2424 slot_calldata ,
2525 slot_code_worked ,
2626 slot_create_address ,
27+ slot_data_load ,
2728 slot_last_slot ,
2829 slot_returndata_size ,
2930 smallest_initcode_subcontainer ,
3031 smallest_runtime_subcontainer ,
3132 value_canary_to_be_overwritten ,
3233 value_code_worked ,
34+ value_long_value ,
3335)
3436from .spec import EOFCREATE_FAILURE
3537
@@ -54,7 +56,6 @@ def test_simple_eofcreate(
5456 ),
5557 Section .Container (container = smallest_initcode_subcontainer ),
5658 ],
57- data = b"abcdef" ,
5859 ),
5960 storage = {0 : 0xB17D }, # a canary to be overwritten
6061 )
@@ -76,6 +77,54 @@ def test_simple_eofcreate(
7677 state_test (env = env , pre = pre , post = post , tx = tx )
7778
7879
80+ def test_eofcreate_then_dataload (
81+ state_test : StateTestFiller ,
82+ pre : Alloc ,
83+ ):
84+ """Verifies that a contract returned with auxdata does not overwrite the parent data."""
85+ env = Environment ()
86+ sender = pre .fund_eoa ()
87+ small_auxdata_container = Container (
88+ sections = [
89+ Section .Code (code = Op .RETURNCONTRACT [0 ](0 , 32 )),
90+ Section .Container (container = smallest_runtime_subcontainer ),
91+ ],
92+ )
93+ contract_address = pre .deploy_contract (
94+ code = Container (
95+ sections = [
96+ Section .Code (
97+ code = Op .SSTORE (0 , Op .EOFCREATE [0 ](0 , 0 , 0 , 0 ))
98+ + Op .SSTORE (slot_data_load , Op .DATALOAD (0 ))
99+ + Op .STOP ,
100+ ),
101+ Section .Container (
102+ container = small_auxdata_container ,
103+ ),
104+ Section .Data (data = value_long_value ),
105+ ],
106+ ),
107+ storage = {slot_data_load : value_canary_to_be_overwritten },
108+ )
109+
110+ post = {
111+ contract_address : Account (
112+ storage = {
113+ 0 : compute_eofcreate_address (contract_address , 0 , small_auxdata_container ),
114+ slot_data_load : value_long_value ,
115+ }
116+ )
117+ }
118+ tx = Transaction (
119+ to = contract_address ,
120+ gas_limit = 10_000_000 ,
121+ gas_price = 10 ,
122+ protected = False ,
123+ sender = sender ,
124+ )
125+ state_test (env = env , pre = pre , post = post , tx = tx )
126+
127+
79128def test_eofcreate_then_call (
80129 state_test : StateTestFiller ,
81130 pre : Alloc ,
0 commit comments