is_execution_enabled function + misc review fixes

Co-Authored-By: Danny Ryan <dannyjryan@gmail.com>
This commit is contained in:
protolambda 2021-05-06 02:21:52 +02:00
parent 8ac59b7317
commit 76b5974d11
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
3 changed files with 13 additions and 3 deletions

View File

@ -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]
```

View File

@ -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

View File

@ -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