diff --git a/specs/merge/beacon-chain.md b/specs/merge/beacon-chain.md index 50b9551b0..626a86724 100644 --- a/specs/merge/beacon-chain.md +++ b/specs/merge/beacon-chain.md @@ -24,6 +24,7 @@ - [`ExecutionPayloadHeader`](#executionpayloadheader) - [Helper functions](#helper-functions) - [Misc](#misc) + - [`is_execution_enabled`](#is_execution_enabled) - [`is_transition_completed`](#is_transition_completed) - [`is_transition_block`](#is_transition_block) - [`compute_time_at_slot`](#compute_time_at_slot) @@ -140,6 +141,13 @@ class ExecutionPayloadHeader(Container): ### Misc +#### `is_execution_enabled` + +```python +def is_execution_enabled(state: BeaconState, block: BeaconBlock) -> bool: + return is_transition_completed(state) or is_transition_block(state, block) +``` + #### `is_transition_completed` ```python @@ -173,7 +181,7 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: process_eth1_data(state, block.body) process_operations(state, block.body) # Pre-merge, skip execution payload processing - if is_transition_completed(state) or is_transition_block(state, block): + if is_execution_enabled(state, block): process_execution_payload(state, block.body.execution_payload) # [New in Merge] ``` diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index 775efdcf3..7a2e61c22 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -330,7 +330,6 @@ def with_phases(phases, other_phases=None): phase_dir[PHASE0] = spec_phase0 if ALTAIR in available_phases: phase_dir[ALTAIR] = spec_altair - if MERGE in available_phases: phase_dir[MERGE] = spec_merge diff --git a/tests/core/pyspec/eth2spec/test/merge/block_processing/test_process_execution_payload.py b/tests/core/pyspec/eth2spec/test/merge/block_processing/test_process_execution_payload.py index d45a2689b..fb1da8758 100644 --- a/tests/core/pyspec/eth2spec/test/merge/block_processing/test_process_execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/merge/block_processing/test_process_execution_payload.py @@ -13,6 +13,8 @@ def run_execution_payload_processing(spec, state, execution_payload, valid=True, If ``valid == False``, run expecting ``AssertionError`` """ + pre_exec_header = state.latest_execution_payload_header.copy() + yield 'pre', state yield 'execution', {'execution_valid': execution_valid} yield 'execution_payload', execution_payload @@ -26,7 +28,8 @@ def run_execution_payload_processing(spec, state, execution_payload, valid=True, yield 'post', state - # TODO: any assertions to make? + assert pre_exec_header != state.latest_execution_payload_header + # TODO: any more assertions to make? @with_merge_and_later