Skip to content

Commit ab9817d

Browse files
authored
new(tests): EIP-7620/7873 - ensure no account gets created on failure (#1486)
* new(tests): EIP-7620/7873 - ensure no account gets created on failure * fix(tests): EIP-7873 - remove redundant 1559-izing of txs * Apply code review suggestions
1 parent 70a1183 commit ab9817d

File tree

3 files changed

+65
-67
lines changed

3 files changed

+65
-67
lines changed

tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py

+26-9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
slot_call_result,
2424
slot_code_should_fail,
2525
slot_code_worked,
26+
slot_counter,
2627
slot_create_address,
2728
slot_max_depth,
2829
slot_returndata,
@@ -87,7 +88,8 @@ def test_initcode_revert(state_test: StateTestFiller, pre: Alloc, revert: bytes)
8788
slot_returndata: revert,
8889
slot_code_worked: value_code_worked,
8990
}
90-
)
91+
),
92+
compute_eofcreate_address(contract_address, 0): Account.NONEXISTENT,
9193
}
9294
tx = Transaction(
9395
to=contract_address,
@@ -125,7 +127,8 @@ def test_initcode_aborts(
125127
slot_create_address: EOFCREATE_FAILURE,
126128
slot_code_worked: value_code_worked,
127129
}
128-
)
130+
),
131+
compute_eofcreate_address(contract_address, 0): Account.NONEXISTENT,
129132
}
130133
tx = Transaction(
131134
to=contract_address,
@@ -215,15 +218,19 @@ def test_eofcreate_deploy_sizes(
215218
# Storage in 0 should have the address,
216219
# Storage 1 is a canary of 1 to make sure it tried to execute, which also covers cases of
217220
# data+code being greater than initcode_size_max, which is allowed.
221+
success = target_deploy_size <= MAX_BYTECODE_SIZE
218222
post = {
219223
contract_address: Account(
220224
storage={
221225
slot_create_address: compute_eofcreate_address(contract_address, 0)
222-
if target_deploy_size <= MAX_BYTECODE_SIZE
226+
if success
223227
else EOFCREATE_FAILURE,
224228
slot_code_worked: value_code_worked,
225229
}
226-
)
230+
),
231+
compute_eofcreate_address(contract_address, 0): Account()
232+
if success
233+
else Account.NONEXISTENT,
227234
}
228235
tx = Transaction(
229236
to=contract_address,
@@ -304,15 +311,19 @@ def test_auxdata_size_failures(state_test: StateTestFiller, pre: Alloc, auxdata_
304311

305312
# Storage in 0 will have address in first test, 0 in all other cases indicating failure
306313
# Storage 1 in 1 is a canary to see if EOFCREATE opcode halted
314+
success = deployed_container_size <= MAX_BYTECODE_SIZE
307315
post = {
308316
contract_address: Account(
309317
storage={
310318
slot_create_address: compute_eofcreate_address(contract_address, 0)
311-
if deployed_container_size <= MAX_BYTECODE_SIZE
319+
if success
312320
else 0,
313321
slot_code_worked: value_code_worked,
314322
}
315-
)
323+
),
324+
compute_eofcreate_address(contract_address, 0): Account()
325+
if success
326+
else Account.NONEXISTENT,
316327
}
317328

318329
tx = Transaction(
@@ -615,7 +626,8 @@ def test_static_flag_eofcreate(
615626
else LEGACY_CALL_FAILURE,
616627
slot_code_worked: value_code_worked,
617628
}
618-
)
629+
),
630+
compute_eofcreate_address(contract_address, 0): Account.NONEXISTENT,
619631
}
620632
tx = Transaction(
621633
to=calling_address,
@@ -765,7 +777,8 @@ def test_reentrant_eofcreate(
765777
initcontainer = Container(
766778
sections=[
767779
Section.Code(
768-
Op.CALLDATALOAD(0)
780+
Op.SSTORE(slot_counter, Op.ADD(Op.SLOAD(slot_counter), 1))
781+
+ Op.CALLDATALOAD(0)
769782
+ Op.RJUMPI[len(reenter_code)]
770783
+ reenter_code
771784
+ Op.RETURNCODE[0](0, 0)
@@ -796,13 +809,17 @@ def test_reentrant_eofcreate(
796809
# inicode marked (!).
797810
# Storage in 0 should have the address from the outer EOFCREATE.
798811
# Storage in 1 should have 0 from the inner EOFCREATE.
812+
# For the created contract storage in `slot_counter` should be 1 as initcode executes only once
799813
post = {
800814
contract_address: Account(
801815
storage={
802816
0: compute_eofcreate_address(contract_address, 0),
803817
1: 0,
804818
}
805-
)
819+
),
820+
compute_eofcreate_address(contract_address, 0): Account(
821+
nonce=1, code=smallest_runtime_subcontainer, storage={slot_counter: 1}
822+
),
806823
}
807824
tx = Transaction(
808825
to=contract_address,

tests/osaka/eip7692_eof_v1/eip7873_tx_create/test_txcreate.py

-22
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ def test_simple_txcreate(state_test: StateTestFiller, pre: Alloc, tx_initcode_co
5757
tx = Transaction(
5858
to=contract_address,
5959
gas_limit=10_000_000,
60-
max_priority_fee_per_gas=10,
61-
max_fee_per_gas=10,
6260
sender=sender,
6361
initcodes=[smallest_initcode_subcontainer] * tx_initcode_count,
6462
)
@@ -104,8 +102,6 @@ def test_txcreate_then_dataload(
104102
tx = Transaction(
105103
to=contract_address,
106104
gas_limit=10_000_000,
107-
max_priority_fee_per_gas=10,
108-
max_fee_per_gas=10,
109105
sender=sender,
110106
initcodes=[small_auxdata_container],
111107
)
@@ -156,8 +152,6 @@ def test_txcreate_then_call(state_test: StateTestFiller, pre: Alloc, evm_code_ty
156152
tx = Transaction(
157153
to=contract_address,
158154
gas_limit=10_000_000,
159-
max_priority_fee_per_gas=10,
160-
max_fee_per_gas=10,
161155
sender=sender,
162156
initcodes=[callable_contract_initcode],
163157
)
@@ -224,8 +218,6 @@ def test_auxdata_variations(state_test: StateTestFiller, pre: Alloc, auxdata_byt
224218
tx = Transaction(
225219
to=contract_address,
226220
gas_limit=10_000_000,
227-
max_priority_fee_per_gas=10,
228-
max_fee_per_gas=10,
229221
sender=sender,
230222
initcodes=[initcode_subcontainer],
231223
)
@@ -282,8 +274,6 @@ def test_calldata(state_test: StateTestFiller, pre: Alloc):
282274
tx = Transaction(
283275
to=contract_address,
284276
gas_limit=10_000_000,
285-
max_priority_fee_per_gas=10,
286-
max_fee_per_gas=10,
287277
sender=sender,
288278
initcodes=[initcode_subcontainer],
289279
)
@@ -382,8 +372,6 @@ def test_txcreate_in_initcode(
382372
tx = Transaction(
383373
to=contract_address,
384374
gas_limit=10_000_000,
385-
max_priority_fee_per_gas=10,
386-
max_fee_per_gas=10,
387375
sender=sender,
388376
initcodes=[nested_initcode_subcontainer, smallest_initcode_subcontainer],
389377
)
@@ -445,8 +433,6 @@ def test_return_data_cleared(
445433
tx = Transaction(
446434
to=contract_address,
447435
gas_limit=10_000_000,
448-
max_priority_fee_per_gas=10,
449-
max_fee_per_gas=10,
450436
sender=sender,
451437
initcodes=[smallest_initcode_subcontainer],
452438
)
@@ -495,8 +481,6 @@ def test_address_collision(
495481
tx = Transaction(
496482
to=contract_address,
497483
gas_limit=300_000_000_000,
498-
max_priority_fee_per_gas=10,
499-
max_fee_per_gas=10,
500484
sender=sender,
501485
initcodes=[smallest_initcode_subcontainer],
502486
)
@@ -546,8 +530,6 @@ def test_txcreate_revert_eof_returndata(
546530
tx = Transaction(
547531
to=contract_address,
548532
gas_limit=1_000_000,
549-
max_priority_fee_per_gas=10,
550-
max_fee_per_gas=10,
551533
sender=sender,
552534
initcodes=[code_reverts_with_calldata],
553535
# Simplest possible valid EOF container, which is going to be
@@ -603,8 +585,6 @@ def test_txcreate_context(
603585
to=factory_address,
604586
gas_limit=200_000,
605587
value=value,
606-
max_priority_fee_per_gas=10,
607-
max_fee_per_gas=10,
608588
initcodes=[initcode],
609589
)
610590

@@ -688,8 +668,6 @@ def test_txcreate_memory_context(
688668
to=contract_address,
689669
gas_limit=200_000,
690670
sender=pre.fund_eoa(),
691-
max_priority_fee_per_gas=10,
692-
max_fee_per_gas=10,
693671
initcodes=[initcontainer],
694672
)
695673
state_test(env=env, pre=pre, post=post, tx=tx)

0 commit comments

Comments
 (0)