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();
}
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);
}
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());
}
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());
}
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);
}
Aggregations