Skip to content

Commit 89a79cc

Browse files
committed
fix deneb tests
1 parent 4acbaca commit 89a79cc

2 files changed

Lines changed: 40 additions & 19 deletions

File tree

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

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,13 @@ def run_execution_payload_processing(spec, state, execution_payload, blob_kzg_co
5656
message=envelope,
5757
signature=signature,
5858
)
59+
body = spec.BeaconBlockBody()
5960
else:
6061
body = spec.BeaconBlockBody(
6162
blob_kzg_commitments=blob_kzg_commitments,
6263
execution_payload=execution_payload,
6364
)
6465

65-
# Before Deneb, only `body.execution_payload` matters. `BeaconBlockBody` is just a wrapper.
66-
body = spec.BeaconBlockBody()
67-
if not is_post_eip7732(spec):
68-
body.blob_kzg_commitments = blob_kzg_commitments
69-
body.execution_payload = execution_payload
70-
7166
yield 'pre', state
7267
yield 'execution', {'execution_valid': execution_valid}
7368
yield 'body', body
@@ -127,7 +122,10 @@ def test_incorrect_blob_tx_type(spec, state):
127122
execution_payload.transactions = [opaque_tx]
128123
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
129124

130-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
125+
## Make the first block full in EIP-7732
126+
if is_post_eip7732(spec):
127+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
128+
131129
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments)
132130

133131

@@ -145,7 +143,9 @@ def test_incorrect_transaction_length_1_extra_byte(spec, state):
145143
execution_payload.transactions = [opaque_tx]
146144
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
147145

148-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
146+
## Make the first block full in EIP-7732
147+
if is_post_eip7732(spec):
148+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
149149
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments)
150150

151151

@@ -163,7 +163,9 @@ def test_incorrect_transaction_length_1_byte_short(spec, state):
163163
execution_payload.transactions = [opaque_tx]
164164
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
165165

166-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
166+
## Make the first block full in EIP-7732
167+
if is_post_eip7732(spec):
168+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
167169
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments)
168170

169171

@@ -181,7 +183,9 @@ def test_incorrect_transaction_length_empty(spec, state):
181183
execution_payload.transactions = [opaque_tx]
182184
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
183185

184-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
186+
## Make the first block full in EIP-7732
187+
if is_post_eip7732(spec):
188+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
185189
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments)
186190

187191

@@ -199,7 +203,10 @@ def test_incorrect_transaction_length_32_extra_bytes(spec, state):
199203
execution_payload.transactions = [opaque_tx]
200204
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
201205

202-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
206+
207+
## Make the first block full in EIP-7732
208+
if is_post_eip7732(spec):
209+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
203210
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments)
204211

205212

@@ -216,7 +223,9 @@ def test_no_transactions_with_commitments(spec, state):
216223
execution_payload.transactions = []
217224
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
218225

219-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
226+
## Make the first block full in EIP-7732
227+
if is_post_eip7732(spec):
228+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
220229
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments)
221230

222231

@@ -234,7 +243,9 @@ def test_incorrect_commitment(spec, state):
234243
execution_payload.transactions = [opaque_tx]
235244
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
236245

237-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
246+
## Make the first block full in EIP-7732
247+
if is_post_eip7732(spec):
248+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
238249
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments)
239250

240251

@@ -252,7 +263,9 @@ def test_incorrect_commitments_order(spec, state):
252263
execution_payload.transactions = [opaque_tx]
253264
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
254265

255-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
266+
## Make the first block full in EIP-7732
267+
if is_post_eip7732(spec):
268+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
256269
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments)
257270

258271

@@ -267,7 +280,9 @@ def test_incorrect_block_hash(spec, state):
267280
execution_payload.block_hash = b'\x12' * 32 # incorrect block hash
268281

269282
# CL itself doesn't verify EL block hash
270-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
283+
## Make the first block full in EIP-7732
284+
if is_post_eip7732(spec):
285+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
271286
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments)
272287

273288

@@ -285,7 +300,9 @@ def test_zeroed_commitment(spec, state):
285300
execution_payload.transactions = [opaque_tx]
286301
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
287302

288-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
303+
## Make the first block full in EIP-7732
304+
if is_post_eip7732(spec):
305+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
289306
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments)
290307

291308

@@ -302,7 +319,9 @@ def test_invalid_correct_input__execution_invalid(spec, state):
302319
execution_payload.transactions = [opaque_tx]
303320
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
304321

305-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
322+
## Make the first block full in EIP-7732
323+
if is_post_eip7732(spec):
324+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
306325
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments,
307326
valid=False, execution_valid=False)
308327

@@ -317,5 +336,7 @@ def test_invalid_exceed_max_blobs_per_block(spec, state):
317336
execution_payload.transactions = [opaque_tx]
318337
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)
319338

320-
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
339+
## Make the first block full in EIP-7732
340+
if is_post_eip7732(spec):
341+
state.latest_execution_payload_header.block_hash = execution_payload.block_hash
321342
yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments, valid=False)

tests/core/pyspec/eth2spec/test/deneb/unittests/validator/test_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _get_sample_sidecars(spec, state, rng):
3434
else:
3535
block.body.blob_kzg_commitments = blob_kzg_commitments_1 + blob_kzg_commitments_2
3636
block.body.execution_payload.transactions = [opaque_tx_1, opaque_tx_2]
37-
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
37+
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
3838

3939
blobs = blobs_1 + blobs_2
4040
proofs = proofs_1 + proofs_2

0 commit comments

Comments
 (0)