From 15d7f6a5f65ca023de1fe124e8f2c7bfe66ccbe2 Mon Sep 17 00:00:00 2001 From: g11tech Date: Wed, 8 May 2024 16:01:26 +0530 Subject: [PATCH] feat: handle the EL payload sending data in deposit requests instead of deposit receipts (#6746) --- .../beacon-node/src/execution/engine/types.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/beacon-node/src/execution/engine/types.ts b/packages/beacon-node/src/execution/engine/types.ts index 54b3a415ec98..f0701d48c5fc 100644 --- a/packages/beacon-node/src/execution/engine/types.ts +++ b/packages/beacon-node/src/execution/engine/types.ts @@ -125,7 +125,9 @@ type ExecutionPayloadResponse = ExecutionPayloadRpc | ExecutionPayloadRpcWithVal export type ExecutionPayloadBodyRpc = { transactions: DATA[]; withdrawals: WithdrawalV1[] | null | undefined; - depositReceipts: DepositReceiptV1[] | null | undefined; + // currently there is a discepancy between EL and CL field name references for deposit requests + // its likely CL receipt will be renamed to requests + depositRequests: DepositReceiptV1[] | null | undefined; withdrawalRequests: ExecutionLayerWithdrawalRequestV1[] | null | undefined; }; @@ -155,7 +157,7 @@ export type ExecutionPayloadRpc = { blobGasUsed?: QUANTITY; // DENEB excessBlobGas?: QUANTITY; // DENEB parentBeaconBlockRoot?: QUANTITY; // DENEB - depositReceipts?: DepositReceiptRpc[]; // ELECTRA + depositRequests?: DepositReceiptRpc[]; // ELECTRA withdrawalRequests?: ExecutionLayerWithdrawalRequestRpc[]; // ELECTRA }; @@ -231,10 +233,10 @@ export function serializeExecutionPayload(fork: ForkName, data: ExecutionPayload payload.excessBlobGas = numToQuantity(excessBlobGas); } - // ELECTRA adds depositReceipts to the ExecutionPayload + // ELECTRA adds depositReceipts/depositRequests to the ExecutionPayload if (ForkSeq[fork] >= ForkSeq.electra) { const {depositReceipts, withdrawalRequests} = data as electra.ExecutionPayload; - payload.depositReceipts = depositReceipts.map(serializeDepositReceipt); + payload.depositRequests = depositReceipts.map(serializeDepositReceipt); payload.withdrawalRequests = withdrawalRequests.map(serializeExecutionLayerWithdrawalRequest); } @@ -324,14 +326,15 @@ export function parseExecutionPayload( } if (ForkSeq[fork] >= ForkSeq.electra) { - const {depositReceipts, withdrawalRequests} = data; + // electra adds depositRequests/depositReceipts + const {depositRequests, withdrawalRequests} = data; // Geth can also reply with null - if (depositReceipts == null) { + if (depositRequests == null) { throw Error( - `depositReceipts missing for ${fork} >= electra executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}` + `depositRequests missing for ${fork} >= electra executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}` ); } - (executionPayload as electra.ExecutionPayload).depositReceipts = depositReceipts.map(deserializeDepositReceipt); + (executionPayload as electra.ExecutionPayload).depositReceipts = depositRequests.map(deserializeDepositReceipt); if (withdrawalRequests == null) { throw Error( @@ -454,7 +457,7 @@ export function deserializeExecutionPayloadBody(data: ExecutionPayloadBodyRpc | ? { transactions: data.transactions.map((tran) => dataToBytes(tran, null)), withdrawals: data.withdrawals ? data.withdrawals.map(deserializeWithdrawal) : null, - depositReceipts: data.depositReceipts ? data.depositReceipts.map(deserializeDepositReceipt) : null, + depositReceipts: data.depositRequests ? data.depositRequests.map(deserializeDepositReceipt) : null, withdrawalRequests: data.withdrawalRequests ? data.withdrawalRequests.map(deserializeExecutionLayerWithdrawalRequest) : null, @@ -467,7 +470,7 @@ export function serializeExecutionPayloadBody(data: ExecutionPayloadBody | null) ? { transactions: data.transactions.map((tran) => bytesToData(tran)), withdrawals: data.withdrawals ? data.withdrawals.map(serializeWithdrawal) : null, - depositReceipts: data.depositReceipts ? data.depositReceipts.map(serializeDepositReceipt) : null, + depositRequests: data.depositReceipts ? data.depositReceipts.map(serializeDepositReceipt) : null, withdrawalRequests: data.withdrawalRequests ? data.withdrawalRequests.map(serializeExecutionLayerWithdrawalRequest) : null,