use of tech.pegasys.teku.spec.executionengine.PayloadStatus in project teku by ConsenSys.
the class BellatrixTransitionHelpersTest method shouldBeValidWhenTerminalBlockHashMatchesInActivationEpoch.
@Test
void shouldBeValidWhenTerminalBlockHashMatchesInActivationEpoch() {
final UInt64 activationEpoch = UInt64.valueOf(15);
final Spec spec = createSpec(payload.getParentHash(), activationEpoch);
final UInt64 blockSlot = spec.computeStartSlotAtEpoch(activationEpoch);
final SafeFuture<PayloadStatus> result = spec.getGenesisSpec().getBellatrixTransitionHelpers().orElseThrow().validateMergeBlock(executionEngine, payload, blockSlot);
assertPayloadResultStatus(result, ExecutionPayloadStatus.VALID);
}
use of tech.pegasys.teku.spec.executionengine.PayloadStatus in project teku by ConsenSys.
the class BellatrixTransitionHelpersTest method shouldBeValidWhenTerminalBlockHashMatchesAfterActivationEpoch.
@Test
void shouldBeValidWhenTerminalBlockHashMatchesAfterActivationEpoch() {
final UInt64 activationEpoch = UInt64.valueOf(15);
final Spec spec = createSpec(payload.getParentHash(), activationEpoch);
final UInt64 blockSlot = spec.computeStartSlotAtEpoch(activationEpoch.plus(1));
final SafeFuture<PayloadStatus> result = spec.getGenesisSpec().getBellatrixTransitionHelpers().orElseThrow().validateMergeBlock(executionEngine, payload, blockSlot);
assertPayloadResultStatus(result, ExecutionPayloadStatus.VALID);
}
use of tech.pegasys.teku.spec.executionengine.PayloadStatus in project teku by ConsenSys.
the class ForkChoiceTest method setForkChoiceNotifierForkChoiceUpdatedResult.
private void setForkChoiceNotifierForkChoiceUpdatedResult(final Optional<PayloadStatus> status) {
ForkChoiceUpdatedResult result = status.map(payloadStatus -> new ForkChoiceUpdatedResult(payloadStatus, Optional.empty())).orElse(null);
when(forkChoiceNotifier.onForkChoiceUpdated(any())).thenReturn(SafeFuture.completedFuture(Optional.ofNullable(result)));
}
use of tech.pegasys.teku.spec.executionengine.PayloadStatus in project teku by ConsenSys.
the class ForkChoiceTest method onBlock_shouldUseLatestValidHashFromForkChoiceUpdated.
@Test
void onBlock_shouldUseLatestValidHashFromForkChoiceUpdated() {
doMerge();
finalizeEpoch(2);
assertThat(recentChainData.isChainHeadOptimistic()).isFalse();
final UInt64 nextBlockSlot = storageSystem.chainBuilder().getLatestSlot().plus(1);
storageSystem.chainUpdater().setCurrentSlot(nextBlockSlot);
final SignedBlockAndState blockAndState = storageSystem.chainBuilder().generateBlockAtSlot(nextBlockSlot);
executionEngine.setPayloadStatus(PayloadStatus.SYNCING);
setForkChoiceNotifierForkChoiceUpdatedResult(PayloadStatus.SYNCING);
final SafeFuture<BlockImportResult> result = forkChoice.onBlock(blockAndState.getBlock(), executionEngine);
assertBlockImportedSuccessfully(result, true);
assertForkChoiceUpdateNotification(blockAndState, true);
// let's import a new block on top the optimistic head
// let's make the EL return ACCEPTED on newPayload call but return INVALID on forkChoiceUpdated
// call
// INVALID will give us a lastValidHash corresponding to the previous block payload (imported
// optimistically)
executionEngine.setPayloadStatus(PayloadStatus.ACCEPTED);
PayloadStatus invalidWithLastValidBlockHash = PayloadStatus.create(ExecutionPayloadStatus.INVALID, blockAndState.getBlock().getMessage().getBody().getOptionalExecutionPayload().map(ExecutionPayload::getBlockHash), Optional.empty());
setForkChoiceNotifierForkChoiceUpdatedResult(invalidWithLastValidBlockHash);
storageSystem.chainUpdater().setCurrentSlot(nextBlockSlot.increment());
final SignedBlockAndState blockAndStatePlus1 = storageSystem.chainBuilder().generateBlockAtSlot(nextBlockSlot.increment());
// before importing, previous block is optimistic
assertThat(isFullyValidated(blockAndState.getRoot())).isFalse();
importBlockOptimistically(blockAndStatePlus1);
// after importing, previous block is fully valid
assertThat(isFullyValidated(blockAndState.getRoot())).isTrue();
// processing the head
setForkChoiceNotifierForkChoiceUpdatedResult(PayloadStatus.VALID);
processHead(blockAndStatePlus1.getSlot());
// we have now no optimistic head
assertHeadIsFullyValidated(blockAndState);
}
use of tech.pegasys.teku.spec.executionengine.PayloadStatus in project teku by ConsenSys.
the class MergeTransitionBlockValidatorTest method shouldReportRootForInvalidNonFinalizedAncestorTransitionBlock.
@Test
void shouldReportRootForInvalidNonFinalizedAncestorTransitionBlock() {
final SignedBlockAndState transitionBlock = generateNonfinalizedTransition();
final SignedBlockAndState chainHead = storageSystem.chainBuilder().getLatestBlockAndState();
final SignedBlockAndState blockToVerify = storageSystem.chainBuilder().generateNextBlock();
withInvalidTransitionBlock(transitionBlock);
final MergeTransitionBlockValidator transitionVerifier = createTransitionValidator();
assertThat(storageSystem.recentChainData().getForkChoiceStrategy().orElseThrow().getOptimisticallySyncedTransitionBlockRoot(chainHead.getRoot())).isPresent();
final SafeFuture<PayloadValidationResult> result = transitionVerifier.verifyTransitionBlock(chainHead.getState().toVersionBellatrix().orElseThrow().getLatestExecutionPayloadHeader(), blockToVerify.getBlock());
assertThat(executionEngine.getRequestedPowBlocks()).contains(getExecutionPayload(transitionBlock).getParentHash());
assertThat(result).isCompleted();
final PayloadValidationResult validationResult = result.join();
assertThat(validationResult.getInvalidTransitionBlockRoot()).contains(transitionBlock.getRoot());
assertThat(validationResult.getStatus()).matches(PayloadStatus::hasInvalidStatus);
}
Aggregations