Search in sources :

Example 1 with FatalServiceFailureException

use of tech.pegasys.teku.infrastructure.exceptions.FatalServiceFailureException in project teku by ConsenSys.

the class MergeTransitionBlockValidator method verifyFinalizedTransitionBlock.

private SafeFuture<PayloadValidationResult> verifyFinalizedTransitionBlock() {
    return recentChainData.getStore().getFinalizedOptimisticTransitionPayload().map(slotAndPayload -> verifyTransitionPayload(slotAndPayload.getSlot(), slotAndPayload.getExecutionPayload())).orElse(SafeFuture.completedFuture(PayloadStatus.VALID)).thenCompose(status -> {
        if (status.hasInvalidStatus()) {
            return SafeFuture.failedFuture(new FatalServiceFailureException("fork choice", "Optimistic sync finalized an invalid transition block. Unable to recover."));
        }
        if (status.hasValidStatus()) {
            final StoreTransaction transaction = recentChainData.startStoreTransaction();
            transaction.removeFinalizedOptimisticTransitionPayload();
            return transaction.commit().thenApply(__ -> new PayloadValidationResult(status));
        }
        return SafeFuture.completedFuture(new PayloadValidationResult(status));
    });
}
Also used : FatalServiceFailureException(tech.pegasys.teku.infrastructure.exceptions.FatalServiceFailureException) StoreTransaction(tech.pegasys.teku.storage.store.UpdatableStore.StoreTransaction)

Aggregations

FatalServiceFailureException (tech.pegasys.teku.infrastructure.exceptions.FatalServiceFailureException)1 StoreTransaction (tech.pegasys.teku.storage.store.UpdatableStore.StoreTransaction)1