Skip to content

Commit

Permalink
Fix electra builder block production flow (#9001)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr authored Jan 16, 2025
1 parent c315305 commit 09d427b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ static BeaconBlockBodyElectra required(final BeaconBlockBody body) {

ExecutionRequests getExecutionRequests();

@Override
default Optional<ExecutionRequests> getOptionalExecutionRequests() {
return Optional.of(getExecutionRequests());
}

@Override
default Optional<BeaconBlockBodyElectra> toVersionElectra() {
return Optional.of(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ public SafeFuture<BuilderBidOrFallbackData> builderGetHeader(
.getBlobKzgCommitmentsSchema()
.createFromBlobsBundle(blobsBundle);
});
final Optional<ExecutionRequests> executionRequests =
schemaDefinitions
.toVersionElectra()
.map(SchemaDefinitionsElectra::getExecutionRequestsSchema)
.map(
executionRequestsSchema ->
new ExecutionRequestsBuilderElectra(executionRequestsSchema).build());

final BuilderBid builderBid =
schemaDefinitions
.getBuilderBidSchema()
Expand All @@ -443,6 +451,7 @@ public SafeFuture<BuilderBidOrFallbackData> 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);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit 09d427b

Please sign in to comment.