From a1ded22b3ab4fa08bf45c12fb945f9adfc5b37c8 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Thu, 8 Apr 2021 14:48:03 +0600 Subject: [PATCH 01/14] Introduce Hash32 custom type --- specs/merge/beacon-chain.md | 9 +++++---- specs/merge/fork-choice.md | 4 ++-- specs/merge/validator.md | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index be79cf5b5..a93076001 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -47,6 +47,7 @@ We define the following Python custom types for type hinting and readability: | Name | SSZ equivalent | Description | | - | - | - | | `OpaqueTransaction` | `ByteList[MAX_BYTES_PER_OPAQUE_TRANSACTION]` | a byte-list containing a single [typed transaction envelope](https://eips.ethereum.org/EIPS/eip-2718#opaque-byte-array-rather-than-an-rlp-array) structured as `TransactionType \|\| TransactionPayload` | +| `Hash32` | `Bytes32` | a 256-bit hash | ## Constants @@ -98,8 +99,8 @@ The execution payload included in a `BeaconBlockBody`. ```python class ExecutionPayload(Container): - block_hash: Bytes32 # Hash of execution block - parent_hash: Bytes32 + block_hash: Hash32 # Hash of execution block + parent_hash: Hash32 coinbase: Bytes20 state_root: Bytes32 number: uint64 @@ -118,8 +119,8 @@ The execution payload header included in a `BeaconState`. ```python class ExecutionPayloadHeader(Container): - block_hash: Bytes32 # Hash of execution block - parent_hash: Bytes32 + block_hash: Hash32 # Hash of execution block + parent_hash: Hash32 coinbase: Bytes20 state_root: Bytes32 number: uint64 diff --git a/specs/merge/fork-choice.md b/specs/merge/fork-choice.md index 647a663c2..df45bedd1 100644 --- a/specs/merge/fork-choice.md +++ b/specs/merge/fork-choice.md @@ -30,7 +30,7 @@ This is the modification of the fork choice according to the executable beacon c ```python class PowBlock(Container): - block_hash: Bytes32 + block_hash: Hash32 is_processed: boolean is_valid: boolean total_difficulty: uint256 @@ -38,7 +38,7 @@ class PowBlock(Container): #### `get_pow_block` -Let `get_pow_block(hash: Bytes32) -> PowBlock` be the function that given the hash of the PoW block returns its data. +Let `get_pow_block(hash: Hash32) -> PowBlock` be the function that given the hash of the PoW block returns its data. *Note*: The `eth_getBlockByHash` JSON-RPC method does not distinguish invalid blocks from blocks that haven't been processed yet. Either extending this existing method or implementing a new one is required. diff --git a/specs/merge/validator.md b/specs/merge/validator.md index 5b26a21dd..42fe7adcf 100644 --- a/specs/merge/validator.md +++ b/specs/merge/validator.md @@ -48,7 +48,7 @@ Let `get_pow_chain_head() -> PowBlock` be the function that returns the head of ###### `produce_execution_payload` -Let `produce_execution_payload(parent_hash: Bytes32) -> ExecutionPayload` be the function that produces new instance of execution payload. +Let `produce_execution_payload(parent_hash: Hash32) -> ExecutionPayload` be the function that produces new instance of execution payload. The body of this function is implementation dependent. * Set `block.body.execution_payload = get_execution_payload(state)` where: From 334a9b2434f70fe6bb01672f5a8d6c3886b7220f Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Thu, 8 Apr 2021 15:26:32 +0600 Subject: [PATCH 02/14] Pass timestamp to execution state transition and payload production --- specs/merge/beacon-chain.md | 14 ++++++++++++-- specs/merge/validator.md | 5 +++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index a93076001..2793a4579 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -26,6 +26,7 @@ - [Misc](#misc) - [`is_transition_completed`](#is_transition_completed) - [`is_transition_block`](#is_transition_block) + - [`compute_time_at_slot`](#compute_time_at_slot) - [Block processing](#block-processing) - [Execution payload processing](#execution-payload-processing) - [`get_execution_state`](#get_execution_state) @@ -149,6 +150,14 @@ def is_transition_block(state: BeaconState, block_body: BeaconBlockBody) -> bool return not is_transition_completed(state) and block_body.execution_payload != ExecutionPayload() ``` +#### `compute_time_at_slot` + +```python +def compute_time_at_slot(state: BeaconState, slot: Slot) -> uint64: + slots_since_genesis = slot - GENESIS_SLOT + return uint64(state.genesis_time + slots_since_genesis * SECONDS_PER_SLOT) +``` + ### Block processing ```python @@ -171,7 +180,7 @@ The body of the function is implementation dependent. ##### `execution_state_transition` -Let `execution_state_transition(execution_state: ExecutionState, execution_payload: ExecutionPayload) -> None` be the transition function of Ethereum execution state. +Let `execution_state_transition(execution_state: ExecutionState, execution_payload: ExecutionPayload, timestamp: uint64) -> None` be the transition function of Ethereum execution state. The body of the function is implementation dependent. *Note*: `execution_state_transition` must throw `AssertionError` if either the transition itself or one of the pre or post conditions has failed. @@ -193,8 +202,9 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody) -> None assert execution_payload.parent_hash == state.latest_execution_payload_header.block_hash assert execution_payload.number == state.latest_execution_payload_header.number + 1 + timestamp = compute_time_at_slot(state, state.slot) execution_state = get_execution_state(state.latest_execution_payload_header.state_root) - execution_state_transition(execution_state, execution_payload) + execution_state_transition(execution_state, body.execution_payload, timestamp) state.latest_execution_payload_header = ExecutionPayloadHeader( block_hash=execution_payload.block_hash, diff --git a/specs/merge/validator.md b/specs/merge/validator.md index 42fe7adcf..2a23fd3e8 100644 --- a/specs/merge/validator.md +++ b/specs/merge/validator.md @@ -48,7 +48,7 @@ Let `get_pow_chain_head() -> PowBlock` be the function that returns the head of ###### `produce_execution_payload` -Let `produce_execution_payload(parent_hash: Hash32) -> ExecutionPayload` be the function that produces new instance of execution payload. +Let `produce_execution_payload(parent_hash: Hash32, timestamp: uint64) -> ExecutionPayload` be the function that produces new instance of execution payload. The body of this function is implementation dependent. * Set `block.body.execution_payload = get_execution_payload(state)` where: @@ -66,5 +66,6 @@ def get_execution_payload(state: BeaconState) -> ExecutionPayload: # Post-merge, normal payload execution_parent_hash = state.latest_execution_payload_header.block_hash - return produce_execution_payload(execution_parent_hash) + timestamp = compute_time_at_slot(state, state.slot) + return produce_execution_payload(execution_parent_hash, timestamp) ``` From ac175fd3255cefbe02c677ca67abb3b329cc573d Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Thu, 8 Apr 2021 15:29:42 +0600 Subject: [PATCH 03/14] Replace state with its root in execution_state_transition params --- specs/merge/beacon-chain.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index 2793a4579..98312d246 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -29,7 +29,6 @@ - [`compute_time_at_slot`](#compute_time_at_slot) - [Block processing](#block-processing) - [Execution payload processing](#execution-payload-processing) - - [`get_execution_state`](#get_execution_state) - [`execution_state_transition`](#execution_state_transition) - [`process_execution_payload`](#process_execution_payload) @@ -171,16 +170,9 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: #### Execution payload processing -##### `get_execution_state` - -*Note*: `ExecutionState` class is an abstract class representing Ethereum execution state. - -Let `get_execution_state(execution_state_root: Bytes32) -> ExecutionState` be the function that given the root hash returns a copy of Ethereum execution state. -The body of the function is implementation dependent. - ##### `execution_state_transition` -Let `execution_state_transition(execution_state: ExecutionState, execution_payload: ExecutionPayload, timestamp: uint64) -> None` be the transition function of Ethereum execution state. +Let `execution_state_transition(execution_state_root: Bytes32, execution_payload: ExecutionPayload, timestamp: uint64) -> None` be the transition function of Ethereum execution state. The body of the function is implementation dependent. *Note*: `execution_state_transition` must throw `AssertionError` if either the transition itself or one of the pre or post conditions has failed. @@ -203,8 +195,8 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody) -> None assert execution_payload.number == state.latest_execution_payload_header.number + 1 timestamp = compute_time_at_slot(state, state.slot) - execution_state = get_execution_state(state.latest_execution_payload_header.state_root) - execution_state_transition(execution_state, body.execution_payload, timestamp) + execution_state_root = state.latest_execution_payload_header.state_root + execution_state_transition(execution_state_root, body.execution_payload, timestamp) state.latest_execution_payload_header = ExecutionPayloadHeader( block_hash=execution_payload.block_hash, From c4c4dade27ff08bad81171132b4717dd6e3762b7 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Fri, 9 Apr 2021 22:50:37 +0600 Subject: [PATCH 04/14] Add missing timestamp in validator.md/get_execution_payload --- specs/merge/validator.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specs/merge/validator.md b/specs/merge/validator.md index 2a23fd3e8..dccc5727b 100644 --- a/specs/merge/validator.md +++ b/specs/merge/validator.md @@ -62,7 +62,8 @@ def get_execution_payload(state: BeaconState) -> ExecutionPayload: return ExecutionPayload() else: # Signify merge via producing on top of the last PoW block - return produce_execution_payload(pow_block.block_hash) + timestamp = compute_time_at_slot(state, state.slot) + return produce_execution_payload(pow_block.block_hash, timestamp) # Post-merge, normal payload execution_parent_hash = state.latest_execution_payload_header.block_hash From 79230c5f68f975a4765dcd4c0bd9f28a11e427b8 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Sat, 10 Apr 2021 03:04:27 +0800 Subject: [PATCH 05/14] Update pyspec builder --- setup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 514f75c50..b337d70ff 100644 --- a/setup.py +++ b/setup.py @@ -313,11 +313,13 @@ def get_pow_chain_head() -> PowBlock: pass -def execution_state_transition(execution_state: ExecutionState, execution_payload: ExecutionPayload) -> None: +def execution_state_transition(execution_state_root: Bytes32, + execution_payload: ExecutionPayload, + timestamp: uint64) -> None: pass -def produce_execution_payload(parent_hash: Bytes32) -> ExecutionPayload: +def produce_execution_payload(parent_hash: Hash32, timestamp: uint64) -> ExecutionPayload: pass""" From 44de07fee924fd010f73a1b4f83086cb1782bb23 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Tue, 13 Apr 2021 15:20:45 +0600 Subject: [PATCH 06/14] Replace hash: Hash32 with block_hash: Hash32 Co-authored-by: Hsiao-Wei Wang --- specs/merge/fork-choice.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/specs/merge/fork-choice.md b/specs/merge/fork-choice.md index df45bedd1..ae3917814 100644 --- a/specs/merge/fork-choice.md +++ b/specs/merge/fork-choice.md @@ -38,7 +38,7 @@ class PowBlock(Container): #### `get_pow_block` -Let `get_pow_block(hash: Hash32) -> PowBlock` be the function that given the hash of the PoW block returns its data. +Let `get_pow_block(block_hash: Hash32) -> PowBlock` be the function that given the hash of the PoW block returns its data. *Note*: The `eth_getBlockByHash` JSON-RPC method does not distinguish invalid blocks from blocks that haven't been processed yet. Either extending this existing method or implementing a new one is required. @@ -113,4 +113,3 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None: if ancestor_at_finalized_slot != store.finalized_checkpoint.root: store.justified_checkpoint = state.current_justified_checkpoint ``` - From 13edd20a365d8ac8f018864b806d1552fd2fcef5 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Tue, 13 Apr 2021 15:29:07 +0600 Subject: [PATCH 07/14] Change Eth1Data.block_hash type to Hash32 --- specs/merge/beacon-chain.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index 98312d246..3a13c1a3d 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -16,6 +16,8 @@ - [Transition](#transition) - [Execution](#execution) - [Containers](#containers) + - [Updated containers](#updated-containers) + - [`Eth1Data`](#eth1data) - [Extended containers](#extended-containers) - [`BeaconBlockBody`](#beaconblockbody) - [`BeaconState`](#beaconstate) @@ -67,6 +69,19 @@ We define the following Python custom types for type hinting and readability: ## Containers +### Modified containers + +#### `Eth1Data` + +*Note*: The only modification is the type of `block_hash` field that is changed to `Hash32`. + +```python +class Eth1Data(Container): + deposit_root: Root + deposit_count: uint64 + block_hash: Hash32 # [Modified in Merge] +``` + ### Extended containers *Note*: Extended SSZ containers inherit all fields from the parent in the original From ad0f1e56207b9170d6609f57aa4cf552f8e3bc49 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Tue, 13 Apr 2021 19:08:47 +0600 Subject: [PATCH 08/14] Add timestamp field into ExecutionPayload --- specs/merge/beacon-chain.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index 3a13c1a3d..ade05d4b8 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -121,6 +121,7 @@ class ExecutionPayload(Container): number: uint64 gas_limit: uint64 gas_used: uint64 + timestamp: uint64 receipt_root: Bytes32 logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM] transactions: List[OpaqueTransaction, MAX_APPLICATION_TRANSACTIONS] @@ -141,6 +142,7 @@ class ExecutionPayloadHeader(Container): number: uint64 gas_limit: uint64 gas_used: uint64 + timestamp: uint64 receipt_root: Bytes32 logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM] transactions_root: Root @@ -187,7 +189,7 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: ##### `execution_state_transition` -Let `execution_state_transition(execution_state_root: Bytes32, execution_payload: ExecutionPayload, timestamp: uint64) -> None` be the transition function of Ethereum execution state. +Let `execution_state_transition(execution_state_root: Bytes32, execution_payload: ExecutionPayload) -> None` be the transition function of Ethereum execution state. The body of the function is implementation dependent. *Note*: `execution_state_transition` must throw `AssertionError` if either the transition itself or one of the pre or post conditions has failed. @@ -209,9 +211,10 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody) -> None assert execution_payload.parent_hash == state.latest_execution_payload_header.block_hash assert execution_payload.number == state.latest_execution_payload_header.number + 1 - timestamp = compute_time_at_slot(state, state.slot) + assert execution_payload.timestamp == compute_time_at_slot(state, state.slot) + execution_state_root = state.latest_execution_payload_header.state_root - execution_state_transition(execution_state_root, body.execution_payload, timestamp) + execution_state_transition(execution_state_root, body.execution_payload) state.latest_execution_payload_header = ExecutionPayloadHeader( block_hash=execution_payload.block_hash, @@ -221,6 +224,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody) -> None number=execution_payload.number, gas_limit=execution_payload.gas_limit, gas_used=execution_payload.gas_used, + timestamp=execution_payload.timestamp, receipt_root=execution_payload.receipt_root, logs_bloom=execution_payload.logs_bloom, transactions_root=hash_tree_root(execution_payload.transactions), From dbbc63b7a3857fbda74b194b238b6ef7a5179f40 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Tue, 13 Apr 2021 19:13:54 +0600 Subject: [PATCH 09/14] Replace execution_state_transition with validate_execution_payload --- specs/merge/beacon-chain.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index ade05d4b8..2dc1bbc84 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -16,7 +16,7 @@ - [Transition](#transition) - [Execution](#execution) - [Containers](#containers) - - [Updated containers](#updated-containers) + - [Modified containers](#modified-containers) - [`Eth1Data`](#eth1data) - [Extended containers](#extended-containers) - [`BeaconBlockBody`](#beaconblockbody) @@ -31,7 +31,7 @@ - [`compute_time_at_slot`](#compute_time_at_slot) - [Block processing](#block-processing) - [Execution payload processing](#execution-payload-processing) - - [`execution_state_transition`](#execution_state_transition) + - [`validate_execution_payload`](#validate_execution_payload) - [`process_execution_payload`](#process_execution_payload) @@ -187,13 +187,11 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: #### Execution payload processing -##### `execution_state_transition` +##### `validate_execution_payload` -Let `execution_state_transition(execution_state_root: Bytes32, execution_payload: ExecutionPayload) -> None` be the transition function of Ethereum execution state. +Let `validate_execution_payload(execution_payload: ExecutionPayload) -> boolean` be the function checking whether given `ExecutionPayload` is valid or not. The body of the function is implementation dependent. -*Note*: `execution_state_transition` must throw `AssertionError` if either the transition itself or one of the pre or post conditions has failed. - ##### `process_execution_payload` ```python @@ -213,8 +211,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody) -> None assert execution_payload.timestamp == compute_time_at_slot(state, state.slot) - execution_state_root = state.latest_execution_payload_header.state_root - execution_state_transition(execution_state_root, body.execution_payload) + assert validate_execution_payload(execution_payload) state.latest_execution_payload_header = ExecutionPayloadHeader( block_hash=execution_payload.block_hash, From 7d8570d48871b82e260ca09454299fc5edf7ef2a Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Wed, 14 Apr 2021 12:53:30 +0600 Subject: [PATCH 10/14] Warn about potential overflows in compute_time_at_slot --- specs/merge/beacon-chain.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index 2dc1bbc84..028eb5b84 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -168,6 +168,8 @@ def is_transition_block(state: BeaconState, block_body: BeaconBlockBody) -> bool #### `compute_time_at_slot` +*Note*: This function is unsafe with respect to overflows and underflows. + ```python def compute_time_at_slot(state: BeaconState, slot: Slot) -> uint64: slots_since_genesis = slot - GENESIS_SLOT From 292fd604f8f6073c891694fa3794c98634b9e6b4 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Wed, 14 Apr 2021 12:54:49 +0600 Subject: [PATCH 11/14] Replace boolean with bool whenever make sense --- specs/merge/beacon-chain.md | 6 +++--- specs/merge/fork-choice.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index 028eb5b84..688f36b47 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -155,14 +155,14 @@ class ExecutionPayloadHeader(Container): #### `is_transition_completed` ```python -def is_transition_completed(state: BeaconState) -> boolean: +def is_transition_completed(state: BeaconState) -> bool: return state.latest_execution_payload_header != ExecutionPayloadHeader() ``` #### `is_transition_block` ```python -def is_transition_block(state: BeaconState, block_body: BeaconBlockBody) -> boolean: +def is_transition_block(state: BeaconState, block_body: BeaconBlockBody) -> bool: return not is_transition_completed(state) and block_body.execution_payload != ExecutionPayload() ``` @@ -191,7 +191,7 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: ##### `validate_execution_payload` -Let `validate_execution_payload(execution_payload: ExecutionPayload) -> boolean` be the function checking whether given `ExecutionPayload` is valid or not. +Let `validate_execution_payload(execution_payload: ExecutionPayload) -> bool` be the function checking whether given `ExecutionPayload` is valid or not. The body of the function is implementation dependent. ##### `process_execution_payload` diff --git a/specs/merge/fork-choice.md b/specs/merge/fork-choice.md index ae3917814..34647f45d 100644 --- a/specs/merge/fork-choice.md +++ b/specs/merge/fork-choice.md @@ -47,7 +47,7 @@ Let `get_pow_block(block_hash: Hash32) -> PowBlock` be the function that given t Used by fork-choice handler, `on_block`. ```python -def is_valid_transition_block(block: PowBlock) -> boolean: +def is_valid_transition_block(block: PowBlock) -> bool: is_total_difficulty_reached = block.total_difficulty >= TRANSITION_TOTAL_DIFFICULTY return block.is_valid and is_total_difficulty_reached ``` From 9d79831b568ace7e06b9b52db23bb083632a5980 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Wed, 14 Apr 2021 13:03:58 +0600 Subject: [PATCH 12/14] Rename validate_execution_payload to verify_execution_state_transition --- specs/merge/beacon-chain.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index 688f36b47..4e0c554d2 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -31,7 +31,7 @@ - [`compute_time_at_slot`](#compute_time_at_slot) - [Block processing](#block-processing) - [Execution payload processing](#execution-payload-processing) - - [`validate_execution_payload`](#validate_execution_payload) + - [`verify_execution_state_transition`](#verify_execution_state_transition) - [`process_execution_payload`](#process_execution_payload) @@ -189,9 +189,9 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: #### Execution payload processing -##### `validate_execution_payload` +##### `verify_execution_state_transition` -Let `validate_execution_payload(execution_payload: ExecutionPayload) -> bool` be the function checking whether given `ExecutionPayload` is valid or not. +Let `verify_execution_state_transition(execution_payload: ExecutionPayload) -> bool` be the function that verifies given `ExecutionPayload` with respect to execution state transition. The body of the function is implementation dependent. ##### `process_execution_payload` @@ -213,7 +213,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody) -> None assert execution_payload.timestamp == compute_time_at_slot(state, state.slot) - assert validate_execution_payload(execution_payload) + assert verify_execution_state_transition(execution_payload) state.latest_execution_payload_header = ExecutionPayloadHeader( block_hash=execution_payload.block_hash, From 320172fb08a0dad653fa3a4a67dce92bce5747b7 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Wed, 14 Apr 2021 08:02:09 -0500 Subject: [PATCH 13/14] fix lint --- setup.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index b337d70ff..6490f4ffa 100644 --- a/setup.py +++ b/setup.py @@ -313,10 +313,8 @@ def get_pow_chain_head() -> PowBlock: pass -def execution_state_transition(execution_state_root: Bytes32, - execution_payload: ExecutionPayload, - timestamp: uint64) -> None: - pass +def verify_execution_state_transition(execution_payload: ExecutionPayload) -> bool: + return True def produce_execution_payload(parent_hash: Hash32, timestamp: uint64) -> ExecutionPayload: From c7166a37af400ba174c70db88ceeaa690685f873 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Thu, 15 Apr 2021 06:47:11 -0500 Subject: [PATCH 14/14] change eth1data block_hash type to Hash32 in phase 0 --- specs/merge/beacon-chain.md | 16 ---------------- specs/phase0/beacon-chain.md | 4 +++- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index 4e0c554d2..a508cb670 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -16,8 +16,6 @@ - [Transition](#transition) - [Execution](#execution) - [Containers](#containers) - - [Modified containers](#modified-containers) - - [`Eth1Data`](#eth1data) - [Extended containers](#extended-containers) - [`BeaconBlockBody`](#beaconblockbody) - [`BeaconState`](#beaconstate) @@ -49,7 +47,6 @@ We define the following Python custom types for type hinting and readability: | Name | SSZ equivalent | Description | | - | - | - | | `OpaqueTransaction` | `ByteList[MAX_BYTES_PER_OPAQUE_TRANSACTION]` | a byte-list containing a single [typed transaction envelope](https://eips.ethereum.org/EIPS/eip-2718#opaque-byte-array-rather-than-an-rlp-array) structured as `TransactionType \|\| TransactionPayload` | -| `Hash32` | `Bytes32` | a 256-bit hash | ## Constants @@ -69,19 +66,6 @@ We define the following Python custom types for type hinting and readability: ## Containers -### Modified containers - -#### `Eth1Data` - -*Note*: The only modification is the type of `block_hash` field that is changed to `Hash32`. - -```python -class Eth1Data(Container): - deposit_root: Root - deposit_count: uint64 - block_hash: Hash32 # [Modified in Merge] -``` - ### Extended containers *Note*: Extended SSZ containers inherit all fields from the parent in the original diff --git a/specs/phase0/beacon-chain.md b/specs/phase0/beacon-chain.md index cbd085bd3..3176d543c 100644 --- a/specs/phase0/beacon-chain.md +++ b/specs/phase0/beacon-chain.md @@ -157,6 +157,7 @@ We define the following Python custom types for type hinting and readability: | `ValidatorIndex` | `uint64` | a validator registry index | | `Gwei` | `uint64` | an amount in Gwei | | `Root` | `Bytes32` | a Merkle root | +| `Hash32` | `Bytes32` | a 256-bit hash | | `Version` | `Bytes4` | a fork version number | | `DomainType` | `Bytes4` | a domain type | | `ForkDigest` | `Bytes4` | a digest of the current fork data | @@ -164,6 +165,7 @@ We define the following Python custom types for type hinting and readability: | `BLSPubkey` | `Bytes48` | a BLS12-381 public key | | `BLSSignature` | `Bytes96` | a BLS12-381 signature | + ## Constants The following values are (non-configurable) constants used throughout the specification. @@ -374,7 +376,7 @@ class PendingAttestation(Container): class Eth1Data(Container): deposit_root: Root deposit_count: uint64 - block_hash: Bytes32 + block_hash: Hash32 ``` #### `HistoricalBatch`