From c0115b075fac8abded6ce0a5b69a4be393795659 Mon Sep 17 00:00:00 2001 From: g11tech Date: Tue, 13 Jun 2023 11:28:56 +0530 Subject: [PATCH] fix: handle dataGasUsed in engine for deneb payload (#5629) --- .../beacon-node/src/execution/engine/types.ts | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/beacon-node/src/execution/engine/types.ts b/packages/beacon-node/src/execution/engine/types.ts index f1d6e4a1a67..50608b3155e 100644 --- a/packages/beacon-node/src/execution/engine/types.ts +++ b/packages/beacon-node/src/execution/engine/types.ts @@ -135,6 +135,7 @@ export type ExecutionPayloadRpc = { blockHash: DATA; // 32 bytes transactions: DATA[]; withdrawals?: WithdrawalRpc[]; // Capella hardfork + dataGasUsed?: QUANTITY; // DENEB excessDataGas?: QUANTITY; // DENEB }; @@ -187,9 +188,11 @@ export function serializeExecutionPayload(fork: ForkName, data: allForks.Executi payload.withdrawals = withdrawals.map(serializeWithdrawal); } - // DENEB adds excessDataGas to the ExecutionPayload - if ((data as deneb.ExecutionPayload).excessDataGas !== undefined) { - payload.excessDataGas = numToQuantity((data as deneb.ExecutionPayload).excessDataGas); + // DENEB adds dataGasUsed & excessDataGas to the ExecutionPayload + if (ForkSeq[fork] >= ForkSeq.deneb) { + const {dataGasUsed, excessDataGas} = data as deneb.ExecutionPayload; + payload.dataGasUsed = numToQuantity(dataGasUsed); + payload.excessDataGas = numToQuantity(excessDataGas); } return payload; @@ -251,12 +254,21 @@ export function parseExecutionPayload( // DENEB adds excessDataGas to the ExecutionPayload if (ForkSeq[fork] >= ForkSeq.deneb) { - if (data.excessDataGas == null) { + const {dataGasUsed, excessDataGas} = data; + + if (dataGasUsed == null) { + throw Error( + `dataGasUsed missing for ${fork} >= deneb executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}` + ); + } + if (excessDataGas == null) { throw Error( `excessDataGas missing for ${fork} >= deneb executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}` ); } - (executionPayload as deneb.ExecutionPayload).excessDataGas = quantityToBigint(data.excessDataGas); + + (executionPayload as deneb.ExecutionPayload).dataGasUsed = quantityToBigint(dataGasUsed); + (executionPayload as deneb.ExecutionPayload).excessDataGas = quantityToBigint(excessDataGas); } return {executionPayload, blockValue, blobsBundle};