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();
}
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));
}
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();
}
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);
}
Aggregations