|
23 | 23 | slot_call_result,
|
24 | 24 | slot_code_should_fail,
|
25 | 25 | slot_code_worked,
|
| 26 | + slot_counter, |
26 | 27 | slot_create_address,
|
27 | 28 | slot_max_depth,
|
28 | 29 | slot_returndata,
|
@@ -87,7 +88,8 @@ def test_initcode_revert(state_test: StateTestFiller, pre: Alloc, revert: bytes)
|
87 | 88 | slot_returndata: revert,
|
88 | 89 | slot_code_worked: value_code_worked,
|
89 | 90 | }
|
90 |
| - ) |
| 91 | + ), |
| 92 | + compute_eofcreate_address(contract_address, 0): Account.NONEXISTENT, |
91 | 93 | }
|
92 | 94 | tx = Transaction(
|
93 | 95 | to=contract_address,
|
@@ -125,7 +127,8 @@ def test_initcode_aborts(
|
125 | 127 | slot_create_address: EOFCREATE_FAILURE,
|
126 | 128 | slot_code_worked: value_code_worked,
|
127 | 129 | }
|
128 |
| - ) |
| 130 | + ), |
| 131 | + compute_eofcreate_address(contract_address, 0): Account.NONEXISTENT, |
129 | 132 | }
|
130 | 133 | tx = Transaction(
|
131 | 134 | to=contract_address,
|
@@ -215,15 +218,19 @@ def test_eofcreate_deploy_sizes(
|
215 | 218 | # Storage in 0 should have the address,
|
216 | 219 | # Storage 1 is a canary of 1 to make sure it tried to execute, which also covers cases of
|
217 | 220 | # data+code being greater than initcode_size_max, which is allowed.
|
| 221 | + success = target_deploy_size <= MAX_BYTECODE_SIZE |
218 | 222 | post = {
|
219 | 223 | contract_address: Account(
|
220 | 224 | storage={
|
221 | 225 | slot_create_address: compute_eofcreate_address(contract_address, 0)
|
222 |
| - if target_deploy_size <= MAX_BYTECODE_SIZE |
| 226 | + if success |
223 | 227 | else EOFCREATE_FAILURE,
|
224 | 228 | slot_code_worked: value_code_worked,
|
225 | 229 | }
|
226 |
| - ) |
| 230 | + ), |
| 231 | + compute_eofcreate_address(contract_address, 0): Account() |
| 232 | + if success |
| 233 | + else Account.NONEXISTENT, |
227 | 234 | }
|
228 | 235 | tx = Transaction(
|
229 | 236 | to=contract_address,
|
@@ -304,15 +311,19 @@ def test_auxdata_size_failures(state_test: StateTestFiller, pre: Alloc, auxdata_
|
304 | 311 |
|
305 | 312 | # Storage in 0 will have address in first test, 0 in all other cases indicating failure
|
306 | 313 | # Storage 1 in 1 is a canary to see if EOFCREATE opcode halted
|
| 314 | + success = deployed_container_size <= MAX_BYTECODE_SIZE |
307 | 315 | post = {
|
308 | 316 | contract_address: Account(
|
309 | 317 | storage={
|
310 | 318 | slot_create_address: compute_eofcreate_address(contract_address, 0)
|
311 |
| - if deployed_container_size <= MAX_BYTECODE_SIZE |
| 319 | + if success |
312 | 320 | else 0,
|
313 | 321 | slot_code_worked: value_code_worked,
|
314 | 322 | }
|
315 |
| - ) |
| 323 | + ), |
| 324 | + compute_eofcreate_address(contract_address, 0): Account() |
| 325 | + if success |
| 326 | + else Account.NONEXISTENT, |
316 | 327 | }
|
317 | 328 |
|
318 | 329 | tx = Transaction(
|
@@ -615,7 +626,8 @@ def test_static_flag_eofcreate(
|
615 | 626 | else LEGACY_CALL_FAILURE,
|
616 | 627 | slot_code_worked: value_code_worked,
|
617 | 628 | }
|
618 |
| - ) |
| 629 | + ), |
| 630 | + compute_eofcreate_address(contract_address, 0): Account.NONEXISTENT, |
619 | 631 | }
|
620 | 632 | tx = Transaction(
|
621 | 633 | to=calling_address,
|
@@ -765,7 +777,8 @@ def test_reentrant_eofcreate(
|
765 | 777 | initcontainer = Container(
|
766 | 778 | sections=[
|
767 | 779 | Section.Code(
|
768 |
| - Op.CALLDATALOAD(0) |
| 780 | + Op.SSTORE(slot_counter, Op.ADD(Op.SLOAD(slot_counter), 1)) |
| 781 | + + Op.CALLDATALOAD(0) |
769 | 782 | + Op.RJUMPI[len(reenter_code)]
|
770 | 783 | + reenter_code
|
771 | 784 | + Op.RETURNCODE[0](0, 0)
|
@@ -796,13 +809,17 @@ def test_reentrant_eofcreate(
|
796 | 809 | # inicode marked (!).
|
797 | 810 | # Storage in 0 should have the address from the outer EOFCREATE.
|
798 | 811 | # 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 |
799 | 813 | post = {
|
800 | 814 | contract_address: Account(
|
801 | 815 | storage={
|
802 | 816 | 0: compute_eofcreate_address(contract_address, 0),
|
803 | 817 | 1: 0,
|
804 | 818 | }
|
805 |
| - ) |
| 819 | + ), |
| 820 | + compute_eofcreate_address(contract_address, 0): Account( |
| 821 | + nonce=1, code=smallest_runtime_subcontainer, storage={slot_counter: 1} |
| 822 | + ), |
806 | 823 | }
|
807 | 824 | tx = Transaction(
|
808 | 825 | to=contract_address,
|
|
0 commit comments