From 02f1fe246724d215a031a356680114d73fb4d18c Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Fri, 11 Oct 2024 00:43:32 -0700 Subject: [PATCH 1/2] initial commit --- .../src/chain/produceBlock/produceBlockBody.ts | 9 +++++++++ packages/beacon-node/src/execution/builder/http.ts | 5 ++++- packages/beacon-node/src/execution/builder/interface.ts | 2 ++ packages/types/src/electra/sszTypes.ts | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts index ff8221a326e9..b8c5f470780b 100644 --- a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts +++ b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts @@ -220,6 +220,14 @@ export async function produceBlockBody( } else { blobsResult = {type: BlobsResultType.preDeneb}; } + + if (ForkSeq[fork] >= ForkSeq.electra) { + const {executionRequests} = builderRes; + if (executionRequests === undefined) { + throw Error(`Invalid builder getHeader response for fork=${fork}, missing exeuctionRequests`); + } + (blockBody as electra.BlindedBeaconBlockBody).executionRequests = executionRequests; + } } // blockType === BlockType.Full @@ -455,6 +463,7 @@ async function prepareExecutionPayloadHeader( header: ExecutionPayloadHeader; executionPayloadValue: Wei; blobKzgCommitments?: deneb.BlobKzgCommitments; + executionRequests?: electra.ExecutionRequests; }> { if (!chain.executionBuilder) { throw Error("executionBuilder required"); diff --git a/packages/beacon-node/src/execution/builder/http.ts b/packages/beacon-node/src/execution/builder/http.ts index 934b874f5ae3..d7b36a666468 100644 --- a/packages/beacon-node/src/execution/builder/http.ts +++ b/packages/beacon-node/src/execution/builder/http.ts @@ -8,6 +8,7 @@ import { SignedBeaconBlockOrContents, SignedBlindedBeaconBlock, ExecutionPayloadHeader, + electra, } from "@lodestar/types"; import {parseExecutionPayloadAndBlobsBundle, reconstructFullBlockOrContents} from "@lodestar/state-transition"; import {ChainForkConfig} from "@lodestar/config"; @@ -114,6 +115,7 @@ export class ExecutionBuilderHttp implements IExecutionBuilder { header: ExecutionPayloadHeader; executionPayloadValue: Wei; blobKzgCommitments?: deneb.BlobKzgCommitments; + executionRequests?: electra.ExecutionRequests; }> { const signedBuilderBid = (await this.api.getHeader({slot, parentHash, proposerPubkey})).value(); @@ -123,7 +125,8 @@ export class ExecutionBuilderHttp implements IExecutionBuilder { const {header, value: executionPayloadValue} = signedBuilderBid.message; const {blobKzgCommitments} = signedBuilderBid.message as deneb.BuilderBid; - return {header, executionPayloadValue, blobKzgCommitments}; + const {executionRequests} = signedBuilderBid.message as electra.BuilderBid; + return {header, executionPayloadValue, blobKzgCommitments, executionRequests}; } async submitBlindedBlock(signedBlindedBlock: SignedBlindedBeaconBlock): Promise { diff --git a/packages/beacon-node/src/execution/builder/interface.ts b/packages/beacon-node/src/execution/builder/interface.ts index 9a655a68de02..5a6a4eb82f63 100644 --- a/packages/beacon-node/src/execution/builder/interface.ts +++ b/packages/beacon-node/src/execution/builder/interface.ts @@ -8,6 +8,7 @@ import { SignedBeaconBlockOrContents, ExecutionPayloadHeader, SignedBlindedBeaconBlock, + electra, } from "@lodestar/types"; import {ForkExecution} from "@lodestar/params"; @@ -36,6 +37,7 @@ export interface IExecutionBuilder { header: ExecutionPayloadHeader; executionPayloadValue: Wei; blobKzgCommitments?: deneb.BlobKzgCommitments; + executionRequests?: electra.ExecutionRequests; }>; submitBlindedBlock(signedBlock: SignedBlindedBeaconBlock): Promise; } diff --git a/packages/types/src/electra/sszTypes.ts b/packages/types/src/electra/sszTypes.ts index 7200af5f4ead..d73c33edd523 100644 --- a/packages/types/src/electra/sszTypes.ts +++ b/packages/types/src/electra/sszTypes.ts @@ -211,6 +211,7 @@ export const BlindedBeaconBlockBody = new ContainerType( executionPayloadHeader: ExecutionPayloadHeader, blsToExecutionChanges: capellaSsz.BeaconBlockBody.fields.blsToExecutionChanges, blobKzgCommitments: denebSsz.BeaconBlockBody.fields.blobKzgCommitments, + executionRequests: ExecutionRequests, // New in ELECTRA }, {typeName: "BlindedBeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true} ); @@ -235,6 +236,7 @@ export const BuilderBid = new ContainerType( { header: ExecutionPayloadHeader, // Modified in ELECTRA blindedBlobsBundle: denebSsz.BlobKzgCommitments, + executionRequests: ExecutionRequests, // New in ELECTRA value: UintBn256, pubkey: BLSPubkey, }, From 5336be334b9f3cc24c16a427158c75d1c4a56ff0 Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Fri, 11 Oct 2024 12:36:12 -0700 Subject: [PATCH 2/2] Update packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts Co-authored-by: Nico Flaig --- packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts index b8c5f470780b..8d90fb6c5b1a 100644 --- a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts +++ b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts @@ -224,7 +224,7 @@ export async function produceBlockBody( if (ForkSeq[fork] >= ForkSeq.electra) { const {executionRequests} = builderRes; if (executionRequests === undefined) { - throw Error(`Invalid builder getHeader response for fork=${fork}, missing exeuctionRequests`); + throw Error(`Invalid builder getHeader response for fork=${fork}, missing executionRequests`); } (blockBody as electra.BlindedBeaconBlockBody).executionRequests = executionRequests; }