From 3cebedbc5cc37b057664969e8c7945c643af9250 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 26 Jan 2023 09:14:08 +0100 Subject: [PATCH 01/14] Spec draft for the verge Co-Authored-By: Dankrad Feist --- specs/verge/beacon-chain.md | 208 ++++++++++++++++++++++++++++++++++++ specs/verge/fork.md | 143 +++++++++++++++++++++++++ 2 files changed, 351 insertions(+) create mode 100644 specs/verge/beacon-chain.md create mode 100644 specs/verge/fork.md diff --git a/specs/verge/beacon-chain.md b/specs/verge/beacon-chain.md new file mode 100644 index 000000000..2f380a38e --- /dev/null +++ b/specs/verge/beacon-chain.md @@ -0,0 +1,208 @@ +# The Verge -- The Beacon Chain + +## Table of contents + + + + + +- [Introduction](#introduction) +- [Custom types](#custom-types) +- [Preset](#preset) + - [Execution](#execution) +- [Containers](#containers) + - [Extended containers](#extended-containers) + - [`ExecutionPayload`](#executionpayload) + - [`ExecutionPayloadHeader`](#executionpayloadheader) + - [New containers](#new-containers) + - [`SuffixStateDiff`](#suffixstatediff) + - [`StemStateDiff`](#stemstatediff) + - [`IPAProof`](#ipaproof) + - [`VerkleProof`](#verkleproof) + - [`ExecutionWitness`](#executionwitness) +- [Beacon chain state transition function](#beacon-chain-state-transition-function) + - [Execution engine](#execution-engine) + - [`notify_new_payload`](#notify_new_payload) + - [Block processing](#block-processing) + - [Execution payload](#execution-payload) + - [`process_execution_payload`](#process_execution_payload) +- [Testing](#testing) + + + + +## Introduction + +This upgrade adds transaction execution to the beacon chain as part of the Verge upgrade. + +## Custom types + +| Name | SSZ equivalent | Description | +| - | - | - | +| `StateDiff` | `List[StemStateDiff, MAX_STEMS]` | Only valid if list is sorted by stems | +| `BandersnatchGroupElement` | `Bytes32` | | +| `BandersnatchFieldElement` | `Bytes32` | | +| `Stem` | `Bytes31` | | + +## Preset + +### Execution + +| Name | Value | +| - | - | +| `MAX_STEMS` | `2**16` | +| `MAX_COMMITMENTS_PER_STEM` | `33` | +| `VERKLE_WIDTH` | `256` | +| `IPA_PROOF_DEPTH` | `8` | + +## Containers + +### Extended containers + +#### `ExecutionPayload` + +```python +class ExecutionPayload(Container): + # Execution block header fields + parent_hash: Hash32 + fee_recipient: ExecutionAddress # 'beneficiary' in the yellow paper + state_root: Bytes32 + receipts_root: Bytes32 + logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM] + prev_randao: Bytes32 # 'difficulty' in the yellow paper + block_number: uint64 # 'number' in the yellow paper + gas_limit: uint64 + gas_used: uint64 + timestamp: uint64 + extra_data: ByteList[MAX_EXTRA_DATA_BYTES] + base_fee_per_gas: uint256 + block_hash: Hash32 # Hash of execution block + # Extra payload field + execution_witness: ExecutionWitness + transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD] +``` + +#### `ExecutionPayloadHeader` + +```python +class ExecutionPayloadHeader(Container): + # Execution block header fields + parent_hash: Hash32 + fee_recipient: ExecutionAddress + state_root: Bytes32 + receipts_root: Bytes32 + logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM] + prev_randao: Bytes32 + block_number: uint64 + gas_limit: uint64 + gas_used: uint64 + timestamp: uint64 + extra_data: ByteList[MAX_EXTRA_DATA_BYTES] + base_fee_per_gas: uint256 + block_hash: Hash32 # Hash of execution block + transactions_root: Root + # Extra payload fields + execution_witness: ExecutionWitness +``` + +### New containers + +#### `SuffixStateDiff` + +```python +class SuffixStateDiff(Container): + suffix: Byte + + # Null means not currently present + current_value: Union[Null, Bytes32] + + # Null means value not updated + new_value: Union[Null, Bytes32] +``` + +*Note*: on the Kaustinen testnet, `new_value` is ommitted from the container. + +#### `StemStateDiff` + +```python +class StemStateDiff(Container): + stem: Stem + # Valid only if list is sorted by suffixes + suffix_diffs: List[SuffixStateDiff, VERKLE_WIDTH] +``` + +```python +# Valid only if list is sorted by stems +StateDiff = List[StemStateDiff, MAX_STEMS] +``` + +#### `IPAProof` + +```python +class IpaProof(Container): + C_L = Vector[BandersnatchGroupElement, IPA_PROOF_DEPTH] + C_R = Vector[BandersnatchGroupElement, IPA_PROOF_DEPTH] + final_evaluation = BandersnatchFieldElement +``` + +#### `VerkleProof` + +```python +class VerkleProof(Container): + other_stems: List[Bytes32, MAX_STEMS] + depth_extension_present: List[uint8, MAX_STEMS] + commitments_by_path: List[BandersnatchGroupElement, MAX_STEMS * MAX_COMMITMENTS_PER_STEM] + D: BandersnatchGroupElement + ipa_proof: IpaProof +``` + +#### `ExecutionWitness` + +```python +class ExecutionWitness(container): + state_diff: StateDiff + verkle_proof: VerkleProof +``` + +## Beacon chain state transition function + +### Block processing + +#### Execution payload + +##### `process_execution_payload` + +```python +def process_execution_payload(state: BeaconState, payload: ExecutionPayload, execution_engine: ExecutionEngine) -> None: + # Verify consistency of the parent hash with respect to the previous execution payload header + if is_merge_transition_complete(state): + assert payload.parent_hash == state.latest_execution_payload_header.block_hash + # Verify prev_randao + assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state)) + # Verify timestamp + assert payload.timestamp == compute_timestamp_at_slot(state, state.slot) + # Verify the execution payload is valid + assert execution_engine.notify_new_payload(payload) + # Cache execution payload header + state.latest_execution_payload_header = ExecutionPayloadHeader( + parent_hash=payload.parent_hash, + fee_recipient=payload.fee_recipient, + state_root=payload.state_root, + receipts_root=payload.receipts_root, + logs_bloom=payload.logs_bloom, + prev_randao=payload.prev_randao, + block_number=payload.block_number, + gas_limit=payload.gas_limit, + gas_used=payload.gas_used, + timestamp=payload.timestamp, + extra_data=payload.extra_data, + base_fee_per_gas=payload.base_fee_per_gas, + block_hash=payload.block_hash, + transactions_root=hash_tree_root(payload.transactions), + execution_witness=payload.execution_witness, + ) +``` + +## Testing + +TBD \ No newline at end of file diff --git a/specs/verge/fork.md b/specs/verge/fork.md new file mode 100644 index 000000000..627c1183c --- /dev/null +++ b/specs/verge/fork.md @@ -0,0 +1,143 @@ +# The Verge -- Fork Logic + +## Table of contents + + + + +- [Introduction](#introduction) +- [Configuration](#configuration) +- [Helper functions](#helper-functions) + - [Misc](#misc) + - [Modified `compute_fork_version`](#modified-compute_fork_version) +- [Fork to the Verge](#fork-to-capella) + - [Fork trigger](#fork-trigger) + - [Upgrading the state](#upgrading-the-state) + + + +## Introduction + +This document describes the process of the Verge upgrade. + +## Configuration + +Warning: this configuration is not definitive. + +| Name | Value | +| - | - | +| `VERGE_FORK_VERSION` | `Version('0x05000000')` | +| `VERGE_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** | + + +## Helper functions + +### Misc + +#### Modified `compute_fork_version` + +```python +def compute_fork_version(epoch: Epoch) -> Version: + """ + Return the fork version at the given ``epoch``. + """ + if epoch >= VERGE_FORK_EPOCH: + return VERGE_FORK_VERSION + if epoch >= CAPELLA_FORK_EPOCH: + return CAPELLA_FORK_VERSION + if epoch >= BELLATRIX_FORK_EPOCH: + return BELLATRIX_FORK_VERSION + if epoch >= ALTAIR_FORK_EPOCH: + return ALTAIR_FORK_VERSION + return GENESIS_FORK_VERSION +``` + +## Fork to the Verge + +### Fork trigger + +The fork is triggered at epoch `VERGE_FORK_EPOCH`. + +Note that for the pure verge networks, we don't apply `upgrade_to_verge` since it starts with the Verge version logic. + +### Upgrading the state + +If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == VERGE_FORK_EPOCH`, +an irregular state change is made to upgrade to the Verge. + +The upgrade occurs after the completion of the inner loop of `process_slots` that sets `state.slot` equal to `VERGE_FORK_EPOCH * SLOTS_PER_EPOCH`. +Care must be taken when transitioning through the fork boundary as implementations will need a modified [state transition function](../phase0/beacon-chain.md#beacon-chain-state-transition-function) that deviates from the Phase 0 document. +In particular, the outer `state_transition` function defined in the Phase 0 document will not expose the precise fork slot to execute the upgrade in the presence of skipped slots at the fork boundary. Instead, the logic must be within `process_slots`. + +```python +def upgrade_to_verge(pre: capella.BeaconState) -> BeaconState: + epoch = capella.get_current_epoch(pre) + latest_execution_payload_header = ExecutionPayloadHeader( + parent_hash=pre.latest_execution_payload_header.parent_hash, + fee_recipient=pre.latest_execution_payload_header.fee_recipient, + state_root=pre.latest_execution_payload_header.state_root, + receipts_root=pre.latest_execution_payload_header.receipts_root, + logs_bloom=pre.latest_execution_payload_header.logs_bloom, + prev_randao=pre.latest_execution_payload_header.prev_randao, + block_number=pre.latest_execution_payload_header.block_number, + gas_limit=pre.latest_execution_payload_header.gas_limit, + gas_used=pre.latest_execution_payload_header.gas_used, + timestamp=pre.latest_execution_payload_header.timestamp, + extra_data=pre.latest_execution_payload_header.extra_data, + base_fee_per_gas=pre.latest_execution_payload_header.base_fee_per_gas, + block_hash=pre.latest_execution_payload_header.block_hash, + transactions_root=pre.latest_execution_payload_header.transactions_root, + withdrawals_root=pre.latest_execution_payload_header.withdrawals_root, + execution_witness=ExecutionWitness([], []) # New in the Verge + ) + post = BeaconState( + # Versioning + genesis_time=pre.genesis_time, + genesis_validators_root=pre.genesis_validators_root, + slot=pre.slot, + fork=Fork( + previous_version=pre.fork.current_version, + current_version=VERGE_FORK_VERSION, + epoch=epoch, + ), + # History + latest_block_header=pre.latest_block_header, + block_roots=pre.block_roots, + state_roots=pre.state_roots, + historical_roots=pre.historical_roots, + # Eth1 + eth1_data=pre.eth1_data, + eth1_data_votes=pre.eth1_data_votes, + eth1_deposit_index=pre.eth1_deposit_index, + # Registry + validators=pre.validators, + balances=pre.balances, + # Randomness + randao_mixes=pre.randao_mixes, + # Slashings + slashings=pre.slashings, + # Participation + previous_epoch_participation=pre.previous_epoch_participation, + current_epoch_participation=pre.current_epoch_participation, + # Finality + justification_bits=pre.justification_bits, + previous_justified_checkpoint=pre.previous_justified_checkpoint, + current_justified_checkpoint=pre.current_justified_checkpoint, + finalized_checkpoint=pre.finalized_checkpoint, + # Inactivity + inactivity_scores=pre.inactivity_scores, + # Sync + current_sync_committee=pre.current_sync_committee, + next_sync_committee=pre.next_sync_committee, + # Execution-layer + latest_execution_payload_header=latest_execution_payload_header, + # Withdrawals + next_withdrawal_index=pre.next_withdrawal_index, + next_withdrawal_validator_index=pre.next_withdrawal_validator_index, + # Deep history valid from Capella onwards + # FIXME most likely wrong + historical_summaries=List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT]([]), # [New in Capella] + ) + + return post +``` From 832a799907cf8f3903531a9ce208afceba48219b Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:23:20 +0100 Subject: [PATCH 02/14] Update specs/verge/beacon-chain.md Co-authored-by: terencechain --- specs/verge/beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/verge/beacon-chain.md b/specs/verge/beacon-chain.md index 2f380a38e..e0f211158 100644 --- a/specs/verge/beacon-chain.md +++ b/specs/verge/beacon-chain.md @@ -78,8 +78,8 @@ class ExecutionPayload(Container): base_fee_per_gas: uint256 block_hash: Hash32 # Hash of execution block # Extra payload field - execution_witness: ExecutionWitness transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD] + execution_witness: ExecutionWitness ``` #### `ExecutionPayloadHeader` From 8fc37ca64c0d235c9c9678ba274ee6d02aef3fe3 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Fri, 27 Jan 2023 11:47:26 +0100 Subject: [PATCH 03/14] fix some typos --- specs/verge/beacon-chain.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/specs/verge/beacon-chain.md b/specs/verge/beacon-chain.md index e0f211158..e23b45822 100644 --- a/specs/verge/beacon-chain.md +++ b/specs/verge/beacon-chain.md @@ -40,8 +40,8 @@ This upgrade adds transaction execution to the beacon chain as part of the Verge | Name | SSZ equivalent | Description | | - | - | - | | `StateDiff` | `List[StemStateDiff, MAX_STEMS]` | Only valid if list is sorted by stems | -| `BandersnatchGroupElement` | `Bytes32` | | -| `BandersnatchFieldElement` | `Bytes32` | | +| `BanderwagonGroupElement` | `Bytes32` | | +| `BanderwagonFieldElement` | `Bytes32` | | | `Stem` | `Bytes31` | | ## Preset @@ -140,19 +140,19 @@ StateDiff = List[StemStateDiff, MAX_STEMS] ```python class IpaProof(Container): - C_L = Vector[BandersnatchGroupElement, IPA_PROOF_DEPTH] - C_R = Vector[BandersnatchGroupElement, IPA_PROOF_DEPTH] - final_evaluation = BandersnatchFieldElement + C_L = Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] + C_R = Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] + final_evaluation = BanderwagonFieldElement ``` #### `VerkleProof` ```python class VerkleProof(Container): - other_stems: List[Bytes32, MAX_STEMS] + other_stems: List[Bytes31, MAX_STEMS] depth_extension_present: List[uint8, MAX_STEMS] - commitments_by_path: List[BandersnatchGroupElement, MAX_STEMS * MAX_COMMITMENTS_PER_STEM] - D: BandersnatchGroupElement + commitments_by_path: List[BanderwagonGroupElement, MAX_STEMS * MAX_COMMITMENTS_PER_STEM] + D: BanderwagonGroupElement ipa_proof: IpaProof ``` From 698650cd19e6f8852df02bea890108c0c9a73d4f Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 9 Feb 2023 14:19:46 +0100 Subject: [PATCH 04/14] add a comment to pinpoint the new, verge-related fields Co-authored-by: Mikhail Kalinin --- specs/verge/beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/verge/beacon-chain.md b/specs/verge/beacon-chain.md index e23b45822..072a7461b 100644 --- a/specs/verge/beacon-chain.md +++ b/specs/verge/beacon-chain.md @@ -79,7 +79,7 @@ class ExecutionPayload(Container): block_hash: Hash32 # Hash of execution block # Extra payload field transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD] - execution_witness: ExecutionWitness + execution_witness: ExecutionWitness # [New in Verge] ``` #### `ExecutionPayloadHeader` From 3b362c61157cc109c75508b37dfe3e1fe86e5253 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Fri, 10 Feb 2023 14:51:14 +0100 Subject: [PATCH 05/14] Use Optional[Bytes32] instead of Union[Null, Bytes32] for value diffs Co-authored-by: Mikhail Kalinin --- specs/verge/beacon-chain.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/verge/beacon-chain.md b/specs/verge/beacon-chain.md index 072a7461b..ebe6745a7 100644 --- a/specs/verge/beacon-chain.md +++ b/specs/verge/beacon-chain.md @@ -114,10 +114,10 @@ class SuffixStateDiff(Container): suffix: Byte # Null means not currently present - current_value: Union[Null, Bytes32] + current_value: Optional[Bytes32] # Null means value not updated - new_value: Union[Null, Bytes32] + new_value: Optional[Bytes32] ``` *Note*: on the Kaustinen testnet, `new_value` is ommitted from the container. From d0c7bbc8020ac196fb8b542d25b47a2d60fde6e0 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Sun, 19 Feb 2023 20:16:48 +0100 Subject: [PATCH 06/14] rebase and move to _features --- specs/{ => _features}/verge/beacon-chain.md | 0 specs/{ => _features}/verge/fork.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename specs/{ => _features}/verge/beacon-chain.md (100%) rename specs/{ => _features}/verge/fork.md (100%) diff --git a/specs/verge/beacon-chain.md b/specs/_features/verge/beacon-chain.md similarity index 100% rename from specs/verge/beacon-chain.md rename to specs/_features/verge/beacon-chain.md diff --git a/specs/verge/fork.md b/specs/_features/verge/fork.md similarity index 100% rename from specs/verge/fork.md rename to specs/_features/verge/fork.md From 567e62fbe94be1dae0bc4c4a29824a6b0a8e93f9 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 9 Mar 2023 11:48:00 +0100 Subject: [PATCH 07/14] Style feedback Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com> --- specs/_features/verge/beacon-chain.md | 2 -- specs/_features/verge/fork.md | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/specs/_features/verge/beacon-chain.md b/specs/_features/verge/beacon-chain.md index ebe6745a7..5a25b6e66 100644 --- a/specs/_features/verge/beacon-chain.md +++ b/specs/_features/verge/beacon-chain.md @@ -112,10 +112,8 @@ class ExecutionPayloadHeader(Container): ```python class SuffixStateDiff(Container): suffix: Byte - # Null means not currently present current_value: Optional[Bytes32] - # Null means value not updated new_value: Optional[Bytes32] ``` diff --git a/specs/_features/verge/fork.md b/specs/_features/verge/fork.md index 627c1183c..17fbac370 100644 --- a/specs/_features/verge/fork.md +++ b/specs/_features/verge/fork.md @@ -136,7 +136,7 @@ def upgrade_to_verge(pre: capella.BeaconState) -> BeaconState: next_withdrawal_validator_index=pre.next_withdrawal_validator_index, # Deep history valid from Capella onwards # FIXME most likely wrong - historical_summaries=List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT]([]), # [New in Capella] + historical_summaries=List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT]([]), ) return post From a5c955fb6371fd4d18d12c3eee66701fa5ab91ca Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:33:15 +0100 Subject: [PATCH 08/14] feedback from ACDC --- specs/_features/verge/beacon-chain.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/specs/_features/verge/beacon-chain.md b/specs/_features/verge/beacon-chain.md index 5a25b6e66..5b808c881 100644 --- a/specs/_features/verge/beacon-chain.md +++ b/specs/_features/verge/beacon-chain.md @@ -102,7 +102,7 @@ class ExecutionPayloadHeader(Container): block_hash: Hash32 # Hash of execution block transactions_root: Root # Extra payload fields - execution_witness: ExecutionWitness + execution_witness_root: Root # [New in Verge] ``` ### New containers @@ -138,8 +138,8 @@ StateDiff = List[StemStateDiff, MAX_STEMS] ```python class IpaProof(Container): - C_L = Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] - C_R = Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] + c_l: Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] + c_r: Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] final_evaluation = BanderwagonFieldElement ``` @@ -150,7 +150,7 @@ class VerkleProof(Container): other_stems: List[Bytes31, MAX_STEMS] depth_extension_present: List[uint8, MAX_STEMS] commitments_by_path: List[BanderwagonGroupElement, MAX_STEMS * MAX_COMMITMENTS_PER_STEM] - D: BanderwagonGroupElement + d: BanderwagonGroupElement ipa_proof: IpaProof ``` From 509fbb2c5ca74d93e9d0c3b3532be4c7214e1cd5 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Fri, 10 Mar 2023 09:34:44 +0100 Subject: [PATCH 09/14] style: remove confusing underscore --- specs/_features/verge/beacon-chain.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/_features/verge/beacon-chain.md b/specs/_features/verge/beacon-chain.md index 5b808c881..31bd21e79 100644 --- a/specs/_features/verge/beacon-chain.md +++ b/specs/_features/verge/beacon-chain.md @@ -138,8 +138,8 @@ StateDiff = List[StemStateDiff, MAX_STEMS] ```python class IpaProof(Container): - c_l: Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] - c_r: Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] + cl: Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] + cr: Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] final_evaluation = BanderwagonFieldElement ``` From 5c13f5c6517c1ba2d919f418453899b6be6f5729 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 27 May 2024 11:53:38 +0200 Subject: [PATCH 10/14] fix depth+extension serialization type Co-authored-by: g11tech --- specs/_features/verge/beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/_features/verge/beacon-chain.md b/specs/_features/verge/beacon-chain.md index 31bd21e79..e01b63662 100644 --- a/specs/_features/verge/beacon-chain.md +++ b/specs/_features/verge/beacon-chain.md @@ -148,7 +148,7 @@ class IpaProof(Container): ```python class VerkleProof(Container): other_stems: List[Bytes31, MAX_STEMS] - depth_extension_present: List[uint8, MAX_STEMS] + depth_extension_present: ByteList[MAX_STEMS] commitments_by_path: List[BanderwagonGroupElement, MAX_STEMS * MAX_COMMITMENTS_PER_STEM] d: BanderwagonGroupElement ipa_proof: IpaProof From 7fbbb252d802f3a858ba1276c3ef6271b42dee2e Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 27 May 2024 12:46:30 +0200 Subject: [PATCH 11/14] rebase on top of deneb --- .../{verge => eip6800}/beacon-chain.md | 22 +++++++---- specs/_features/{verge => eip6800}/fork.md | 38 ++++++++++--------- 2 files changed, 34 insertions(+), 26 deletions(-) rename specs/_features/{verge => eip6800}/beacon-chain.md (91%) rename specs/_features/{verge => eip6800}/fork.md (81%) diff --git a/specs/_features/verge/beacon-chain.md b/specs/_features/eip6800/beacon-chain.md similarity index 91% rename from specs/_features/verge/beacon-chain.md rename to specs/_features/eip6800/beacon-chain.md index e01b63662..8b33d7173 100644 --- a/specs/_features/verge/beacon-chain.md +++ b/specs/_features/eip6800/beacon-chain.md @@ -1,4 +1,4 @@ -# The Verge -- The Beacon Chain +# eip6800 -- The Beacon Chain ## Table of contents @@ -33,7 +33,7 @@ ## Introduction -This upgrade adds transaction execution to the beacon chain as part of the Verge upgrade. +This upgrade adds transaction execution to the beacon chain as part of the eip6800 upgrade. ## Custom types @@ -76,10 +76,11 @@ class ExecutionPayload(Container): timestamp: uint64 extra_data: ByteList[MAX_EXTRA_DATA_BYTES] base_fee_per_gas: uint256 + # Extra payload fields block_hash: Hash32 # Hash of execution block - # Extra payload field transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD] - execution_witness: ExecutionWitness # [New in Verge] + withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD] + execution_witness: ExecutionWitness # [New in eip6800] ``` #### `ExecutionPayloadHeader` @@ -99,10 +100,12 @@ class ExecutionPayloadHeader(Container): timestamp: uint64 extra_data: ByteList[MAX_EXTRA_DATA_BYTES] base_fee_per_gas: uint256 + # Extra payload fields block_hash: Hash32 # Hash of execution block transactions_root: Root - # Extra payload fields - execution_witness_root: Root # [New in Verge] + withdrawals_root: Root + excess_data_gas: uint256 + execution_witness_root: Root # [New in eip6800] ``` ### New containers @@ -181,6 +184,7 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe assert payload.timestamp == compute_timestamp_at_slot(state, state.slot) # Verify the execution payload is valid assert execution_engine.notify_new_payload(payload) + # Cache execution payload header state.latest_execution_payload_header = ExecutionPayloadHeader( parent_hash=payload.parent_hash, @@ -197,10 +201,12 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe base_fee_per_gas=payload.base_fee_per_gas, block_hash=payload.block_hash, transactions_root=hash_tree_root(payload.transactions), - execution_witness=payload.execution_witness, + withdrawals_root=hash_tree_root(payload.withdrawals), + excess_data_gas=payload.excess_data_gas, + execution_witness=payload.execution_witness, # [New in eip6800] ) ``` ## Testing -TBD \ No newline at end of file +TBD diff --git a/specs/_features/verge/fork.md b/specs/_features/eip6800/fork.md similarity index 81% rename from specs/_features/verge/fork.md rename to specs/_features/eip6800/fork.md index 17fbac370..1edbe4d60 100644 --- a/specs/_features/verge/fork.md +++ b/specs/_features/eip6800/fork.md @@ -1,4 +1,4 @@ -# The Verge -- Fork Logic +# eip6800 -- Fork Logic ## Table of contents @@ -10,7 +10,7 @@ - [Helper functions](#helper-functions) - [Misc](#misc) - [Modified `compute_fork_version`](#modified-compute_fork_version) -- [Fork to the Verge](#fork-to-capella) +- [Fork to eip6800](#fork-to-eip6800) - [Fork trigger](#fork-trigger) - [Upgrading the state](#upgrading-the-state) @@ -18,7 +18,7 @@ ## Introduction -This document describes the process of the Verge upgrade. +This document describes the process of the eip6800 upgrade. ## Configuration @@ -26,8 +26,8 @@ Warning: this configuration is not definitive. | Name | Value | | - | - | -| `VERGE_FORK_VERSION` | `Version('0x05000000')` | -| `VERGE_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** | +| `EIP6800_FORK_VERSION` | `Version('0x05000000')` | +| `EIP6800_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** | ## Helper functions @@ -41,8 +41,10 @@ def compute_fork_version(epoch: Epoch) -> Version: """ Return the fork version at the given ``epoch``. """ - if epoch >= VERGE_FORK_EPOCH: - return VERGE_FORK_VERSION + if epoch >= EIP6800_FORK_EPOCH: + return EIP6800_FORK_VERSION + if epoch >= DENEB_FORK_EPOCH: + return DENEB_FORK_VERSION if epoch >= CAPELLA_FORK_EPOCH: return CAPELLA_FORK_VERSION if epoch >= BELLATRIX_FORK_EPOCH: @@ -52,25 +54,25 @@ def compute_fork_version(epoch: Epoch) -> Version: return GENESIS_FORK_VERSION ``` -## Fork to the Verge +## Fork to eip6800 ### Fork trigger -The fork is triggered at epoch `VERGE_FORK_EPOCH`. +The fork is triggered at epoch `EIP6800_FORK_EPOCH`. -Note that for the pure verge networks, we don't apply `upgrade_to_verge` since it starts with the Verge version logic. +Note that for the pure eip6800 networks, we don't apply `upgrade_to_eip6800` since it starts with the eip6800 version logic. ### Upgrading the state -If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == VERGE_FORK_EPOCH`, -an irregular state change is made to upgrade to the Verge. +If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == EIP6800_FORK_EPOCH`, +an irregular state change is made to upgrade to eip6800. -The upgrade occurs after the completion of the inner loop of `process_slots` that sets `state.slot` equal to `VERGE_FORK_EPOCH * SLOTS_PER_EPOCH`. +The upgrade occurs after the completion of the inner loop of `process_slots` that sets `state.slot` equal to `EIP6800_FORK_EPOCH * SLOTS_PER_EPOCH`. Care must be taken when transitioning through the fork boundary as implementations will need a modified [state transition function](../phase0/beacon-chain.md#beacon-chain-state-transition-function) that deviates from the Phase 0 document. In particular, the outer `state_transition` function defined in the Phase 0 document will not expose the precise fork slot to execute the upgrade in the presence of skipped slots at the fork boundary. Instead, the logic must be within `process_slots`. ```python -def upgrade_to_verge(pre: capella.BeaconState) -> BeaconState: +def upgrade_to_eip6800(pre: capella.BeaconState) -> BeaconState: epoch = capella.get_current_epoch(pre) latest_execution_payload_header = ExecutionPayloadHeader( parent_hash=pre.latest_execution_payload_header.parent_hash, @@ -85,10 +87,11 @@ def upgrade_to_verge(pre: capella.BeaconState) -> BeaconState: timestamp=pre.latest_execution_payload_header.timestamp, extra_data=pre.latest_execution_payload_header.extra_data, base_fee_per_gas=pre.latest_execution_payload_header.base_fee_per_gas, + excess_data_gas=uint256(0), block_hash=pre.latest_execution_payload_header.block_hash, transactions_root=pre.latest_execution_payload_header.transactions_root, withdrawals_root=pre.latest_execution_payload_header.withdrawals_root, - execution_witness=ExecutionWitness([], []) # New in the Verge + execution_witness=ExecutionWitness([], []) # New in eip6800 ) post = BeaconState( # Versioning @@ -97,7 +100,7 @@ def upgrade_to_verge(pre: capella.BeaconState) -> BeaconState: slot=pre.slot, fork=Fork( previous_version=pre.fork.current_version, - current_version=VERGE_FORK_VERSION, + current_version=EIP6800_FORK_VERSION, # [Modified in eip6800] epoch=epoch, ), # History @@ -135,8 +138,7 @@ def upgrade_to_verge(pre: capella.BeaconState) -> BeaconState: next_withdrawal_index=pre.next_withdrawal_index, next_withdrawal_validator_index=pre.next_withdrawal_validator_index, # Deep history valid from Capella onwards - # FIXME most likely wrong - historical_summaries=List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT]([]), + historical_summaries=pre.historical_summaries, ) return post From 0fd49c1a323cf464848c065959efa3a9ce57f77b Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 27 May 2024 14:10:58 +0200 Subject: [PATCH 12/14] fix spelling error --- specs/_features/eip6800/beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/_features/eip6800/beacon-chain.md b/specs/_features/eip6800/beacon-chain.md index 8b33d7173..dd821e66b 100644 --- a/specs/_features/eip6800/beacon-chain.md +++ b/specs/_features/eip6800/beacon-chain.md @@ -121,7 +121,7 @@ class SuffixStateDiff(Container): new_value: Optional[Bytes32] ``` -*Note*: on the Kaustinen testnet, `new_value` is ommitted from the container. +*Note*: on the Kaustinen testnet, `new_value` is omitted from the container. #### `StemStateDiff` From 744ae2e687e2effbea177d0f83e8d825ae1232de Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Tue, 28 May 2024 16:24:11 +0800 Subject: [PATCH 13/14] Add EIP-6800 linter checks. Fix the lint errors. Remove custom type `StateDiff` and then use `List[StemStateDiff, MAX_STEMS]` directly in `ExecutionWitness`. --- .gitignore | 1 + Makefile | 2 +- presets/mainnet/eip6800.yaml | 12 ++++ presets/minimal/eip6800.yaml | 12 ++++ pysetup/constants.py | 2 +- pysetup/helpers.py | 2 +- pysetup/md_doc_paths.py | 2 + pysetup/spec_builders/__init__.py | 3 +- pysetup/spec_builders/eip6800.py | 21 +++++++ setup.py | 8 ++- specs/_features/eip6800/beacon-chain.md | 61 +++++++++++-------- specs/_features/eip6800/fork.md | 6 +- .../pyspec/eth2spec/utils/ssz/ssz_typing.py | 1 + 13 files changed, 99 insertions(+), 34 deletions(-) create mode 100644 presets/mainnet/eip6800.yaml create mode 100644 presets/minimal/eip6800.yaml create mode 100644 pysetup/spec_builders/eip6800.py diff --git a/.gitignore b/.gitignore index 3e4413e97..3586b356c 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ tests/core/pyspec/eth2spec/deneb/ tests/core/pyspec/eth2spec/electra/ tests/core/pyspec/eth2spec/whisk/ tests/core/pyspec/eth2spec/eip7594/ +tests/core/pyspec/eth2spec/eip6800/ # coverage reports .htmlcov diff --git a/Makefile b/Makefile index 8fbedf251..bdf4bdde7 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/*/*.md) \ $(wildcard $(SPEC_DIR)/_features/*/*/*.md) \ $(wildcard $(SSZ_DIR)/*.md) -ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb electra whisk +ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb electra whisk eip6800 # The parameters for commands. Use `foreach` to avoid listing specs again. COVERAGE_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), --cov=eth2spec.$S.$(TEST_PRESET_TYPE)) PYLINT_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), ./eth2spec/$S) diff --git a/presets/mainnet/eip6800.yaml b/presets/mainnet/eip6800.yaml new file mode 100644 index 000000000..d74ee6212 --- /dev/null +++ b/presets/mainnet/eip6800.yaml @@ -0,0 +1,12 @@ +# Mainnet preset - EIP6800 + +# Misc +# --------------------------------------------------------------- +# `uint64(2**16)` (= 65,536) +MAX_STEMS: 65536 +# `uint64(33)` +MAX_COMMITMENTS_PER_STEM: 33 +# `uint64(2**8)` (= 256) +VERKLE_WIDTH: 256 +# `uint64(2**3)` (= 8) +IPA_PROOF_DEPTH: 8 diff --git a/presets/minimal/eip6800.yaml b/presets/minimal/eip6800.yaml new file mode 100644 index 000000000..499721e4a --- /dev/null +++ b/presets/minimal/eip6800.yaml @@ -0,0 +1,12 @@ +# Minimal preset - EIP6800 + +# Execution +# --------------------------------------------------------------- +# `uint64(2**16)` (= 65,536) +MAX_STEMS: 65536 +# `uint64(33)` +MAX_COMMITMENTS_PER_STEM: 33 +# `uint64(2**8)` (= 256) +VERKLE_WIDTH: 256 +# `uint64(2**3)` (= 8) +IPA_PROOF_DEPTH: 8 diff --git a/pysetup/constants.py b/pysetup/constants.py index 0078b24dc..e26efb8e0 100644 --- a/pysetup/constants.py +++ b/pysetup/constants.py @@ -6,10 +6,10 @@ CAPELLA = 'capella' DENEB = 'deneb' ELECTRA = 'electra' EIP7594 = 'eip7594' +EIP6800 = 'eip6800' WHISK = 'whisk' - # The helper functions that are used when defining constants CONSTANT_DEP_SUNDRY_CONSTANTS_FUNCTIONS = ''' def ceillog2(x: int) -> uint64: diff --git a/pysetup/helpers.py b/pysetup/helpers.py index 49c0fcafc..589ae6ab5 100644 --- a/pysetup/helpers.py +++ b/pysetup/helpers.py @@ -178,7 +178,7 @@ def combine_dicts(old_dict: Dict[str, T], new_dict: Dict[str, T]) -> Dict[str, T ignored_dependencies = [ 'bit', 'boolean', 'Vector', 'List', 'Container', 'BLSPubkey', 'BLSSignature', - 'Bytes1', 'Bytes4', 'Bytes8', 'Bytes20', 'Bytes32', 'Bytes48', 'Bytes96', 'Bitlist', 'Bitvector', + 'Bytes1', 'Bytes4', 'Bytes8', 'Bytes20', 'Bytes31', 'Bytes32', 'Bytes48', 'Bytes96', 'Bitlist', 'Bitvector', 'uint8', 'uint16', 'uint32', 'uint64', 'uint128', 'uint256', 'bytes', 'byte', 'ByteList', 'ByteVector', 'Dict', 'dict', 'field', 'ceillog2', 'floorlog2', 'Set', diff --git a/pysetup/md_doc_paths.py b/pysetup/md_doc_paths.py index a4a730e5a..28ebc7137 100644 --- a/pysetup/md_doc_paths.py +++ b/pysetup/md_doc_paths.py @@ -9,6 +9,7 @@ from .constants import ( ELECTRA, WHISK, EIP7594, + EIP6800, ) @@ -21,6 +22,7 @@ PREVIOUS_FORK_OF = { ELECTRA: DENEB, WHISK: CAPELLA, EIP7594: DENEB, + EIP6800: DENEB, } ALL_FORKS = list(PREVIOUS_FORK_OF.keys()) diff --git a/pysetup/spec_builders/__init__.py b/pysetup/spec_builders/__init__.py index ea74b50b7..922cee18b 100644 --- a/pysetup/spec_builders/__init__.py +++ b/pysetup/spec_builders/__init__.py @@ -6,12 +6,13 @@ from .deneb import DenebSpecBuilder from .electra import ElectraSpecBuilder from .whisk import WhiskSpecBuilder from .eip7594 import EIP7594SpecBuilder +from .eip6800 import EIP6800SpecBuilder spec_builders = { builder.fork: builder for builder in ( Phase0SpecBuilder, AltairSpecBuilder, BellatrixSpecBuilder, CapellaSpecBuilder, DenebSpecBuilder, - ElectraSpecBuilder, WhiskSpecBuilder, EIP7594SpecBuilder, + ElectraSpecBuilder, WhiskSpecBuilder, EIP7594SpecBuilder, EIP6800SpecBuilder, ) } diff --git a/pysetup/spec_builders/eip6800.py b/pysetup/spec_builders/eip6800.py new file mode 100644 index 000000000..4ea76d6a2 --- /dev/null +++ b/pysetup/spec_builders/eip6800.py @@ -0,0 +1,21 @@ +from typing import Dict + +from .base import BaseSpecBuilder +from ..constants import EIP6800 + + +class EIP6800SpecBuilder(BaseSpecBuilder): + fork: str = EIP6800 + + @classmethod + def imports(cls, preset_name: str): + return f''' +from eth2spec.deneb import {preset_name} as deneb +from eth2spec.utils.ssz.ssz_typing import Bytes31 +''' + + @classmethod + def hardcoded_custom_type_dep_constants(cls, spec_object) -> str: + return { + 'MAX_STEMS': spec_object.preset_vars['MAX_STEMS'].value, + } diff --git a/setup.py b/setup.py index fe2250f7c..e5c348ada 100644 --- a/setup.py +++ b/setup.py @@ -219,7 +219,13 @@ def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str], pr elif source.startswith("class"): class_name, parent_class = _get_class_info_from_source(source) # check consistency with spec - assert class_name == current_name + try: + assert class_name == current_name + except Exception: + print('class_name', class_name) + print('current_name', current_name) + raise + if parent_class: assert parent_class == "Container" # NOTE: trim whitespace from spec diff --git a/specs/_features/eip6800/beacon-chain.md b/specs/_features/eip6800/beacon-chain.md index dd821e66b..8c93729b8 100644 --- a/specs/_features/eip6800/beacon-chain.md +++ b/specs/_features/eip6800/beacon-chain.md @@ -1,4 +1,4 @@ -# eip6800 -- The Beacon Chain +# EIP6800 -- The Beacon Chain ## Table of contents @@ -21,8 +21,6 @@ - [`VerkleProof`](#verkleproof) - [`ExecutionWitness`](#executionwitness) - [Beacon chain state transition function](#beacon-chain-state-transition-function) - - [Execution engine](#execution-engine) - - [`notify_new_payload`](#notify_new_payload) - [Block processing](#block-processing) - [Execution payload](#execution-payload) - [`process_execution_payload`](#process_execution_payload) @@ -39,7 +37,6 @@ This upgrade adds transaction execution to the beacon chain as part of the eip68 | Name | SSZ equivalent | Description | | - | - | - | -| `StateDiff` | `List[StemStateDiff, MAX_STEMS]` | Only valid if list is sorted by stems | | `BanderwagonGroupElement` | `Bytes32` | | | `BanderwagonFieldElement` | `Bytes32` | | | `Stem` | `Bytes31` | | @@ -50,10 +47,10 @@ This upgrade adds transaction execution to the beacon chain as part of the eip68 | Name | Value | | - | - | -| `MAX_STEMS` | `2**16` | -| `MAX_COMMITMENTS_PER_STEM` | `33` | -| `VERKLE_WIDTH` | `256` | -| `IPA_PROOF_DEPTH` | `8` | +| `MAX_STEMS` | `uint64(2**16)` (= 65,536) | +| `MAX_COMMITMENTS_PER_STEM` | `uint64(33)` | +| `VERKLE_WIDTH` | `uint64(2**8)` (= 256) | +| `IPA_PROOF_DEPTH` | `uint64(2**3)` (= 8) | ## Containers @@ -80,7 +77,9 @@ class ExecutionPayload(Container): block_hash: Hash32 # Hash of execution block transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD] withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD] - execution_witness: ExecutionWitness # [New in eip6800] + blob_gas_used: uint64 + excess_blob_gas: uint64 + execution_witness: ExecutionWitness # [New in EIP6800] ``` #### `ExecutionPayloadHeader` @@ -104,8 +103,9 @@ class ExecutionPayloadHeader(Container): block_hash: Hash32 # Hash of execution block transactions_root: Root withdrawals_root: Root - excess_data_gas: uint256 - execution_witness_root: Root # [New in eip6800] + blob_gas_used: uint64 + excess_data_gas: uint64 + execution_witness_root: Root # [New in EIP6800] ``` ### New containers @@ -114,7 +114,7 @@ class ExecutionPayloadHeader(Container): ```python class SuffixStateDiff(Container): - suffix: Byte + suffix: Bytes1 # Null means not currently present current_value: Optional[Bytes32] # Null means value not updated @@ -132,15 +132,10 @@ class StemStateDiff(Container): suffix_diffs: List[SuffixStateDiff, VERKLE_WIDTH] ``` -```python -# Valid only if list is sorted by stems -StateDiff = List[StemStateDiff, MAX_STEMS] -``` - #### `IPAProof` ```python -class IpaProof(Container): +class IPAProof(Container): cl: Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] cr: Vector[BanderwagonGroupElement, IPA_PROOF_DEPTH] final_evaluation = BanderwagonFieldElement @@ -154,14 +149,14 @@ class VerkleProof(Container): depth_extension_present: ByteList[MAX_STEMS] commitments_by_path: List[BanderwagonGroupElement, MAX_STEMS * MAX_COMMITMENTS_PER_STEM] d: BanderwagonGroupElement - ipa_proof: IpaProof + ipa_proof: IPAProof ``` #### `ExecutionWitness` ```python -class ExecutionWitness(container): - state_diff: StateDiff +class ExecutionWitness(Container): + state_diff: List[StemStateDiff, MAX_STEMS] verkle_proof: VerkleProof ``` @@ -174,16 +169,30 @@ class ExecutionWitness(container): ##### `process_execution_payload` ```python -def process_execution_payload(state: BeaconState, payload: ExecutionPayload, execution_engine: ExecutionEngine) -> None: +def process_execution_payload(state: BeaconState, body: BeaconBlockBody, execution_engine: ExecutionEngine) -> None: + payload = body.execution_payload + # Verify consistency of the parent hash with respect to the previous execution payload header - if is_merge_transition_complete(state): - assert payload.parent_hash == state.latest_execution_payload_header.block_hash + assert payload.parent_hash == state.latest_execution_payload_header.block_hash # Verify prev_randao assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state)) # Verify timestamp assert payload.timestamp == compute_timestamp_at_slot(state, state.slot) + + # Verify commitments are under limit + assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK + # Verify the execution payload is valid - assert execution_engine.notify_new_payload(payload) + # Pass `versioned_hashes` to Execution Engine + # Pass `parent_beacon_block_root` to Execution Engine + versioned_hashes = [kzg_commitment_to_versioned_hash(commitment) for commitment in body.blob_kzg_commitments] + assert execution_engine.verify_and_notify_new_payload( + NewPayloadRequest( + execution_payload=payload, + versioned_hashes=versioned_hashes, + parent_beacon_block_root=state.latest_block_header.parent_root, + ) + ) # Cache execution payload header state.latest_execution_payload_header = ExecutionPayloadHeader( @@ -203,7 +212,7 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe transactions_root=hash_tree_root(payload.transactions), withdrawals_root=hash_tree_root(payload.withdrawals), excess_data_gas=payload.excess_data_gas, - execution_witness=payload.execution_witness, # [New in eip6800] + execution_witness=payload.execution_witness, # [New in EIP6800] ) ``` diff --git a/specs/_features/eip6800/fork.md b/specs/_features/eip6800/fork.md index 1edbe4d60..9c6df2f16 100644 --- a/specs/_features/eip6800/fork.md +++ b/specs/_features/eip6800/fork.md @@ -1,4 +1,4 @@ -# eip6800 -- Fork Logic +# EIP-6800 -- Fork Logic ## Table of contents @@ -72,7 +72,7 @@ Care must be taken when transitioning through the fork boundary as implementatio In particular, the outer `state_transition` function defined in the Phase 0 document will not expose the precise fork slot to execute the upgrade in the presence of skipped slots at the fork boundary. Instead, the logic must be within `process_slots`. ```python -def upgrade_to_eip6800(pre: capella.BeaconState) -> BeaconState: +def upgrade_to_eip6800(pre: deneb.BeaconState) -> BeaconState: epoch = capella.get_current_epoch(pre) latest_execution_payload_header = ExecutionPayloadHeader( parent_hash=pre.latest_execution_payload_header.parent_hash, @@ -91,7 +91,7 @@ def upgrade_to_eip6800(pre: capella.BeaconState) -> BeaconState: block_hash=pre.latest_execution_payload_header.block_hash, transactions_root=pre.latest_execution_payload_header.transactions_root, withdrawals_root=pre.latest_execution_payload_header.withdrawals_root, - execution_witness=ExecutionWitness([], []) # New in eip6800 + execution_witness=ExecutionWitness([], []) # New in eip6800 ) post = BeaconState( # Versioning diff --git a/tests/core/pyspec/eth2spec/utils/ssz/ssz_typing.py b/tests/core/pyspec/eth2spec/utils/ssz/ssz_typing.py index 5a1b61d0b..1f3db2fe0 100644 --- a/tests/core/pyspec/eth2spec/utils/ssz/ssz_typing.py +++ b/tests/core/pyspec/eth2spec/utils/ssz/ssz_typing.py @@ -10,3 +10,4 @@ from remerkleable.core import BasicView, View, Path Bytes20 = ByteVector[20] # type: ignore +Bytes31 = ByteVector[31] # type: ignore From 8737e69c212912ff5aa53bc15f3eb78fafaca6d2 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Tue, 28 May 2024 10:39:35 +0200 Subject: [PATCH 14/14] use execution_witness_root in header --- specs/_features/eip6800/beacon-chain.md | 2 +- specs/_features/eip6800/fork.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/_features/eip6800/beacon-chain.md b/specs/_features/eip6800/beacon-chain.md index 8c93729b8..ab935cb87 100644 --- a/specs/_features/eip6800/beacon-chain.md +++ b/specs/_features/eip6800/beacon-chain.md @@ -212,7 +212,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, - execution_witness=payload.execution_witness, # [New in EIP6800] + execution_witness_root=hash_tree_root(payload.execution_witness), # [New in EIP6800] ) ``` diff --git a/specs/_features/eip6800/fork.md b/specs/_features/eip6800/fork.md index 9c6df2f16..74f143f59 100644 --- a/specs/_features/eip6800/fork.md +++ b/specs/_features/eip6800/fork.md @@ -91,7 +91,7 @@ def upgrade_to_eip6800(pre: deneb.BeaconState) -> BeaconState: block_hash=pre.latest_execution_payload_header.block_hash, transactions_root=pre.latest_execution_payload_header.transactions_root, withdrawals_root=pre.latest_execution_payload_header.withdrawals_root, - execution_witness=ExecutionWitness([], []) # New in eip6800 + execution_witness_root=hash_tree_root(ExecutionWitness([], [])) # New in eip6800 ) post = BeaconState( # Versioning