From 09d427ba119ed558ff5651f9bf97352815067017 Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Thu, 16 Jan 2025 13:30:35 +0100 Subject: [PATCH] Fix electra builder block production flow (#9001) --- .../versions/electra/BeaconBlockBodyElectra.java | 5 +++++ .../spec/executionlayer/ExecutionLayerChannelStub.java | 9 +++++++++ .../versions/electra/block/BlockProcessorElectra.java | 8 +++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectra.java index e6ea4fb31a0..e651d620cdf 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectra.java @@ -32,6 +32,11 @@ static BeaconBlockBodyElectra required(final BeaconBlockBody body) { ExecutionRequests getExecutionRequests(); + @Override + default Optional getOptionalExecutionRequests() { + return Optional.of(getExecutionRequests()); + } + @Override default Optional toVersionElectra() { return Optional.of(this); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java index 62932ca4235..5fcea357212 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java @@ -433,6 +433,14 @@ public SafeFuture builderGetHeader( .getBlobKzgCommitmentsSchema() .createFromBlobsBundle(blobsBundle); }); + final Optional executionRequests = + schemaDefinitions + .toVersionElectra() + .map(SchemaDefinitionsElectra::getExecutionRequestsSchema) + .map( + executionRequestsSchema -> + new ExecutionRequestsBuilderElectra(executionRequestsSchema).build()); + final BuilderBid builderBid = schemaDefinitions .getBuilderBidSchema() @@ -443,6 +451,7 @@ public SafeFuture builderGetHeader( builder.value(getPayloadResponse.getExecutionPayloadValue()); // using an empty public key for the stub builder.publicKey(BLSPublicKey.empty()); + executionRequests.ifPresent(builder::executionRequests); }); return BuilderBidOrFallbackData.create(builderBid); }) diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java index f28fc1a3772..02eaa62338e 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java @@ -41,7 +41,6 @@ import tech.pegasys.teku.spec.config.SpecConfig; import tech.pegasys.teku.spec.config.SpecConfigElectra; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BeaconBlockBodyElectra; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSummary; import tech.pegasys.teku.spec.datastructures.execution.ExpectedWithdrawals; @@ -141,7 +140,9 @@ public NewPayloadRequest computeNewPayloadRequest( .toList(); final Bytes32 parentBeaconBlockRoot = state.getLatestBlockHeader().getParentRoot(); final ExecutionRequests executionRequests = - BeaconBlockBodyElectra.required(beaconBlockBody).getExecutionRequests(); + beaconBlockBody + .getOptionalExecutionRequests() + .orElseThrow(() -> new BlockProcessingException("Execution requests expected")); return new NewPayloadRequest( executionPayload, versionedHashes, @@ -162,7 +163,8 @@ protected void processOperationsNoValidation( safelyProcess( () -> { final ExecutionRequests executionRequests = - BeaconBlockBodyElectra.required(body).getExecutionRequests(); + body.getOptionalExecutionRequests() + .orElseThrow(() -> new BlockProcessingException("Execution requests expected")); processDepositRequests(state, executionRequests.getDeposits()); processWithdrawalRequests(