Skip to content

Commit 11e1509

Browse files
Fix tests to ensure merge functions do not need to be modified (#4718)
This PR removes the legacy merge transition functions `is_merge_transition_complete` and `validate_merge_block` from the Gloas specification. Updated test helpers to conditionally skip merge transition assertions for post-Gloas forks Fixes #4684
1 parent 5281d23 commit 11e1509

File tree

3 files changed

+6
-62
lines changed

3 files changed

+6
-62
lines changed

specs/gloas/beacon-chain.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@
6868
- [New `process_payload_attestation`](#new-process_payload_attestation)
6969
- [Proposer Slashing](#proposer-slashing)
7070
- [Modified `process_proposer_slashing`](#modified-process_proposer_slashing)
71-
- [Modified `is_merge_transition_complete`](#modified-is_merge_transition_complete)
72-
- [Modified `validate_merge_block`](#modified-validate_merge_block)
7371
- [Execution payload processing](#execution-payload-processing)
7472
- [New `verify_execution_payload_envelope_signature`](#new-verify_execution_payload_envelope_signature)
7573
- [New `process_execution_payload`](#new-process_execution_payload)
@@ -1203,53 +1201,6 @@ def process_proposer_slashing(state: BeaconState, proposer_slashing: ProposerSla
12031201
slash_validator(state, header_1.proposer_index)
12041202
```
12051203

1206-
#### Modified `is_merge_transition_complete`
1207-
1208-
*Note*: `is_merge_transition_complete` is modified only for testing purposes to
1209-
add the blob kzg commitments root for an empty list
1210-
1211-
```python
1212-
def is_merge_transition_complete(state: BeaconState) -> bool:
1213-
bid = ExecutionPayloadBid()
1214-
kzgs = List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]()
1215-
bid.blob_kzg_commitments_root = kzgs.hash_tree_root()
1216-
1217-
return state.latest_execution_payload_bid != bid
1218-
```
1219-
1220-
#### Modified `validate_merge_block`
1221-
1222-
*Note*: `validate_merge_block` is modified to use the new
1223-
`signed_execution_payload_bid` field in the `BeaconBlockBody`.
1224-
1225-
```python
1226-
def validate_merge_block(block: BeaconBlock) -> None:
1227-
"""
1228-
Check the parent PoW block of execution payload is a valid terminal PoW block.
1229-
1230-
Note: Unavailable PoW block(s) may later become available,
1231-
and a client software MAY delay a call to ``validate_merge_block``
1232-
until the PoW block(s) become available.
1233-
"""
1234-
if TERMINAL_BLOCK_HASH != Hash32():
1235-
# If `TERMINAL_BLOCK_HASH` is used as an override, the activation epoch must be reached.
1236-
assert compute_epoch_at_slot(block.slot) >= TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH
1237-
assert (
1238-
block.body.signed_execution_payload_bid.message.parent_block_hash == TERMINAL_BLOCK_HASH
1239-
)
1240-
return
1241-
1242-
# [Modified in Gloas:EIP7732]
1243-
pow_block = get_pow_block(block.body.signed_execution_payload_bid.message.parent_block_hash)
1244-
# Check if `pow_block` is available
1245-
assert pow_block is not None
1246-
pow_parent = get_pow_block(pow_block.parent_hash)
1247-
# Check if `pow_parent` is available
1248-
assert pow_parent is not None
1249-
# Check if `pow_block` is a valid terminal PoW block
1250-
assert is_valid_terminal_pow_block(pow_block, pow_parent)
1251-
```
1252-
12531204
### Execution payload processing
12541205

12551206
#### New `verify_execution_payload_envelope_signature`

tests/core/pyspec/eth2spec/test/bellatrix/unittests/test_transition.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
from eth2spec.test.context import (
22
spec_state_test,
3-
with_all_phases_from_to,
4-
with_bellatrix_and_later,
5-
)
6-
from eth2spec.test.helpers.constants import (
7-
BELLATRIX,
8-
GLOAS,
3+
with_bellatrix_only,
94
)
105
from eth2spec.test.helpers.execution_payload import (
116
build_empty_execution_payload,
@@ -14,14 +9,14 @@
149
)
1510

1611

17-
@with_bellatrix_and_later
12+
@with_bellatrix_only
1813
@spec_state_test
1914
def test_fail_merge_complete(spec, state):
2015
state = build_state_with_incomplete_transition(spec, state)
2116
assert not spec.is_merge_transition_complete(state)
2217

2318

24-
@with_bellatrix_and_later
19+
@with_bellatrix_only
2520
@spec_state_test
2621
def test_success_merge_complete(spec, state):
2722
state = build_state_with_complete_transition(spec, state)
@@ -37,7 +32,7 @@ def test_success_merge_complete(spec, state):
3732
]
3833

3934

40-
@with_all_phases_from_to(BELLATRIX, GLOAS)
35+
@with_bellatrix_only
4136
@spec_state_test
4237
def test_is_merge_block_and_is_execution_enabled(spec, state):
4338
for result in expected_results:

tests/core/pyspec/eth2spec/test/helpers/execution_payload.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,7 @@ def build_state_with_incomplete_transition(spec, state):
444444
else:
445445
header = spec.ExecutionPayloadHeader()
446446
state = build_state_with_execution_payload_header(spec, state, header)
447-
448-
assert not spec.is_merge_transition_complete(state)
447+
assert not spec.is_merge_transition_complete(state)
449448

450449
return state
451450

@@ -458,8 +457,7 @@ def build_state_with_complete_transition(spec, state):
458457
else:
459458
payload_header = get_execution_payload_header(spec, state, pre_state_payload)
460459
state = build_state_with_execution_payload_header(spec, state, payload_header)
461-
462-
assert spec.is_merge_transition_complete(state)
460+
assert spec.is_merge_transition_complete(state)
463461

464462
return state
465463

0 commit comments

Comments
 (0)