From 4f19d94730bdc5874ff7db783fab72a969bb386e Mon Sep 17 00:00:00 2001 From: gajinder Date: Fri, 28 Jul 2023 19:09:16 +0530 Subject: [PATCH 1/2] refactor: rename data gas to blob gas for relevant deneb fields --- .../beacon-node/src/execution/engine/types.ts | 28 +++++++++---------- packages/light-client/src/spec/utils.ts | 16 +++++------ .../unit/isValidLightClientHeader.test.ts | 2 +- .../src/block/processExecutionPayload.ts | 8 +++--- .../src/slot/upgradeStateToDeneb.ts | 6 ++-- packages/types/src/deneb/sszTypes.ts | 8 +++--- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/beacon-node/src/execution/engine/types.ts b/packages/beacon-node/src/execution/engine/types.ts index 14ec66bdcca..3f7254f1297 100644 --- a/packages/beacon-node/src/execution/engine/types.ts +++ b/packages/beacon-node/src/execution/engine/types.ts @@ -129,8 +129,8 @@ export type ExecutionPayloadRpc = { blockHash: DATA; // 32 bytes transactions: DATA[]; withdrawals?: WithdrawalRpc[]; // Capella hardfork - dataGasUsed?: QUANTITY; // DENEB - excessDataGas?: QUANTITY; // DENEB + blobGasUsed?: QUANTITY; // DENEB + excessBlobGas?: QUANTITY; // DENEB parentBeaconBlockRoot?: QUANTITY; // DENEB }; @@ -185,11 +185,11 @@ export function serializeExecutionPayload(fork: ForkName, data: allForks.Executi payload.withdrawals = withdrawals.map(serializeWithdrawal); } - // DENEB adds dataGasUsed & excessDataGas to the ExecutionPayload + // DENEB adds blobGasUsed & excessBlobGas to the ExecutionPayload if (ForkSeq[fork] >= ForkSeq.deneb) { - const {dataGasUsed, excessDataGas} = data as deneb.ExecutionPayload; - payload.dataGasUsed = numToQuantity(dataGasUsed); - payload.excessDataGas = numToQuantity(excessDataGas); + const {blobGasUsed, excessBlobGas} = data as deneb.ExecutionPayload; + payload.blobGasUsed = numToQuantity(blobGasUsed); + payload.excessBlobGas = numToQuantity(excessBlobGas); } return payload; @@ -249,23 +249,23 @@ export function parseExecutionPayload( (executionPayload as capella.ExecutionPayload).withdrawals = withdrawals.map((w) => deserializeWithdrawal(w)); } - // DENEB adds excessDataGas to the ExecutionPayload + // DENEB adds excessBlobGas to the ExecutionPayload if (ForkSeq[fork] >= ForkSeq.deneb) { - const {dataGasUsed, excessDataGas} = data; + const {blobGasUsed, excessBlobGas} = data; - if (dataGasUsed == null) { + if (blobGasUsed == null) { throw Error( - `dataGasUsed missing for ${fork} >= deneb executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}` + `blobGasUsed missing for ${fork} >= deneb executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}` ); } - if (excessDataGas == null) { + if (excessBlobGas == null) { throw Error( - `excessDataGas missing for ${fork} >= deneb executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}` + `excessBlobGas missing for ${fork} >= deneb executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}` ); } - (executionPayload as deneb.ExecutionPayload).dataGasUsed = quantityToBigint(dataGasUsed); - (executionPayload as deneb.ExecutionPayload).excessDataGas = quantityToBigint(excessDataGas); + (executionPayload as deneb.ExecutionPayload).blobGasUsed = quantityToBigint(blobGasUsed); + (executionPayload as deneb.ExecutionPayload).excessBlobGas = quantityToBigint(excessBlobGas); } return {executionPayload, blockValue, blobsBundle}; diff --git a/packages/light-client/src/spec/utils.ts b/packages/light-client/src/spec/utils.ts index 8f74b94568d..0ff1775f55c 100644 --- a/packages/light-client/src/spec/utils.ts +++ b/packages/light-client/src/spec/utils.ts @@ -98,10 +98,10 @@ export function upgradeLightClientHeader( // eslint-disable-next-line no-fallthrough case ForkName.deneb: - (upgradedHeader as deneb.LightClientHeader).execution.dataGasUsed = - ssz.deneb.LightClientHeader.fields.execution.fields.dataGasUsed.defaultValue(); - (upgradedHeader as deneb.LightClientHeader).execution.excessDataGas = - ssz.deneb.LightClientHeader.fields.execution.fields.excessDataGas.defaultValue(); + (upgradedHeader as deneb.LightClientHeader).execution.blobGasUsed = + ssz.deneb.LightClientHeader.fields.execution.fields.blobGasUsed.defaultValue(); + (upgradedHeader as deneb.LightClientHeader).execution.excessBlobGas = + ssz.deneb.LightClientHeader.fields.execution.fields.excessBlobGas.defaultValue(); // Break if no further upgradation is required else fall through if (ForkSeq[targetFork] <= ForkSeq.deneb) break; @@ -129,10 +129,10 @@ export function isValidLightClientHeader(config: ChainForkConfig, header: allFor if (epoch < config.DENEB_FORK_EPOCH) { if ( - ((header as deneb.LightClientHeader).execution.dataGasUsed && - (header as deneb.LightClientHeader).execution.dataGasUsed !== BigInt(0)) || - ((header as deneb.LightClientHeader).execution.excessDataGas && - (header as deneb.LightClientHeader).execution.excessDataGas !== BigInt(0)) + ((header as deneb.LightClientHeader).execution.blobGasUsed && + (header as deneb.LightClientHeader).execution.blobGasUsed !== BigInt(0)) || + ((header as deneb.LightClientHeader).execution.excessBlobGas && + (header as deneb.LightClientHeader).execution.excessBlobGas !== BigInt(0)) ) { return false; } diff --git a/packages/light-client/test/unit/isValidLightClientHeader.test.ts b/packages/light-client/test/unit/isValidLightClientHeader.test.ts index 72836fb3169..a28ac65ff61 100644 --- a/packages/light-client/test/unit/isValidLightClientHeader.test.ts +++ b/packages/light-client/test/unit/isValidLightClientHeader.test.ts @@ -76,7 +76,7 @@ describe("isValidLightClientHeader", function () { const capellaUpgradedDenebHeader = { beacon: capellaLCHeader.beacon, - execution: {...capellaLCHeader.execution, dataGasUsed: 0, excessDataGas: 0}, + execution: {...capellaLCHeader.execution, blobGasUsed: 0, excessBlobGas: 0}, executionBranch: capellaLCHeader.executionBranch, }; diff --git a/packages/state-transition/src/block/processExecutionPayload.ts b/packages/state-transition/src/block/processExecutionPayload.ts index 56b304cbfc9..4965c21397b 100644 --- a/packages/state-transition/src/block/processExecutionPayload.ts +++ b/packages/state-transition/src/block/processExecutionPayload.ts @@ -109,12 +109,12 @@ export function executionPayloadToPayloadHeader( if (fork >= ForkSeq.deneb) { // https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/beacon-chain.md#process_execution_payload - (bellatrixPayloadFields as deneb.ExecutionPayloadHeader).dataGasUsed = ( + (bellatrixPayloadFields as deneb.ExecutionPayloadHeader).blobGasUsed = ( payload as deneb.ExecutionPayloadHeader | deneb.ExecutionPayload - ).dataGasUsed; - (bellatrixPayloadFields as deneb.ExecutionPayloadHeader).excessDataGas = ( + ).blobGasUsed; + (bellatrixPayloadFields as deneb.ExecutionPayloadHeader).excessBlobGas = ( payload as deneb.ExecutionPayloadHeader | deneb.ExecutionPayload - ).excessDataGas; + ).excessBlobGas; } return bellatrixPayloadFields; diff --git a/packages/state-transition/src/slot/upgradeStateToDeneb.ts b/packages/state-transition/src/slot/upgradeStateToDeneb.ts index c6c0c867060..53be75f72ad 100644 --- a/packages/state-transition/src/slot/upgradeStateToDeneb.ts +++ b/packages/state-transition/src/slot/upgradeStateToDeneb.ts @@ -20,7 +20,7 @@ export function upgradeStateToDeneb(stateCapella: CachedBeaconStateCapella): Cac epoch: stateCapella.epochCtx.epoch, }); - // Since excessDataGas and dataGasUsed are appened in the end to latestExecutionPayloadHeader so they should + // Since excessBlobGas and blobGasUsed are appened in the end to latestExecutionPayloadHeader so they should // be set to defaults and need no assigning, but right now any access to latestExecutionPayloadHeader fails // with LeafNode has no left node. Weirdly its beacuse of addition of the second field as with one field // it seems to work. @@ -28,8 +28,8 @@ export function upgradeStateToDeneb(stateCapella: CachedBeaconStateCapella): Cac // TODO DENEB: Debug and remove the following cloning stateDeneb.latestExecutionPayloadHeader = ssz.deneb.BeaconState.fields.latestExecutionPayloadHeader.toViewDU({ ...stateCapella.latestExecutionPayloadHeader.toValue(), - excessDataGas: BigInt(0), - dataGasUsed: BigInt(0), + excessBlobGas: BigInt(0), + blobGasUsed: BigInt(0), }); stateDeneb.commit(); diff --git a/packages/types/src/deneb/sszTypes.ts b/packages/types/src/deneb/sszTypes.ts index eb04bb1e7a3..2ba06346708 100644 --- a/packages/types/src/deneb/sszTypes.ts +++ b/packages/types/src/deneb/sszTypes.ts @@ -125,8 +125,8 @@ export const BeaconBlockAndBlobsSidecarByRootRequest = new ListCompositeType(Roo export const ExecutionPayload = new ContainerType( { ...capellaSsz.ExecutionPayload.fields, - dataGasUsed: UintBn64, // New in DENEB - excessDataGas: UintBn64, // New in DENEB + blobGasUsed: UintBn64, // New in DENEB + excessBlobGas: UintBn64, // New in DENEB }, {typeName: "ExecutionPayload", jsonCase: "eth2"} ); @@ -134,8 +134,8 @@ export const ExecutionPayload = new ContainerType( export const ExecutionPayloadHeader = new ContainerType( { ...capellaSsz.ExecutionPayloadHeader.fields, - dataGasUsed: UintBn64, // New in DENEB - excessDataGas: UintBn64, // New in DENEB + blobGasUsed: UintBn64, // New in DENEB + excessBlobGas: UintBn64, // New in DENEB }, {typeName: "ExecutionPayloadHeader", jsonCase: "eth2"} ); From 27fbe4c7fac5376341a3f657fc605da85e1cfdb8 Mon Sep 17 00:00:00 2001 From: gajinder Date: Tue, 1 Aug 2023 14:07:17 +0530 Subject: [PATCH 2/2] update spec test version --- packages/beacon-node/test/spec/specTestVersioning.ts | 2 +- packages/params/test/e2e/ensure-config-is-synced.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/beacon-node/test/spec/specTestVersioning.ts b/packages/beacon-node/test/spec/specTestVersioning.ts index 37f08e3f9e5..ff24be32ee3 100644 --- a/packages/beacon-node/test/spec/specTestVersioning.ts +++ b/packages/beacon-node/test/spec/specTestVersioning.ts @@ -15,7 +15,7 @@ import {DownloadTestsOptions} from "@lodestar/spec-test-util"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); export const ethereumConsensusSpecsTests: DownloadTestsOptions = { - specVersion: "v1.4.0-beta.0", + specVersion: "v1.4.0-beta.1", // Target directory is the host package root: 'packages/*/spec-tests' outputDir: path.join(__dirname, "../../spec-tests"), specTestsRepoUrl: "https://github.com/ethereum/consensus-spec-tests", diff --git a/packages/params/test/e2e/ensure-config-is-synced.test.ts b/packages/params/test/e2e/ensure-config-is-synced.test.ts index 6adea922f37..774e06fad8b 100644 --- a/packages/params/test/e2e/ensure-config-is-synced.test.ts +++ b/packages/params/test/e2e/ensure-config-is-synced.test.ts @@ -8,7 +8,7 @@ import {loadConfigYaml} from "../yaml.js"; // Not e2e, but slow. Run with e2e tests /** https://github.com/ethereum/consensus-specs/releases */ -const specConfigCommit = "v1.4.0-beta.0"; +const specConfigCommit = "v1.4.0-beta.1"; describe("Ensure config is synced", function () { this.timeout(60 * 1000);