Search in sources :

Example 11 with SpecVersion

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);
}
Also used : MutableBeaconStatePhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.MutableBeaconStatePhase0) SpecVersion(tech.pegasys.teku.spec.SpecVersion) MutableBeaconStatePhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.MutableBeaconStatePhase0) BeaconStatePhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStatePhase0) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)

Example 12 with SpecVersion

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);
}
Also used : ValidatorStatuses(tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatuses) SpecVersion(tech.pegasys.teku.spec.SpecVersion) ValidatorStatusFactory(tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory) RewardsAndPenaltiesCalculatorAltair(tech.pegasys.teku.spec.logic.versions.altair.statetransition.epoch.RewardsAndPenaltiesCalculatorAltair) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)

Example 13 with SpecVersion

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);
}
Also used : EpochProcessor(tech.pegasys.teku.spec.logic.common.statetransition.epoch.EpochProcessor) SpecVersion(tech.pegasys.teku.spec.SpecVersion) ValidatorStatusFactory(tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)

Example 14 with SpecVersion

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);
}
Also used : SpecVersion(tech.pegasys.teku.spec.SpecVersion) Bytes4(tech.pegasys.teku.infrastructure.bytes.Bytes4) SszBytes4(tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes4) SszBytes32(tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32) Bytes32(org.apache.tuweni.bytes.Bytes32)

Example 15 with SpecVersion

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));
    }
}
Also used : TransitionConfiguration(tech.pegasys.teku.spec.executionengine.TransitionConfiguration) SpecConfigBellatrix(tech.pegasys.teku.spec.config.SpecConfigBellatrix) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) Cancellable(tech.pegasys.teku.infrastructure.async.Cancellable) SpecConfig(tech.pegasys.teku.spec.config.SpecConfig) ChainHead(tech.pegasys.teku.storage.client.ChainHead) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) ExecutionEngineChannel(tech.pegasys.teku.spec.executionengine.ExecutionEngineChannel) SpecVersion(tech.pegasys.teku.spec.SpecVersion) TekuPair(tech.pegasys.teku.infrastructure.collections.TekuPair) Logger(org.apache.logging.log4j.Logger) RecentChainData(tech.pegasys.teku.storage.client.RecentChainData) Duration(java.time.Duration) Optional(java.util.Optional) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) UInt256(org.apache.tuweni.units.bigints.UInt256) EventLogger(tech.pegasys.teku.infrastructure.logging.EventLogger) Spec(tech.pegasys.teku.spec.Spec) LogManager(org.apache.logging.log4j.LogManager) Bytes32(org.apache.tuweni.bytes.Bytes32) SpecMilestone(tech.pegasys.teku.spec.SpecMilestone) PowBlock(tech.pegasys.teku.spec.datastructures.execution.PowBlock) PowBlock(tech.pegasys.teku.spec.datastructures.execution.PowBlock) SpecVersion(tech.pegasys.teku.spec.SpecVersion) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64)

Aggregations

SpecVersion (tech.pegasys.teku.spec.SpecVersion)23 Bytes32 (org.apache.tuweni.bytes.Bytes32)12 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)7 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)6 Bytes4 (tech.pegasys.teku.infrastructure.bytes.Bytes4)4 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 ValidatorStatusFactory (tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory)3 Optional (java.util.Optional)2 Bytes (org.apache.tuweni.bytes.Bytes)2 BLSSignature (tech.pegasys.teku.bls.BLSSignature)2 SafeFuture (tech.pegasys.teku.infrastructure.async.SafeFuture)2 Spec (tech.pegasys.teku.spec.Spec)2 EnrForkId (tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EnrForkId)2 ValidatorStatuses (tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatuses)2 RecentChainData (tech.pegasys.teku.storage.client.RecentChainData)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 IntList (it.unimi.dsi.fastutil.ints.IntList)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1