use of tech.pegasys.teku.spec.logic.common.helpers.MiscHelpers in project teku by ConsenSys.
the class ShufflingTestExecutor method runTest.
@Override
public void runTest(final TestDefinition testDefinition) throws Exception {
final ShufflingData shufflingData = loadYaml(testDefinition, "mapping.yaml", ShufflingData.class);
final MiscHelpers miscHelpers = testDefinition.getSpec().getGenesisSpec().miscHelpers();
final Bytes32 seed = Bytes32.fromHexString(shufflingData.getSeed());
IntStream.range(0, shufflingData.getCount()).forEach(index -> assertThat(miscHelpers.computeShuffledIndex(index, shufflingData.getCount(), seed)).isEqualTo(shufflingData.getMapping(index)));
final int[] inputs = IntStream.range(0, shufflingData.getCount()).toArray();
miscHelpers.shuffleList(inputs, seed);
assertThat(inputs).isEqualTo(shufflingData.getMapping());
}
use of tech.pegasys.teku.spec.logic.common.helpers.MiscHelpers in project teku by ConsenSys.
the class SpecLogicPhase0 method create.
public static SpecLogicPhase0 create(final SpecConfig config, final SchemaDefinitions schemaDefinitions) {
// Helpers
final Predicates predicates = new Predicates();
final MiscHelpers miscHelpers = new MiscHelpers(config);
final BeaconStateAccessors beaconStateAccessors = new BeaconStateAccessorsPhase0(config, predicates, miscHelpers);
final BeaconStateMutators beaconStateMutators = new BeaconStateMutators(config, miscHelpers, beaconStateAccessors);
// Operation validaton
final OperationSignatureVerifier operationSignatureVerifier = new OperationSignatureVerifier(miscHelpers, beaconStateAccessors);
// Util
final ValidatorsUtil validatorsUtil = new ValidatorsUtil(config, miscHelpers, beaconStateAccessors);
final BeaconStateUtil beaconStateUtil = new BeaconStateUtil(config, schemaDefinitions, predicates, miscHelpers, beaconStateAccessors);
final AttestationUtil attestationUtil = new AttestationUtil(schemaDefinitions, beaconStateAccessors, miscHelpers);
final OperationValidator operationValidator = OperationValidator.create(config, predicates, miscHelpers, beaconStateAccessors, attestationUtil);
final ValidatorStatusFactoryPhase0 validatorStatusFactory = new ValidatorStatusFactoryPhase0(config, beaconStateUtil, attestationUtil, beaconStateAccessors, predicates);
final EpochProcessorPhase0 epochProcessor = new EpochProcessorPhase0(config, miscHelpers, beaconStateAccessors, beaconStateMutators, validatorsUtil, beaconStateUtil, validatorStatusFactory, schemaDefinitions);
final BlockProcessorPhase0 blockProcessor = new BlockProcessorPhase0(config, predicates, miscHelpers, beaconStateAccessors, beaconStateMutators, operationSignatureVerifier, beaconStateUtil, attestationUtil, validatorsUtil, operationValidator);
final ForkChoiceUtil forkChoiceUtil = new ForkChoiceUtil(config, beaconStateAccessors, attestationUtil, miscHelpers);
final BlockProposalUtil blockProposalUtil = new BlockProposalUtil(schemaDefinitions, blockProcessor);
return new SpecLogicPhase0(predicates, miscHelpers, beaconStateAccessors, beaconStateMutators, operationSignatureVerifier, validatorsUtil, beaconStateUtil, attestationUtil, operationValidator, validatorStatusFactory, epochProcessor, blockProcessor, forkChoiceUtil, blockProposalUtil);
}
Aggregations