Skip to content

Commit 39ba4c2

Browse files
committed
address comments
1 parent 1520ee1 commit 39ba4c2

File tree

5 files changed

+93
-95
lines changed

5 files changed

+93
-95
lines changed

converted-ethereum-tests.txt

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
([#440](https://github.com/ethereum/execution-spec-tests/pull/440))
2-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/01_tloadBeginningTxnFiller.yml
3-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/02_tloadAfterTstoreFiller.yml
4-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/03_tloadAfterStoreIs0Filler.yml
5-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/04_tloadAfterCallFiller.yml
6-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/05_tloadReentrancyFiller.yml
7-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/06_tstoreInReentrancyCallFiller.yml
8-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/07_tloadAfterReentrancyStoreFiller.yml
9-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/08_revertUndoesTransientStoreFiller.yml
10-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/09_revertUndoesAllFiller.yml
11-
..
12-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/11_tstoreDelegateCallFiller.yml
13-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/12_tloadDelegateCallFiller.yml
14-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/13_tloadStaticCallFiller.yml
15-
..
16-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/16_tloadGasFiller.yml
17-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/18_tloadAfterStoreFiller.yml
18-
..
19-
src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/20_oogUndoesTransientStoreInCallFiller.yml
2+
GeneralStateTests/Cancun/stEIP1153-transientStorage/01_tloadBeginningTxn.json
3+
GeneralStateTests/Cancun/stEIP1153-transientStorage/02_tloadAfterTstore.json
4+
GeneralStateTests/Cancun/stEIP1153-transientStorage/03_tloadAfterStoreIs0.json
5+
GeneralStateTests/Cancun/stEIP1153-transientStorage/04_tloadAfterCall.json
6+
GeneralStateTests/Cancun/stEIP1153-transientStorage/05_tloadReentrancy.json
7+
GeneralStateTests/Cancun/stEIP1153-transientStorage/06_tstoreInReentrancyCall.json
8+
GeneralStateTests/Cancun/stEIP1153-transientStorage/07_tloadAfterReentrancyStore.json
9+
GeneralStateTests/Cancun/stEIP1153-transientStorage/08_revertUndoesTransientStore.json
10+
GeneralStateTests/Cancun/stEIP1153-transientStorage/09_revertUndoesAll.json
2011

12+
GeneralStateTests/Cancun/stEIP1153-transientStorage/11_tstoreDelegateCall.json
13+
GeneralStateTests/Cancun/stEIP1153-transientStorage/12_tloadDelegateCall.json
14+
GeneralStateTests/Cancun/stEIP1153-transientStorage/13_tloadStaticCall.json
15+
16+
GeneralStateTests/Cancun/stEIP1153-transientStorage/16_tloadGas.json
17+
GeneralStateTests/Cancun/stEIP1153-transientStorage/18_tloadAfterStore.json
18+
19+
GeneralStateTests/Cancun/stEIP1153-transientStorage/20_oogUndoesTransientStoreInCall.json

tests/cancun/eip1153_tstore/test_basic_tload.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ def test_basic_tload_gasprice(
208208
(16_tloadGasFiller.yml)
209209
tload costs 100 gas same as a warm sload
210210
"""
211-
212211
slot_tload_nonzero_gas_price_result = 1
213212
slot_tload_zero_gas_price_result = 2
214213
slot_code_worked = 3

tests/cancun/eip1153_tstore/test_tload_calls.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
@pytest.mark.parametrize("call_type", [Op.CALL, Op.CALLCODE, Op.DELEGATECALL])
2626
def test_tload_calls(state_test: StateTestFiller, call_type: Op):
2727
"""
28-
Covered .json vectors:
28+
Ported .json vectors:
2929
3030
(04_tloadAfterCallFiller.yml)
3131
Loading a slot after a call to another contract is 0.
@@ -37,10 +37,10 @@ def test_tload_calls(state_test: StateTestFiller, call_type: Op):
3737
address_call = Address("B00000000000000000000000000000000000000B")
3838

3939
# Storage variables
40-
str_a_tload_after_subcall_result = 0
41-
str_a_subcall_result = 1
42-
str_b_subcall_tload_result = 2
43-
str_b_subcall_updated_tload_result = 3
40+
slot_a_tload_after_subcall_result = 0
41+
slot_a_subcall_result = 1
42+
slot_b_subcall_tload_result = 2
43+
slot_b_subcall_updated_tload_result = 3
4444

4545
def make_call(call_type: Op) -> bytes:
4646
if call_type == Op.DELEGATECALL or call_type == Op.STATICCALL:
@@ -54,23 +54,23 @@ def make_call(call_type: Op) -> bytes:
5454
nonce=0,
5555
code=Op.JUMPDEST()
5656
+ Op.TSTORE(0, 10)
57-
+ Op.SSTORE(str_a_subcall_result, make_call(call_type))
58-
+ Op.SSTORE(str_a_tload_after_subcall_result, Op.TLOAD(0)),
57+
+ Op.SSTORE(slot_a_subcall_result, make_call(call_type))
58+
+ Op.SSTORE(slot_a_tload_after_subcall_result, Op.TLOAD(0)),
5959
storage={
60-
str_a_subcall_result: 0xFF,
61-
str_a_tload_after_subcall_result: 0xFF,
60+
slot_a_subcall_result: 0xFF,
61+
slot_a_tload_after_subcall_result: 0xFF,
6262
},
6363
),
6464
address_call: Account(
6565
balance=7000000000000000000,
6666
nonce=0,
6767
code=Op.JUMPDEST()
68-
+ Op.SSTORE(str_b_subcall_tload_result, Op.TLOAD(0))
68+
+ Op.SSTORE(slot_b_subcall_tload_result, Op.TLOAD(0))
6969
+ Op.TSTORE(0, 20)
70-
+ Op.SSTORE(str_b_subcall_updated_tload_result, Op.TLOAD(0)),
70+
+ Op.SSTORE(slot_b_subcall_updated_tload_result, Op.TLOAD(0)),
7171
storage={
72-
str_b_subcall_tload_result: 0xFF,
73-
str_b_subcall_updated_tload_result: 0xFF,
72+
slot_b_subcall_tload_result: 0xFF,
73+
slot_b_subcall_updated_tload_result: 0xFF,
7474
},
7575
),
7676
TestAddress: Account(
@@ -86,18 +86,18 @@ def make_call(call_type: Op) -> bytes:
8686
post[address_to] = Account(
8787
storage={
8888
# other calls don't change context, there for tload updated in this account
89-
str_a_tload_after_subcall_result: 10 if call_type == Op.CALL else 20,
90-
str_a_subcall_result: 1,
89+
slot_a_tload_after_subcall_result: 10 if call_type == Op.CALL else 20,
90+
slot_a_subcall_result: 1,
9191
# since context unchanged the subcall works as if continued execution
92-
str_b_subcall_tload_result: 0 if call_type == Op.CALL else 10,
93-
str_b_subcall_updated_tload_result: 0 if call_type == Op.CALL else 20,
92+
slot_b_subcall_tload_result: 0 if call_type == Op.CALL else 10,
93+
slot_b_subcall_updated_tload_result: 0 if call_type == Op.CALL else 20,
9494
}
9595
)
9696

9797
post[address_call] = Account(
9898
storage={
99-
str_b_subcall_tload_result: 0 if call_type == Op.CALL else 0xFF,
100-
str_b_subcall_updated_tload_result: 20 if call_type == Op.CALL else 0xFF,
99+
slot_b_subcall_tload_result: 0 if call_type == Op.CALL else 0xFF,
100+
slot_b_subcall_updated_tload_result: 20 if call_type == Op.CALL else 0xFF,
101101
}
102102
)
103103

tests/cancun/eip1153_tstore/test_tload_reentrancy.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_tload_reentrancy(
3434
state_test: StateTestFiller, call_type: Op, call_return: Op, call_dest: bytes
3535
):
3636
"""
37-
Covered .json vectors:
37+
Ported .json vectors:
3838
3939
(05_tloadReentrancyFiller.yml)
4040
Reentrant calls access the same transient storage
@@ -44,10 +44,10 @@ def test_tload_reentrancy(
4444
empty_value = 0
4545

4646
# Storage variables
47-
str_tload_in_subcall_result = 1
48-
str_tload_after_subcall_result = 2
49-
str_subcall_worked = 3
50-
str_code_worked = 4
47+
slot_tload_in_subcall_result = 1
48+
slot_tload_after_subcall_result = 2
49+
slot_subcall_worked = 3
50+
slot_code_worked = 4
5151

5252
# Function names
5353
do_load = 1
@@ -76,19 +76,19 @@ def make_call(call_type: Op) -> bytes:
7676
action=Op.TSTORE(0, tload_value)
7777
+ Op.MSTORE(0, do_load)
7878
+ Op.MSTORE(32, 0xFF)
79-
+ Op.SSTORE(str_subcall_worked, make_call(call_type))
80-
+ Op.SSTORE(str_tload_in_subcall_result, Op.MLOAD(32))
81-
+ Op.SSTORE(str_tload_after_subcall_result, Op.TLOAD(0))
82-
+ Op.SSTORE(str_code_worked, 1),
79+
+ Op.SSTORE(slot_subcall_worked, make_call(call_type))
80+
+ Op.SSTORE(slot_tload_in_subcall_result, Op.MLOAD(32))
81+
+ Op.SSTORE(slot_tload_after_subcall_result, Op.TLOAD(0))
82+
+ Op.SSTORE(slot_code_worked, 1),
8383
),
8484
],
8585
default_action=b"",
8686
),
8787
storage={
88-
str_tload_in_subcall_result: 0xFF,
89-
str_tload_after_subcall_result: 0xFF,
90-
str_subcall_worked: 0xFF,
91-
str_code_worked: 0xFF,
88+
slot_tload_in_subcall_result: 0xFF,
89+
slot_tload_after_subcall_result: 0xFF,
90+
slot_subcall_worked: 0xFF,
91+
slot_code_worked: 0xFF,
9292
},
9393
),
9494
address_code: Account(
@@ -111,11 +111,11 @@ def make_call(call_type: Op) -> bytes:
111111
# if reentrancy
112112
post[address_to] = Account(
113113
storage={
114-
str_code_worked: 1,
114+
slot_code_worked: 1,
115115
# if call OOG, we fail to obtain the result
116-
str_tload_in_subcall_result: 0xFF if call_return == Om.OOG else tload_value,
117-
str_tload_after_subcall_result: tload_value,
118-
str_subcall_worked: (
116+
slot_tload_in_subcall_result: 0xFF if call_return == Om.OOG else tload_value,
117+
slot_tload_after_subcall_result: tload_value,
118+
slot_subcall_worked: (
119119
0 if call_return == Op.REVERT or call_return == Om.OOG else 1
120120
),
121121
}
@@ -124,8 +124,8 @@ def make_call(call_type: Op) -> bytes:
124124
# if external call
125125
post[address_to] = Account(
126126
storage={
127-
str_code_worked: 1,
128-
str_tload_in_subcall_result: (
127+
slot_code_worked: 1,
128+
slot_tload_in_subcall_result: (
129129
0xFF # if call OOG, we fail to obtain the result
130130
if call_return == Om.OOG
131131
# else delegate and callcode are working in the same context so tload works
@@ -136,8 +136,8 @@ def make_call(call_type: Op) -> bytes:
136136
)
137137
),
138138
# no subcall errors can change the tload result
139-
str_tload_after_subcall_result: 44,
140-
str_subcall_worked: (
139+
slot_tload_after_subcall_result: 44,
140+
slot_subcall_worked: (
141141
0 if call_return == Op.REVERT or call_return == Om.OOG else 1
142142
),
143143
}

tests/cancun/eip1153_tstore/test_tstore_reentrancy.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_tstore_reentrancy(
3434
state_test: StateTestFiller, call_type: Op, call_return: Op, call_dest: bytes
3535
):
3636
"""
37-
Covered .json vectors:
37+
Ported .json vectors:
3838
3939
(06_tstoreInReentrancyCallFiller.yml)
4040
Reentrant calls access the same transient storage
@@ -62,13 +62,13 @@ def test_tstore_reentrancy(
6262
tload_value_set_in_call = 90
6363

6464
# Storage cells
65-
str_tload_before_call = 0
66-
str_tload_in_subcall_result = 1
67-
str_tload_after_call = 2
68-
str_subcall_worked = 3
69-
str_tload_1_after_call = 4
70-
str_tstore_overwrite = 5
71-
str_code_worked = 6
65+
slot_tload_before_call = 0
66+
slot_tload_in_subcall_result = 1
67+
slot_tload_after_call = 2
68+
slot_subcall_worked = 3
69+
slot_tload_1_after_call = 4
70+
slot_tstore_overwrite = 5
71+
slot_code_worked = 6
7272

7373
# Function names
7474
do_tstore = 1
@@ -102,28 +102,28 @@ def make_call(call_type: Op) -> bytes:
102102
Case(
103103
condition=Op.EQ(Op.CALLDATALOAD(0), do_reenter),
104104
action=Op.TSTORE(0, tload_value_set_before_call)
105-
+ Op.SSTORE(str_tload_before_call, Op.TLOAD(0))
105+
+ Op.SSTORE(slot_tload_before_call, Op.TLOAD(0))
106106
+ Op.MSTORE(0, do_tstore)
107107
+ Op.MSTORE(32, 0xFF)
108-
+ Op.SSTORE(str_subcall_worked, make_call(call_type))
109-
+ Op.SSTORE(str_tload_in_subcall_result, Op.MLOAD(32))
110-
+ Op.SSTORE(str_tload_after_call, Op.TLOAD(0))
111-
+ Op.SSTORE(str_tload_1_after_call, Op.TLOAD(1))
108+
+ Op.SSTORE(slot_subcall_worked, make_call(call_type))
109+
+ Op.SSTORE(slot_tload_in_subcall_result, Op.MLOAD(32))
110+
+ Op.SSTORE(slot_tload_after_call, Op.TLOAD(0))
111+
+ Op.SSTORE(slot_tload_1_after_call, Op.TLOAD(1))
112112
+ Op.TSTORE(0, 50)
113-
+ Op.SSTORE(str_tstore_overwrite, Op.TLOAD(0))
114-
+ Op.SSTORE(str_code_worked, 1),
113+
+ Op.SSTORE(slot_tstore_overwrite, Op.TLOAD(0))
114+
+ Op.SSTORE(slot_code_worked, 1),
115115
),
116116
],
117117
default_action=b"",
118118
),
119119
storage={
120-
str_tload_before_call: 0xFF,
121-
str_tload_in_subcall_result: 0xFF,
122-
str_tload_after_call: 0xFF,
123-
str_subcall_worked: 0xFF,
124-
str_tload_1_after_call: 0xFF,
125-
str_tstore_overwrite: 0xFF,
126-
str_code_worked: 0xFF,
120+
slot_tload_before_call: 0xFF,
121+
slot_tload_in_subcall_result: 0xFF,
122+
slot_tload_after_call: 0xFF,
123+
slot_subcall_worked: 0xFF,
124+
slot_tload_1_after_call: 0xFF,
125+
slot_tstore_overwrite: 0xFF,
126+
slot_code_worked: 0xFF,
127127
},
128128
),
129129
address_code: Account(
@@ -156,46 +156,46 @@ def successful_delegate_or_callcode() -> bool:
156156
# if reentrancy
157157
post[address_to] = Account(
158158
storage={
159-
str_code_worked: 1,
160-
str_tload_before_call: tload_value_set_before_call,
161-
str_tload_in_subcall_result: (
159+
slot_code_worked: 1,
160+
slot_tload_before_call: tload_value_set_before_call,
161+
slot_tload_in_subcall_result: (
162162
# we fail to obtain in call result if it fails
163163
0xFF
164164
if call_type == Op.STATICCALL or call_return == Om.OOG
165165
else tload_value_set_in_call
166166
),
167167
# reentrant tstore overrides value in upper level
168-
str_tload_after_call: (
168+
slot_tload_after_call: (
169169
tload_value_set_before_call if failing_calls() else tload_value_set_in_call
170170
),
171-
str_tload_1_after_call: 0 if failing_calls() else 12,
172-
str_tstore_overwrite: 50,
171+
slot_tload_1_after_call: 0 if failing_calls() else 12,
172+
slot_tstore_overwrite: 50,
173173
# tstore in static call not allowed
174-
str_subcall_worked: 0 if failing_calls() else 1,
174+
slot_subcall_worked: 0 if failing_calls() else 1,
175175
}
176176
)
177177
else:
178178
post[address_to] = Account(
179179
# if external call
180180
storage={
181-
str_code_worked: 1,
182-
str_tload_before_call: tload_value_set_before_call,
183-
str_tload_in_subcall_result: (
181+
slot_code_worked: 1,
182+
slot_tload_before_call: tload_value_set_before_call,
183+
slot_tload_in_subcall_result: (
184184
# we fail to obtain in call result if it fails
185185
0xFF
186186
if call_type == Op.STATICCALL or call_return == Om.OOG
187187
else tload_value_set_in_call
188188
),
189189
# external tstore overrides value in upper level only in delegate and callcode
190-
str_tload_after_call: (
190+
slot_tload_after_call: (
191191
tload_value_set_in_call
192192
if successful_delegate_or_callcode()
193193
else tload_value_set_before_call
194194
),
195-
str_tload_1_after_call: 12 if successful_delegate_or_callcode() else 0,
196-
str_tstore_overwrite: 50,
195+
slot_tload_1_after_call: 12 if successful_delegate_or_callcode() else 0,
196+
slot_tstore_overwrite: 50,
197197
# tstore in static call not allowed, reentrancy means external call here
198-
str_subcall_worked: 0 if failing_calls() else 1,
198+
slot_subcall_worked: 0 if failing_calls() else 1,
199199
}
200200
)
201201

0 commit comments

Comments
 (0)