Skip to content

Commit e17a138

Browse files
authored
Add tests for Gloas on_block parent payload verification (#5321)
1 parent 4f1df00 commit e17a138

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
from eth_consensus_specs.test.context import (
2+
spec_state_test,
3+
with_gloas_and_later,
4+
)
5+
from eth_consensus_specs.test.helpers.block import (
6+
build_empty_block_for_next_slot,
7+
)
8+
from eth_consensus_specs.test.helpers.execution_payload import (
9+
build_signed_execution_payload_envelope,
10+
)
11+
from eth_consensus_specs.test.helpers.fork_choice import (
12+
add_execution_payload,
13+
output_head_check,
14+
setup_one_block_store,
15+
tick_and_add_block,
16+
tick_store_to_slot,
17+
)
18+
from eth_consensus_specs.test.helpers.state import (
19+
state_transition_and_sign_block,
20+
)
21+
22+
23+
@with_gloas_and_later
24+
@spec_state_test
25+
def test_on_block_parent_full_rejects_unverified_payload(spec, state):
26+
"""
27+
Test that on_block rejects a child claiming a full parent when the
28+
parent's execution payload has not been verified.
29+
"""
30+
store, _, block_state, signed_block, test_steps = yield from setup_one_block_store(spec, state)
31+
32+
# Build a child that points its bid at parent.bid.block_hash so it claims
33+
# the parent is FULL
34+
tick_store_to_slot(spec, store, block_state.slot + 1, test_steps)
35+
child_state = block_state.copy()
36+
child = build_empty_block_for_next_slot(spec, child_state)
37+
child.body.signed_execution_payload_bid.message.parent_block_hash = (
38+
signed_block.message.body.signed_execution_payload_bid.message.block_hash
39+
)
40+
signed_child = state_transition_and_sign_block(spec, child_state, child)
41+
42+
yield from tick_and_add_block(spec, store, signed_child, test_steps, valid=False)
43+
output_head_check(spec, store, test_steps)
44+
yield "steps", test_steps
45+
46+
47+
@with_gloas_and_later
48+
@spec_state_test
49+
def test_on_block_parent_full_accepts_verified_payload(spec, state):
50+
"""
51+
Test that on_block accepts a child claiming a full parent when the
52+
parent's execution payload has been verified.
53+
"""
54+
store, block_root, block_state, signed_block, test_steps = yield from setup_one_block_store(
55+
spec, state
56+
)
57+
58+
# Deliver the parent's envelope so is_payload_verified returns True
59+
envelope = build_signed_execution_payload_envelope(spec, block_state, block_root, signed_block)
60+
yield from add_execution_payload(spec, store, envelope, test_steps)
61+
62+
# Build the same FULL-claim child fixture as the rejection test
63+
tick_store_to_slot(spec, store, block_state.slot + 1, test_steps)
64+
child_state = block_state.copy()
65+
child = build_empty_block_for_next_slot(spec, child_state)
66+
child.body.signed_execution_payload_bid.message.parent_block_hash = (
67+
signed_block.message.body.signed_execution_payload_bid.message.block_hash
68+
)
69+
signed_child = state_transition_and_sign_block(spec, child_state, child)
70+
71+
yield from tick_and_add_block(spec, store, signed_child, test_steps)
72+
output_head_check(spec, store, test_steps)
73+
yield "steps", test_steps

0 commit comments

Comments
 (0)