Search in sources :

Example 1 with BeaconStateBellatrix

use of tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix in project teku by ConsenSys.

the class MiscHelpersBellatrix method isMergeTransitionBlock.

public boolean isMergeTransitionBlock(final BeaconState genericState, final BeaconBlock block) {
    final BeaconStateBellatrix state = BeaconStateBellatrix.required(genericState);
    final BeaconBlockBodyBellatrix blockBody = BeaconBlockBodyBellatrix.required(block.getBody());
    return !isMergeTransitionComplete(state) && !blockBody.getExecutionPayload().isDefault();
}
Also used : BeaconStateBellatrix(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix) BeaconBlockBodyBellatrix(tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BeaconBlockBodyBellatrix)

Example 2 with BeaconStateBellatrix

use of tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix in project teku by ConsenSys.

the class MergeTransitionBlockValidatorTest method shouldVerifyFinalizedAncestorTransitionBlock.

@Test
void shouldVerifyFinalizedAncestorTransitionBlock() {
    final SignedBlockAndState transitionBlock = generateFinalizedTransition();
    final BeaconStateBellatrix chainHeadState = storageSystem.chainBuilder().getLatestBlockAndState().getState().toVersionBellatrix().orElseThrow();
    withValidTransitionBlock(transitionBlock);
    final SignedBlockAndState blockToVerify = storageSystem.chainBuilder().generateNextBlock();
    final MergeTransitionBlockValidator transitionVerifier = createTransitionValidator();
    assertThat(storageSystem.recentChainData().getStore().getFinalizedOptimisticTransitionPayload()).isPresent();
    final SafeFuture<PayloadValidationResult> result = transitionVerifier.verifyTransitionBlock(chainHeadState.getLatestExecutionPayloadHeader(), blockToVerify.getBlock());
    assertThat(executionEngine.getRequestedPowBlocks()).contains(getExecutionPayload(transitionBlock).getParentHash());
    assertThat(result).isCompletedWithValue(new PayloadValidationResult(PayloadStatus.VALID));
}
Also used : BeaconStateBellatrix(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState) Test(org.junit.jupiter.api.Test)

Example 3 with BeaconStateBellatrix

use of tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix in project teku by ConsenSys.

the class EpochProcessorBellatrix method getRewardAndPenaltyDeltas.

@Override
public RewardAndPenaltyDeltas getRewardAndPenaltyDeltas(final BeaconState genericState, final ValidatorStatuses validatorStatuses) {
    final BeaconStateBellatrix state = BeaconStateBellatrix.required(genericState);
    final RewardsAndPenaltiesCalculatorBellatrix calculator = new RewardsAndPenaltiesCalculatorBellatrix(specConfigBellatrix, state, validatorStatuses, miscHelpersAltair, beaconStateAccessorsAltair);
    return calculator.getDeltas();
}
Also used : BeaconStateBellatrix(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix)

Example 4 with BeaconStateBellatrix

use of tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix in project teku by ConsenSys.

the class MergeTransitionBlockValidatorTest method shouldFailWithFatalServiceFailuresExceptionWhenFinalizedAncestorTransitionBlockIsInvalid.

/**
 * We can't mark a finalized block as invalid or reorg to a valid fork, so if we discover we
 * finalized an invalid transition we have to bail out with {@link
 * tech.pegasys.teku.infrastructure.exceptions.FatalServiceFailureException}
 */
@Test
void shouldFailWithFatalServiceFailuresExceptionWhenFinalizedAncestorTransitionBlockIsInvalid() {
    final SignedBlockAndState transitionBlock = generateFinalizedTransition();
    final BeaconStateBellatrix chainHeadState = storageSystem.chainBuilder().getLatestBlockAndState().getState().toVersionBellatrix().orElseThrow();
    withInvalidTransitionBlock(transitionBlock);
    final SignedBlockAndState blockToVerify = storageSystem.chainBuilder().generateNextBlock();
    final MergeTransitionBlockValidator transitionVerifier = createTransitionValidator();
    assertThat(storageSystem.recentChainData().getStore().getFinalizedOptimisticTransitionPayload()).isPresent();
    final SafeFuture<PayloadValidationResult> result = transitionVerifier.verifyTransitionBlock(chainHeadState.getLatestExecutionPayloadHeader(), blockToVerify.getBlock());
    assertThatSafeFuture(result).isCompletedExceptionallyWith(FatalServiceFailureException.class);
}
Also used : BeaconStateBellatrix(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState) Test(org.junit.jupiter.api.Test)

Aggregations

BeaconStateBellatrix (tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix)4 Test (org.junit.jupiter.api.Test)2 SignedBlockAndState (tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState)2 BeaconBlockBodyBellatrix (tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BeaconBlockBodyBellatrix)1