From 296efec2561a44580a7c321bf22c51aff2e52714 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Tue, 30 May 2023 00:39:13 +0800 Subject: [PATCH] Add `data_gas_used` field to `ExecutionPayload` --- specs/_features/eip6110/beacon-chain.md | 3 +++ specs/_features/eip6110/fork.md | 1 + specs/deneb/beacon-chain.md | 3 +++ specs/deneb/fork.md | 1 + specs/deneb/light-client/fork.md | 1 + specs/deneb/light-client/full-node.md | 1 + specs/deneb/light-client/sync-protocol.md | 2 +- tests/core/pyspec/eth2spec/test/helpers/execution_payload.py | 3 +++ 8 files changed, 14 insertions(+), 1 deletion(-) diff --git a/specs/_features/eip6110/beacon-chain.md b/specs/_features/eip6110/beacon-chain.md index e1384fdae..95dc7fd3c 100644 --- a/specs/_features/eip6110/beacon-chain.md +++ b/specs/_features/eip6110/beacon-chain.md @@ -92,6 +92,7 @@ class ExecutionPayload(Container): transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD] withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD] excess_data_gas: uint256 + data_gas_used: uint256 deposit_receipts: List[DepositReceipt, MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD] # [New in EIP6110] ``` @@ -117,6 +118,7 @@ class ExecutionPayloadHeader(Container): transactions_root: Root withdrawals_root: Root excess_data_gas: uint256 + data_gas_used: uint256 deposit_receipts_root: Root # [New in EIP6110] ``` @@ -269,6 +271,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi transactions_root=hash_tree_root(payload.transactions), withdrawals_root=hash_tree_root(payload.withdrawals), excess_data_gas=payload.excess_data_gas, + data_gas_used=payload.data_gas_used, deposit_receipts_root=hash_tree_root(payload.deposit_receipts), # [New in EIP6110] ) ``` diff --git a/specs/_features/eip6110/fork.md b/specs/_features/eip6110/fork.md index 2145a9d1a..8a603b530 100644 --- a/specs/_features/eip6110/fork.md +++ b/specs/_features/eip6110/fork.md @@ -89,6 +89,7 @@ def upgrade_to_eip6110(pre: deneb.BeaconState) -> BeaconState: transactions_root=pre.latest_execution_payload_header.transactions_root, withdrawals_root=pre.latest_execution_payload_header.withdrawals_root, excess_data_gas=uint256(0), + data_gas_used=uint256(0), deposit_receipts_root=Root(), # [New in EIP-6110] ) post = BeaconState( diff --git a/specs/deneb/beacon-chain.md b/specs/deneb/beacon-chain.md index 175a80edf..26206384a 100644 --- a/specs/deneb/beacon-chain.md +++ b/specs/deneb/beacon-chain.md @@ -127,6 +127,7 @@ class ExecutionPayload(Container): transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD] withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD] excess_data_gas: uint256 # [New in Deneb] + data_gas_used: uint256 # [New in Deneb] ``` #### `ExecutionPayloadHeader` @@ -151,6 +152,7 @@ class ExecutionPayloadHeader(Container): transactions_root: Root withdrawals_root: Root excess_data_gas: uint256 # [New in Deneb] + data_gas_used: uint256 # [New in Deneb] ``` ## Helper functions @@ -258,6 +260,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi transactions_root=hash_tree_root(payload.transactions), withdrawals_root=hash_tree_root(payload.withdrawals), excess_data_gas=payload.excess_data_gas, # [New in Deneb] + data_gas_used=payload.data_gas_used, # [New in Deneb] ) ``` diff --git a/specs/deneb/fork.md b/specs/deneb/fork.md index 23b3f23c7..8c7fd5319 100644 --- a/specs/deneb/fork.md +++ b/specs/deneb/fork.md @@ -84,6 +84,7 @@ def upgrade_to_deneb(pre: capella.BeaconState) -> BeaconState: transactions_root=pre.latest_execution_payload_header.transactions_root, withdrawals_root=pre.latest_execution_payload_header.withdrawals_root, excess_data_gas=uint256(0), # [New in Deneb] + data_gas_used=uint256(0), # [New in Deneb] ) post = BeaconState( # Versioning diff --git a/specs/deneb/light-client/fork.md b/specs/deneb/light-client/fork.md index 46a093028..2ae59cc7e 100644 --- a/specs/deneb/light-client/fork.md +++ b/specs/deneb/light-client/fork.md @@ -42,6 +42,7 @@ def upgrade_lc_header_to_deneb(pre: capella.LightClientHeader) -> LightClientHea transactions_root=pre.execution.transactions_root, withdrawals_root=pre.execution.withdrawals_root, excess_data_gas=uint256(0), # [New in Deneb] + data_gas_used=uint256(0), # [New in Deneb] ), execution_branch=pre.execution_branch, ) diff --git a/specs/deneb/light-client/full-node.md b/specs/deneb/light-client/full-node.md index 275194036..0ef0ee96f 100644 --- a/specs/deneb/light-client/full-node.md +++ b/specs/deneb/light-client/full-node.md @@ -50,6 +50,7 @@ def block_to_light_client_header(block: SignedBeaconBlock) -> LightClientHeader: # [New in Deneb] if epoch >= DENEB_FORK_EPOCH: execution_header.excess_data_gas = payload.excess_data_gas + execution_header.data_gas_used = payload.data_gas_used execution_branch = compute_merkle_proof_for_block_body(block.message.body, EXECUTION_PAYLOAD_INDEX) else: diff --git a/specs/deneb/light-client/sync-protocol.md b/specs/deneb/light-client/sync-protocol.md index c691a113d..194be0ae4 100644 --- a/specs/deneb/light-client/sync-protocol.md +++ b/specs/deneb/light-client/sync-protocol.md @@ -68,7 +68,7 @@ def is_valid_light_client_header(header: LightClientHeader) -> bool: # [New in Deneb] if epoch < DENEB_FORK_EPOCH: - if header.execution.excess_data_gas != uint256(0): + if header.execution.excess_data_gas != uint256(0) or header.execution.data_gas_used != uint256(0): return False if epoch < CAPELLA_FORK_EPOCH: diff --git a/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py b/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py index 747d678ef..1fa3f4c4b 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py @@ -32,6 +32,7 @@ def get_execution_payload_header(spec, execution_payload): payload_header.withdrawals_root = spec.hash_tree_root(execution_payload.withdrawals) if is_post_deneb(spec): payload_header.excess_data_gas = execution_payload.excess_data_gas + payload_header.data_gas_used = execution_payload.data_gas_used if is_post_eip6110(spec): payload_header.deposit_receipts_root = spec.hash_tree_root(execution_payload.deposit_receipts) return payload_header @@ -99,6 +100,7 @@ def compute_el_header_block_hash(spec, if is_post_deneb(spec): # excess_data_gas execution_payload_header_rlp.append((big_endian_int, payload_header.excess_data_gas)) + execution_payload_header_rlp.append((big_endian_int, payload_header.data_gas_used)) if is_post_eip6110(spec): # deposit_receipts_root assert deposit_receipts_trie_root is not None @@ -202,6 +204,7 @@ def build_empty_execution_payload(spec, state, randao_mix=None): payload.withdrawals = spec.get_expected_withdrawals(state) if is_post_deneb(spec): payload.excess_data_gas = 0 + payload.data_gas_used = 0 if is_post_eip6110(spec): # just to be clear payload.deposit_receipts = []