Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename data gas to blob gas for relevant deneb fields #5816

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions packages/beacon-node/src/execution/engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/test/spec/specTestVersioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why do we have this magic string in this file and in packages/params/test/e2e/ensure-config-is-synced.test.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this corresponds to protocol spec test releases (which go hand in hand with spec releases) : https://github.com/ethereum/consensus-spec-tests/releases

// Target directory is the host package root: 'packages/*/spec-tests'
outputDir: path.join(__dirname, "../../spec-tests"),
specTestsRepoUrl: "https://github.com/ethereum/consensus-spec-tests",
Expand Down
16 changes: 8 additions & 8 deletions packages/light-client/src/spec/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/params/test/e2e/ensure-config-is-synced.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/state-transition/src/slot/upgradeStateToDeneb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ 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.
//
// 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();
Expand Down
8 changes: 4 additions & 4 deletions packages/types/src/deneb/sszTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ 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"}
);

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"}
);
Expand Down
Loading