Search in sources :

Example 1 with MiscHelpers

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());
}
Also used : MiscHelpers(tech.pegasys.teku.spec.logic.common.helpers.MiscHelpers) Bytes32(org.apache.tuweni.bytes.Bytes32)

Example 2 with MiscHelpers

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);
}
Also used : ForkChoiceUtil(tech.pegasys.teku.spec.logic.common.util.ForkChoiceUtil) AttestationUtil(tech.pegasys.teku.spec.logic.common.util.AttestationUtil) EpochProcessorPhase0(tech.pegasys.teku.spec.logic.versions.phase0.statetransition.epoch.EpochProcessorPhase0) MiscHelpers(tech.pegasys.teku.spec.logic.common.helpers.MiscHelpers) OperationSignatureVerifier(tech.pegasys.teku.spec.logic.common.operations.OperationSignatureVerifier) ValidatorsUtil(tech.pegasys.teku.spec.logic.common.util.ValidatorsUtil) ValidatorStatusFactoryPhase0(tech.pegasys.teku.spec.logic.versions.phase0.statetransition.epoch.ValidatorStatusFactoryPhase0) OperationValidator(tech.pegasys.teku.spec.logic.common.operations.validation.OperationValidator) BeaconStateUtil(tech.pegasys.teku.spec.logic.common.util.BeaconStateUtil) BeaconStateMutators(tech.pegasys.teku.spec.logic.common.helpers.BeaconStateMutators) BlockProposalUtil(tech.pegasys.teku.spec.logic.common.util.BlockProposalUtil) Predicates(tech.pegasys.teku.spec.logic.common.helpers.Predicates) BeaconStateAccessors(tech.pegasys.teku.spec.logic.common.helpers.BeaconStateAccessors) BlockProcessorPhase0(tech.pegasys.teku.spec.logic.versions.phase0.block.BlockProcessorPhase0) BeaconStateAccessorsPhase0(tech.pegasys.teku.spec.logic.versions.phase0.helpers.BeaconStateAccessorsPhase0)

Aggregations

MiscHelpers (tech.pegasys.teku.spec.logic.common.helpers.MiscHelpers)2 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 BeaconStateAccessors (tech.pegasys.teku.spec.logic.common.helpers.BeaconStateAccessors)1 BeaconStateMutators (tech.pegasys.teku.spec.logic.common.helpers.BeaconStateMutators)1 Predicates (tech.pegasys.teku.spec.logic.common.helpers.Predicates)1 OperationSignatureVerifier (tech.pegasys.teku.spec.logic.common.operations.OperationSignatureVerifier)1 OperationValidator (tech.pegasys.teku.spec.logic.common.operations.validation.OperationValidator)1 AttestationUtil (tech.pegasys.teku.spec.logic.common.util.AttestationUtil)1 BeaconStateUtil (tech.pegasys.teku.spec.logic.common.util.BeaconStateUtil)1 BlockProposalUtil (tech.pegasys.teku.spec.logic.common.util.BlockProposalUtil)1 ForkChoiceUtil (tech.pegasys.teku.spec.logic.common.util.ForkChoiceUtil)1 ValidatorsUtil (tech.pegasys.teku.spec.logic.common.util.ValidatorsUtil)1 BlockProcessorPhase0 (tech.pegasys.teku.spec.logic.versions.phase0.block.BlockProcessorPhase0)1 BeaconStateAccessorsPhase0 (tech.pegasys.teku.spec.logic.versions.phase0.helpers.BeaconStateAccessorsPhase0)1 EpochProcessorPhase0 (tech.pegasys.teku.spec.logic.versions.phase0.statetransition.epoch.EpochProcessorPhase0)1 ValidatorStatusFactoryPhase0 (tech.pegasys.teku.spec.logic.versions.phase0.statetransition.epoch.ValidatorStatusFactoryPhase0)1