Search in sources :

Example 1 with SpecConfig

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

the class DepositProviderTest method setup.

void setup(final int maxDeposits) {
    when(state.getSlot()).thenReturn(UInt64.valueOf(1234));
    SpecConfig specConfig = SpecConfigLoader.loadConfig("minimal", b -> b.maxDeposits(maxDeposits));
    spec = TestSpecFactory.createPhase0(specConfig);
    depositUtil = new DepositUtil(spec);
    dataStructureUtil = new DataStructureUtil(spec);
    depositProvider = new DepositProvider(new StubMetricsSystem(), recentChainData, eth1DataCache, spec);
    depositMerkleTree = new OptimizedMerkleTree(spec.getGenesisSpecConfig().getDepositContractTreeDepth());
    mockStateEth1DataVotes();
    createDepositEvents(40);
    randomEth1Data = dataStructureUtil.randomEth1Data();
}
Also used : DepositUtil(tech.pegasys.teku.spec.datastructures.util.DepositUtil) OptimizedMerkleTree(tech.pegasys.teku.spec.datastructures.util.OptimizedMerkleTree) StubMetricsSystem(tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem) SpecConfig(tech.pegasys.teku.spec.config.SpecConfig) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil)

Example 2 with SpecConfig

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

the class ConfigProvider method getConfig.

public GetSpecResponse getConfig() {
    final Map<String, String> configAttributes = new HashMap<>();
    final SpecConfig config = spec.atEpoch(UInt64.ZERO).getConfig();
    config.getRawConfig().forEach((k, v) -> {
        configAttributes.put(k, formatValue(v));
    });
    // For the time being, manually add legacy constants for compatibility reasons
    // These constants are no longer defined in newer config files, but may be required by consumers
    configAttributes.put("BLS_WITHDRAWAL_PREFIX", config.getBlsWithdrawalPrefix().toHexString());
    configAttributes.put("TARGET_AGGREGATORS_PER_COMMITTEE", Integer.toString(ValidatorConstants.TARGET_AGGREGATORS_PER_COMMITTEE, 10));
    configAttributes.put("RANDOM_SUBNETS_PER_VALIDATOR", Integer.toString(ValidatorConstants.RANDOM_SUBNETS_PER_VALIDATOR, 10));
    configAttributes.put("EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION", Integer.toString(ValidatorConstants.EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION, 10));
    configAttributes.put("DOMAIN_BEACON_PROPOSER", Domain.BEACON_PROPOSER.toHexString());
    configAttributes.put("DOMAIN_BEACON_ATTESTER", Domain.BEACON_ATTESTER.toHexString());
    configAttributes.put("DOMAIN_RANDAO", Domain.RANDAO.toHexString());
    configAttributes.put("DOMAIN_DEPOSIT", Domain.DEPOSIT.toHexString());
    configAttributes.put("DOMAIN_VOLUNTARY_EXIT", Domain.VOLUNTARY_EXIT.toHexString());
    configAttributes.put("DOMAIN_SELECTION_PROOF", Domain.SELECTION_PROOF.toHexString());
    configAttributes.put("DOMAIN_AGGREGATE_AND_PROOF", Domain.AGGREGATE_AND_PROOF.toHexString());
    // Manually add legacy altair constants
    config.toVersionAltair().ifPresent(altairConfig -> {
        configAttributes.put("DOMAIN_SYNC_COMMITTEE", Domain.SYNC_COMMITTEE.toHexString());
        configAttributes.put("DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF", Domain.SYNC_COMMITTEE_SELECTION_PROOF.toHexString());
        configAttributes.put("DOMAIN_CONTRIBUTION_AND_PROOF", Domain.CONTRIBUTION_AND_PROOF.toHexString());
        configAttributes.put("TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE", Integer.toString(ValidatorConstants.TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE, 10));
        configAttributes.put("SYNC_COMMITTEE_SUBNET_COUNT", Integer.toString(NetworkConstants.SYNC_COMMITTEE_SUBNET_COUNT, 10));
    });
    return new GetSpecResponse(configAttributes);
}
Also used : GetSpecResponse(tech.pegasys.teku.api.response.v1.config.GetSpecResponse) HashMap(java.util.HashMap) SpecConfig(tech.pegasys.teku.spec.config.SpecConfig)

Example 3 with SpecConfig

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

the class BeaconStateSchemaPhase0Test method changeSpecConfigTest_checkPhase0Fields.

@Test
public void changeSpecConfigTest_checkPhase0Fields() {
    final Spec standardSpec = TestSpecFactory.createMinimalPhase0();
    final SpecConfig modifiedConfig = SpecConfigLoader.loadConfig("minimal", b -> b.maxAttestations(123));
    BeaconStatePhase0 s1 = getSchema(modifiedConfig).createEmpty();
    BeaconStatePhase0 s2 = getSchema(standardSpec.getGenesisSpecConfig()).createEmpty();
    assertThat(s1.getPrevious_epoch_attestations().getSchema()).isNotEqualTo(s2.getPrevious_epoch_attestations().getSchema());
    assertThat(s1.getCurrent_epoch_attestations().getSchema()).isNotEqualTo(s2.getCurrent_epoch_attestations().getSchema());
}
Also used : SpecConfig(tech.pegasys.teku.spec.config.SpecConfig) Spec(tech.pegasys.teku.spec.Spec) Test(org.junit.jupiter.api.Test) AbstractBeaconStateSchemaTest(tech.pegasys.teku.spec.datastructures.state.beaconstate.common.AbstractBeaconStateSchemaTest)

Example 4 with SpecConfig

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

the class MiscHelpersTest method testListShuffleAndShuffledIndexCompatibility.

@Test
void testListShuffleAndShuffledIndexCompatibility() {
    final SpecConfig specConfig = mock(SpecConfig.class);
    final MiscHelpers miscHelpers = new MiscHelpers(specConfig);
    when(specConfig.getShuffleRoundCount()).thenReturn(10);
    Bytes32 seed = Bytes32.ZERO;
    int index_count = 3333;
    int[] indices = IntStream.range(0, index_count).toArray();
    miscHelpers.shuffleList(indices, seed);
    assertThat(indices).isEqualTo(IntStream.range(0, index_count).map(i -> miscHelpers.computeShuffledIndex(i, indices.length, seed)).toArray());
}
Also used : SpecConfig(tech.pegasys.teku.spec.config.SpecConfig) Bytes32(org.apache.tuweni.bytes.Bytes32) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with SpecConfig

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

the class DepositProcessingControllerTest method createDepositProcessingController.

private void createDepositProcessingController(final Consumer<SpecConfigBuilder> configModifier) {
    final SpecConfig config = SpecConfigLoader.loadConfig("minimal", configModifier);
    depositProcessingController = new DepositProcessingController(config, eth1Provider, eth1EventsChannel, asyncRunner, depositFetcher, eth1BlockFetcher, headTracker);
}
Also used : SpecConfig(tech.pegasys.teku.spec.config.SpecConfig)

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