use of tech.pegasys.teku.spec.SpecVersion in project teku by ConsenSys.
the class ForkUpgradeTestExecutor method processAltairUpgrade.
private void processAltairUpgrade(final TestDefinition testDefinition) {
final SpecVersion spec = testDefinition.getSpec().getGenesisSpec();
final BeaconStateSchema<BeaconStatePhase0, MutableBeaconStatePhase0> phase0Schema = BeaconStateSchemaPhase0.create(spec.getConfig());
final BeaconState preState = TestDataUtils.loadSsz(testDefinition, "pre.ssz_snappy", phase0Schema);
final BeaconState postState = TestDataUtils.loadStateFromSsz(testDefinition, "post.ssz_snappy");
final StateUpgrade<?> stateUpgrade = testDefinition.getSpec().getGenesisSpec().getStateUpgrade().orElseThrow();
final BeaconState updated = stateUpgrade.upgrade(preState);
assertThatSszData(updated).isEqualByGettersTo(postState);
}
use of tech.pegasys.teku.spec.SpecVersion in project teku by ConsenSys.
the class RewardsTestExecutorAltair method runTest.
@Override
public void runTest(final TestDefinition testDefinition) throws Throwable {
final BeaconState preState = loadStateFromSsz(testDefinition, "pre.ssz_snappy");
final ValidatorStatusFactory statusFactory = testDefinition.getSpec().getGenesisSpec().getValidatorStatusFactory();
final ValidatorStatuses validatorStatuses = statusFactory.createValidatorStatuses(preState);
final SpecVersion spec = testDefinition.getSpec().getGenesisSpec();
final RewardsAndPenaltiesCalculatorAltair calculator = createRewardsAndPenaltiesCalculator(preState, validatorStatuses, spec);
runTest(testDefinition, calculator, validatorStatuses);
}
use of tech.pegasys.teku.spec.SpecVersion in project teku by ConsenSys.
the class EpochProcessingTestExecutor method runTest.
@Override
public void runTest(final TestDefinition testDefinition) throws Exception {
final BeaconState preState = loadStateFromSsz(testDefinition, "pre.ssz_snappy");
final BeaconState expectedPostState = loadStateFromSsz(testDefinition, "post.ssz_snappy");
final SpecVersion genesisSpec = testDefinition.getSpec().getGenesisSpec();
final EpochProcessor epochProcessor = genesisSpec.getEpochProcessor();
final ValidatorStatusFactory validatorStatusFactory = genesisSpec.getValidatorStatusFactory();
final EpochProcessingExecutor processor = new EpochProcessingExecutor(epochProcessor, validatorStatusFactory);
final BeaconState result = preState.updated(state -> processor.executeOperation(operation, state));
assertThat(result).isEqualTo(expectedPostState);
}
use of tech.pegasys.teku.spec.SpecVersion in project teku by ConsenSys.
the class StatusMessage method createPreGenesisForkDigest.
private static Bytes4 createPreGenesisForkDigest(final Spec spec) {
final SpecVersion genesisSpec = spec.getGenesisSpec();
final Bytes4 genesisFork = genesisSpec.getConfig().getGenesisForkVersion();
final Bytes32 emptyValidatorsRoot = Bytes32.ZERO;
return genesisSpec.miscHelpers().computeForkDigest(genesisFork, emptyValidatorsRoot);
}
use of tech.pegasys.teku.spec.SpecVersion in project teku by ConsenSys.
the class TerminalPowBlockMonitor method checkTerminalBlockByBlockHash.
private void checkTerminalBlockByBlockHash(final Bytes32 blockHashTracking) {
final UInt64 slot = recentChainData.getCurrentSlot().orElseThrow();
final SpecVersion specVersion = spec.atSlot(slot);
final boolean isActivationEpochReached = specVersion.miscHelpers().computeEpochAtSlot(slot).isGreaterThanOrEqualTo(specConfigBellatrix.getTerminalBlockHashActivationEpoch());
if (isActivationEpochReached) {
executionEngine.getPowBlock(blockHashTracking).thenAccept(maybePowBlock -> maybePowBlock.map(PowBlock::getBlockHash).map(blockHashTracking::equals).ifPresent(found -> {
if (!found) {
LOG.trace("checkTerminalBlockByBlockHash: Terminal Block not found.");
return;
}
if (notYetFound(blockHashTracking)) {
LOG.trace("checkTerminalBlockByBlockHash: Terminal Block found!");
onTerminalPowBlockFound(blockHashTracking);
}
})).finish(error -> LOG.error("Unexpected error while searching Terminal Block by Hash", error));
}
}
Aggregations