Skip to content

Commit 9be0529

Browse files
authored
Merge pull request #3829 from etan-status/df-elhash
Fix EL block hash computation for Deneb
2 parents 81f3ea8 + a63bad0 commit 9be0529

File tree

17 files changed

+79
-71
lines changed

17 files changed

+79
-71
lines changed

tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_execution_payload.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_bad_parent_hash_first_payload(spec, state):
133133

134134
execution_payload = build_empty_execution_payload(spec, state)
135135
execution_payload.parent_hash = b'\x55' * 32
136-
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
136+
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
137137

138138
yield from run_execution_payload_processing(spec, state, execution_payload)
139139

@@ -146,7 +146,7 @@ def test_invalid_bad_parent_hash_regular_payload(spec, state):
146146

147147
execution_payload = build_empty_execution_payload(spec, state)
148148
execution_payload.parent_hash = spec.Hash32()
149-
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
149+
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
150150

151151
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
152152

@@ -156,7 +156,7 @@ def run_bad_prev_randao_test(spec, state):
156156

157157
execution_payload = build_empty_execution_payload(spec, state)
158158
execution_payload.prev_randao = b'\x42' * 32
159-
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
159+
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
160160

161161
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
162162

@@ -182,7 +182,7 @@ def run_bad_everything_test(spec, state):
182182
execution_payload.parent_hash = spec.Hash32()
183183
execution_payload.prev_randao = spec.Bytes32()
184184
execution_payload.timestamp = 0
185-
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
185+
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
186186

187187
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
188188

@@ -211,7 +211,7 @@ def run_bad_timestamp_test(spec, state, is_future):
211211
else:
212212
timestamp = execution_payload.timestamp - 1
213213
execution_payload.timestamp = timestamp
214-
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
214+
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
215215

216216
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
217217

@@ -249,7 +249,7 @@ def run_non_empty_extra_data_test(spec, state):
249249

250250
execution_payload = build_empty_execution_payload(spec, state)
251251
execution_payload.extra_data = b'\x45' * 12
252-
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
252+
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
253253

254254
yield from run_execution_payload_processing(spec, state, execution_payload)
255255
assert state.latest_execution_payload_header.extra_data == execution_payload.extra_data
@@ -278,7 +278,7 @@ def run_non_empty_transactions_test(spec, state):
278278
spec.Transaction(b'\x99' * 128)
279279
for _ in range(num_transactions)
280280
]
281-
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
281+
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
282282

283283
yield from run_execution_payload_processing(spec, state, execution_payload)
284284
assert state.latest_execution_payload_header.transactions_root == execution_payload.transactions.hash_tree_root()
@@ -304,7 +304,7 @@ def run_zero_length_transaction_test(spec, state):
304304
execution_payload = build_empty_execution_payload(spec, state)
305305
execution_payload.transactions = [spec.Transaction(b'')]
306306
assert len(execution_payload.transactions[0]) == 0
307-
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
307+
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
308308

309309
yield from run_execution_payload_processing(spec, state, execution_payload)
310310
assert state.latest_execution_payload_header.transactions_root == execution_payload.transactions.hash_tree_root()

tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_on_merge_block.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_all_valid(spec, state):
7575
def run_func():
7676
block = build_empty_block_for_next_slot(spec, state)
7777
block.body.execution_payload.parent_hash = pow_block.block_hash
78-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
78+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
7979
signed_block = state_transition_and_sign_block(spec, state, block)
8080
yield from tick_and_add_block(spec, store, signed_block, test_steps, merge_block=True)
8181
# valid
@@ -107,7 +107,7 @@ def test_block_lookup_failed(spec, state):
107107
def run_func():
108108
block = build_empty_block_for_next_slot(spec, state)
109109
block.body.execution_payload.parent_hash = pow_block.block_hash
110-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
110+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
111111
signed_block = state_transition_and_sign_block(spec, state, block)
112112
yield from tick_and_add_block(spec, store, signed_block, test_steps, valid=False, merge_block=True,
113113
block_not_found=True)
@@ -141,7 +141,7 @@ def test_too_early_for_merge(spec, state):
141141
def run_func():
142142
block = build_empty_block_for_next_slot(spec, state)
143143
block.body.execution_payload.parent_hash = pow_block.block_hash
144-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
144+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
145145
signed_block = state_transition_and_sign_block(spec, state, block)
146146
yield from tick_and_add_block(spec, store, signed_block, test_steps, valid=False, merge_block=True)
147147

@@ -174,7 +174,7 @@ def test_too_late_for_merge(spec, state):
174174
def run_func():
175175
block = build_empty_block_for_next_slot(spec, state)
176176
block.body.execution_payload.parent_hash = pow_block.block_hash
177-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
177+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
178178
signed_block = state_transition_and_sign_block(spec, state, block)
179179
yield from tick_and_add_block(spec, store, signed_block, test_steps, valid=False, merge_block=True)
180180

tests/core/pyspec/eth2spec/test/bellatrix/sync/test_optimistic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_from_syncing_to_invalid(spec, state):
6565
block_hashes[f'chain_a_{i - 1}'] if i != 0 else block_hashes['block_0']
6666
)
6767
block.body.execution_payload.extra_data = spec.hash(bytes(f'chain_a_{i}', 'UTF-8'))
68-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
68+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
6969
block_hashes[f'chain_a_{i}'] = block.body.execution_payload.block_hash
7070

7171
signed_block = state_transition_and_sign_block(spec, state, block)
@@ -82,7 +82,7 @@ def test_from_syncing_to_invalid(spec, state):
8282
block_hashes[f'chain_b_{i - 1}'] if i != 0 else block_hashes['block_0']
8383
)
8484
block.body.execution_payload.extra_data = spec.hash(bytes(f'chain_b_{i}', 'UTF-8'))
85-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
85+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
8686
block_hashes[f'chain_b_{i}'] = block.body.execution_payload.block_hash
8787

8888
signed_block = state_transition_with_full_block(spec, state, True, True, block=block)
@@ -95,7 +95,7 @@ def test_from_syncing_to_invalid(spec, state):
9595
block = build_empty_block_for_next_slot(spec, state)
9696
block.body.execution_payload.parent_hash = signed_blocks_b[-1].message.body.execution_payload.block_hash
9797
block.body.execution_payload.extra_data = spec.hash(bytes(f'chain_b_{i}', 'UTF-8'))
98-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
98+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
9999
block_hashes['chain_b_3'] = block.body.execution_payload.block_hash
100100

101101
# Ensure that no duplicate block hashes

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_validate_merge_block_success(spec, state):
6060
pow_chain.head().total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
6161
block = build_empty_block_for_next_slot(spec, state)
6262
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
63-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
63+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
6464
run_validate_merge_block(spec, pow_chain, block)
6565

6666

@@ -81,7 +81,7 @@ def test_validate_merge_block_fail_parent_block_lookup(spec, state):
8181
pow_chain.head().total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
8282
block = build_empty_block_for_next_slot(spec, state)
8383
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
84-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
84+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
8585
run_validate_merge_block(spec, pow_chain, block, valid=False)
8686

8787

@@ -93,7 +93,7 @@ def test_validate_merge_block_fail_after_terminal(spec, state):
9393
pow_chain.head().total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY + uint256(1)
9494
block = build_empty_block_for_next_slot(spec, state)
9595
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
96-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
96+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
9797
run_validate_merge_block(spec, pow_chain, block, valid=False)
9898

9999

@@ -110,7 +110,7 @@ def test_validate_merge_block_tbh_override_success(spec, state):
110110
pow_chain.head().block_hash = TERMINAL_BLOCK_HASH
111111
block = build_empty_block_for_next_slot(spec, state)
112112
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
113-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
113+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
114114
run_validate_merge_block(spec, pow_chain, block)
115115

116116

@@ -126,7 +126,7 @@ def test_validate_merge_block_fail_parent_hash_is_not_tbh(spec, state):
126126
pow_chain.head().total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
127127
block = build_empty_block_for_next_slot(spec, state)
128128
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
129-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
129+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
130130
run_validate_merge_block(spec, pow_chain, block, valid=False)
131131

132132

@@ -143,7 +143,7 @@ def test_validate_merge_block_terminal_block_hash_fail_activation_not_reached(sp
143143
pow_chain.head().block_hash = TERMINAL_BLOCK_HASH
144144
block = build_empty_block_for_next_slot(spec, state)
145145
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
146-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
146+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
147147
run_validate_merge_block(spec, pow_chain, block, valid=False)
148148

149149

@@ -159,5 +159,5 @@ def test_validate_merge_block_fail_activation_not_reached_parent_hash_is_not_tbh
159159
pow_chain.head().total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
160160
block = build_empty_block_for_next_slot(spec, state)
161161
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
162-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
162+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
163163
run_validate_merge_block(spec, pow_chain, block, valid=False)

tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_execution_payload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def test_invalid_bad_parent_hash_first_payload(spec, state):
1919

2020
execution_payload = build_empty_execution_payload(spec, state)
2121
execution_payload.parent_hash = b'\x55' * 32
22-
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
22+
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
2323

2424
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)

0 commit comments

Comments
 (0)