Search in sources :

Example 6 with SpecConfig

use of tech.pegasys.teku.spec.config.SpecConfig in project teku by ConsenSys.

the class MinimumGenesisTimeBlockFinderTest method withMinGenesisTime.

private void withMinGenesisTime(final long minGenesisTime, final Optional<UInt64> eth1DepositContractDeployBlock) {
    final SpecConfig config = SpecConfigLoader.loadConfig("minimal", builder -> builder.minGenesisTime(UInt64.valueOf(minGenesisTime)));
    minimumGenesisTimeBlockFinder = new MinimumGenesisTimeBlockFinder(config, eth1Provider, eth1DepositContractDeployBlock);
}
Also used : SpecConfig(tech.pegasys.teku.spec.config.SpecConfig)

Example 7 with SpecConfig

use of tech.pegasys.teku.spec.config.SpecConfig in project teku by ConsenSys.

the class ConfigProviderTest method shouldParseResultOfConfig.

@Test
void shouldParseResultOfConfig() {
    final GetSpecResponse response = configProvider.getConfig();
    final SpecConfig specConfig = SpecConfigLoader.loadRemoteConfig(response.data);
    final SpecConfig expectedConfig = spec.getGenesisSpecConfig();
    assertThat(specConfig).isEqualToComparingFieldByField(expectedConfig);
}
Also used : GetSpecResponse(tech.pegasys.teku.api.response.v1.config.GetSpecResponse) SpecConfig(tech.pegasys.teku.spec.config.SpecConfig) Test(org.junit.jupiter.api.Test)

Example 8 with SpecConfig

use of tech.pegasys.teku.spec.config.SpecConfig in project teku by ConsenSys.

the class BlockProposalTestUtil method get_eth1_data_stub.

private Eth1Data get_eth1_data_stub(BeaconState state, UInt64 current_epoch) {
    final SpecConfig specConfig = spec.atSlot(state.getSlot()).getConfig();
    final int epochsPerPeriod = specConfig.getEpochsPerEth1VotingPeriod();
    UInt64 votingPeriod = current_epoch.dividedBy(epochsPerPeriod);
    return new Eth1Data(Hash.sha256(SSZ.encodeUInt64(epochsPerPeriod)), state.getEth1_deposit_index(), Hash.sha256(Hash.sha256(SSZ.encodeUInt64(votingPeriod.longValue()))));
}
Also used : SpecConfig(tech.pegasys.teku.spec.config.SpecConfig) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Eth1Data(tech.pegasys.teku.spec.datastructures.blocks.Eth1Data)

Example 9 with SpecConfig

use of tech.pegasys.teku.spec.config.SpecConfig in project teku by ConsenSys.

the class BeaconBlockBodySchemaPhase0Test method create_mainnet.

@Test
public void create_mainnet() {
    final Spec spec = TestSpecFactory.createMainnetPhase0();
    final SpecConfig specConfig = spec.getGenesisSpecConfig();
    final BeaconBlockBodySchemaPhase0 specA = BeaconBlockBodySchemaPhase0.create(specConfig, new AttesterSlashingSchema(new IndexedAttestationSchema(specConfig)));
    final BeaconBlockBodySchemaPhase0 specB = BeaconBlockBodySchemaPhase0.create(specConfig, new AttesterSlashingSchema(new IndexedAttestationSchema(specConfig)));
    assertThat(specA).isEqualTo(specB);
}
Also used : IndexedAttestationSchema(tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation.IndexedAttestationSchema) AttesterSlashingSchema(tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing.AttesterSlashingSchema) SpecConfig(tech.pegasys.teku.spec.config.SpecConfig) Spec(tech.pegasys.teku.spec.Spec) Test(org.junit.jupiter.api.Test)

Example 10 with SpecConfig

use of tech.pegasys.teku.spec.config.SpecConfig in project teku by ConsenSys.

the class AbstractBeaconStateSchemaTest method changeSpecConfigTest.

@Test
public void changeSpecConfigTest() {
    final Spec standardSpec = TestSpecFactory.createMinimalPhase0();
    final SpecConfig modifiedConfig = SpecConfigLoader.loadConfig("minimal", b -> b.slotsPerHistoricalRoot(123).historicalRootsLimit(123).epochsPerEth1VotingPeriod(123).validatorRegistryLimit(123L).epochsPerHistoricalVector(123).epochsPerSlashingsVector(123).maxAttestations(123));
    BeaconState s1 = getSchema(modifiedConfig).createEmpty();
    BeaconState s2 = getSchema(standardSpec.getGenesisSpecConfig()).createEmpty();
    assertThat(s1.getBlock_roots().getSchema()).isNotEqualTo(s2.getBlock_roots().getSchema());
    assertThat(s1.getState_roots().getSchema()).isNotEqualTo(s2.getState_roots().getSchema());
    assertThat(s1.getHistorical_roots().getSchema()).isNotEqualTo(s2.getHistorical_roots().getSchema());
    assertThat(s1.getEth1_data_votes().getSchema()).isNotEqualTo(s2.getEth1_data_votes().getSchema());
    assertThat(s1.getValidators().getSchema()).isNotEqualTo(s2.getValidators().getSchema());
    assertThat(s1.getBalances().getSchema()).isNotEqualTo(s2.getBalances().getSchema());
    assertThat(s1.getRandao_mixes().getSchema()).isNotEqualTo(s2.getRandao_mixes().getSchema());
    assertThat(s1.getSlashings().getSchema()).isNotEqualTo(s2.getSlashings().getSchema());
}
Also used : SpecConfig(tech.pegasys.teku.spec.config.SpecConfig) Spec(tech.pegasys.teku.spec.Spec) MutableBeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState) Test(org.junit.jupiter.api.Test)

Aggregations

SpecConfig (tech.pegasys.teku.spec.config.SpecConfig)19 Test (org.junit.jupiter.api.Test)12 Spec (tech.pegasys.teku.spec.Spec)7 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)3 Bytes32 (org.apache.tuweni.bytes.Bytes32)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 GetSpecResponse (tech.pegasys.teku.api.response.v1.config.GetSpecResponse)2 SpecConfigLoader (tech.pegasys.teku.spec.config.SpecConfigLoader)2 SignedBeaconBlock (tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock)2 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 IntList (it.unimi.dsi.fastutil.ints.IntList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1