Skip to content

Commit 6203535

Browse files
winsvegamarioevzdanceratopz
authored
feat(fill,tests): add all static GeneralStateTestsFiller from ethereum/tests (#1442)
* feat(tests/static): all ethereum/tests state_test fillers fix(tests): Rename modules to comply with python naming system fix(tests): Mark stTimeConsuming as slow fix(tests): Skip deprecated/duplicated blob tests fix(tests/legacy): All state tests start on block 1 docs: Changelog fix(tests): Remove static blob tests altogether refactor: rename rename feat(tests): Add tests/static/README.md readme changes * Update docs/CHANGELOG.md Co-authored-by: danceratopz <[email protected]> * Update CHANGELOG.md --------- Co-authored-by: Mario Vega <[email protected]> Co-authored-by: danceratopz <[email protected]>
1 parent ab9817d commit 6203535

File tree

2,700 files changed

+416741
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,700 files changed

+416741
-0
lines changed

docs/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Test fixtures for use by clients are available for each release on the [Github r
2222

2323
-[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702): Test that DELEGATECALL to a 7702 target works as intended ([#1485](https://github.com/ethereum/execution-spec-tests/pull/1485)).
2424
-[EIP-2573](https://eips.ethereum.org/EIPS/eip-2537): Includes a BLS12 point generator, alongside additional coverage many of the precompiles ([#1350](https://github.com/ethereum/execution-spec-tests/pull/1350)).
25+
- ✨ Add all [`GeneralStateTests` from `ethereum/tests`](https://github.com/ethereum/tests/tree/7dc757ec132e372b6178a016b91f4c639f366c02/src/GeneralStateTestsFiller) to `execution-spec-tests` located now at [tests/legacy/state_tests](https://github.com/ethereum/execution-spec-tests/tree/main/tests/legacy/state_tests) ([#1442](https://github.com/ethereum/execution-spec-tests/pull/1442)).
2526

2627
## [v4.3.0](https://github.com/ethereum/execution-spec-tests/releases/tag/v4.3.0) - 2025-04-18
2728

tests/static/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Static Tests
2+
3+
This directory contains static test files that were originally located at [ethereum/tests](https://github.com/ethereum/tests/tree/develop/src). These files should not be modified directly.
4+
5+
## Important Policy
6+
7+
If you find a test that is broken or needs updating:
8+
9+
1. **DO NOT** modify the static test files directly.
10+
2. Instead, create or update the corresponding Python test in the appropriate `tests/<fork>` folder.
11+
3. Delete the original static test filler file(s).
12+
4. Open a PR containing the new tests and the static tests deletion, and make sure that there is no coverage drop.

tests/static/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Static State Tests Fillers from ethereum/tests repo."""
2+
3+
REFERENCE_SPEC_GIT_PATH = ""
4+
REFERENCE_SPEC_VERSION = ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Static State Tests Fillers from ethereum/tests repo."""
2+
3+
REFERENCE_SPEC_GIT_PATH = ""
4+
REFERENCE_SPEC_VERSION = ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# 10
2+
# Revert undoes transient storage writes from inner calls that successfully returned.
3+
# TSTORE(x, y), CALL(self, ...), CALL(self, ...), TSTORE(x, y + 1), RETURN, REVERT, TLOAD(x) returns y
4+
#
5+
# Expect slot 0 to have 5 from the first tstore & tload.
6+
# Expect slot 1 to have 0. Call was unsuccessful.
7+
# Expect slot 2 to have 1. Inner call was successful.
8+
# Expect slot 3 to have 5. Should load the value stored before the unsuccessful call.
9+
10+
10_revertUndoesStoreAfterReturn:
11+
_info:
12+
comment: Revert undoes the transient storage writes after a successful call.
13+
14+
env:
15+
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
16+
currentDifficulty: 0x20000
17+
currentNumber: 1
18+
currentTimestamp: 1000
19+
currentGasLimit: 0x10000000000000
20+
currentBaseFee: 10
21+
22+
pre:
23+
A00000000000000000000000000000000000000A:
24+
balance: 1000000000000000000
25+
nonce: 0
26+
code: |
27+
:yul {
28+
switch selector()
29+
30+
case 0x70ac643e { // doFirstCall()
31+
doFirstCall()
32+
}
33+
34+
case 0x76b85d23 { // doCallThenRevert()
35+
doCallThenRevert()
36+
}
37+
38+
case 0x4ccca553 { // doSuccessfulStore()
39+
doSuccessfulStore()
40+
}
41+
42+
function doFirstCall() {
43+
verbatim_2i_0o(hex"5D", 0, 5)
44+
45+
let v := verbatim_1i_1o(hex"5C", 0)
46+
sstore(0, v)
47+
48+
mstore(0, hex"76b85d23") // calls doCallThenRevert()
49+
let fail := call(gas(), address(), 0, 0, 32, 0, 32)
50+
51+
sstore(1, fail) // should be 0 (revert)
52+
sstore(2, mload(0)) // load 1 (successful call)
53+
54+
let val := verbatim_1i_1o(hex"5C", 0)
55+
sstore(3, val)
56+
}
57+
58+
59+
function doCallThenRevert() {
60+
mstore(0, hex"4ccca553") // calls doSuccessfulStore()
61+
let s := call(gas(), address(), 0, 0, 32, 0, 0)
62+
mstore(0, s)
63+
revert(0, 32)
64+
}
65+
66+
function doSuccessfulStore() {
67+
verbatim_2i_0o(hex"5D", 0, 6)
68+
}
69+
70+
function doReenter(fs) -> f {
71+
mstore(0, fs)
72+
f := call(gas(), address(), 0, 0, 32, 0, 0)
73+
}
74+
75+
function selector() -> s {
76+
let value := calldataload(0)
77+
s := shr(224, value)
78+
}
79+
}
80+
storage: { 0x01: 0xffff }
81+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
82+
balance: 1000000000000000000000
83+
code: "0x"
84+
nonce: 0
85+
storage: {}
86+
87+
transaction:
88+
data:
89+
- data: :abi doFirstCall()
90+
accessList: []
91+
gasLimit:
92+
- "400000"
93+
nonce: 0
94+
to: A00000000000000000000000000000000000000A
95+
value:
96+
- 0
97+
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
98+
maxPriorityFeePerGas: 0
99+
maxFeePerGas: 2000
100+
101+
expect:
102+
- network:
103+
- ">=Cancun"
104+
result:
105+
A00000000000000000000000000000000000000A:
106+
storage:
107+
0x00: 5
108+
0x01: 0
109+
0x02: 1
110+
0x03: 5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# 14
2+
# Transient storage cannot be manipulated in a nested static context: TSTORE(x, y), STATICCALL(self, ...), CALL(self, ...), TSTORE(x, z) reverts
3+
#
4+
# Expect slot 0 to have 10 from the first tstore & tload.
5+
# Expect slot 1 to have 0 (for revert).
6+
# Expect slot 2 to have 1 (for success).
7+
# Expect slot 3 to have 10 (original value).
8+
9+
14_revertAfterNestedStaticcall:
10+
_info:
11+
comment: Transient storage can't be manipulated from nested staticcall.
12+
13+
env:
14+
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
15+
currentDifficulty: 0x20000
16+
currentNumber: 1
17+
currentTimestamp: 1000
18+
currentGasLimit: 0x10000000000000
19+
currentBaseFee: 10
20+
21+
pre:
22+
A00000000000000000000000000000000000000A:
23+
balance: 1000000000000000000
24+
nonce: 0
25+
code: |
26+
:yul {
27+
switch selector()
28+
29+
case 0xf5f40590 { // doStoreAndStaticCall()
30+
doStoreAndStaticCall()
31+
}
32+
33+
case 0xf8dfc2d0 { // doCallToStore()
34+
doCallToStore()
35+
}
36+
37+
case 0x62fdb9be { // doStore()
38+
doStore()
39+
}
40+
41+
function doStoreAndStaticCall() {
42+
verbatim_2i_0o(hex"5D", 0, 10)
43+
44+
let v := verbatim_1i_1o(hex"5C", 0)
45+
sstore(0, v)
46+
47+
mstore(0, hex"f8dfc2d0") // doCallToStore()
48+
let success := staticcall(0xffff, address(), 0, 32, 0, 32)
49+
50+
sstore(1, mload(0)) // should be 0 from nested unsuccessful call
51+
sstore(2, success) // should be 1
52+
53+
let val := verbatim_1i_1o(hex"5C", 0)
54+
sstore(3, val)
55+
}
56+
57+
function doCallToStore() {
58+
mstore(0, hex"62fdb9be") // doStore()
59+
let f := call(gas(), address(), 0, 0, 32, 0, 0) // call with zero-value
60+
mstore(0, f)
61+
return(0, 32)
62+
}
63+
64+
function doStore() {
65+
verbatim_2i_0o(hex"5D", 0, 11) // will revert
66+
}
67+
68+
function selector() -> s {
69+
let value := calldataload(0)
70+
s := shr(224, value)
71+
}
72+
}
73+
storage: { 0x01: 0xffff }
74+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
75+
balance: 1000000000000000000000
76+
code: "0x"
77+
nonce: 0
78+
storage: {}
79+
80+
transaction:
81+
data:
82+
- data: :abi doStoreAndStaticCall()
83+
accessList: []
84+
gasLimit:
85+
- "400000"
86+
nonce: 0
87+
to: A00000000000000000000000000000000000000A
88+
value:
89+
- 0
90+
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
91+
maxPriorityFeePerGas: 0
92+
maxFeePerGas: 2000
93+
94+
expect:
95+
- network:
96+
- ">=Cancun"
97+
result:
98+
A00000000000000000000000000000000000000A:
99+
storage:
100+
0x00: 10
101+
0x01: 0
102+
0x02: 1
103+
0x03: 10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# 15
2+
# Transient storage cannot be DOS’d: CALL(self, ...), TSTORE(x, y), TSTORE(x + 1, y), TSTORE(x + 2, y), ... ,TSTORE(x + n, y), REVERT, TLOAD(x) returns 0 and runs in under 15 seconds
3+
#
4+
# Expect slot 0 to have 0. Call fails.
5+
# Expect slot 1 to have 0. Loading returns 0.
6+
7+
15_tstoreCannotBeDosd:
8+
_info:
9+
comment: Transient storage cannot be DOS’d.
10+
11+
env:
12+
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
13+
currentDifficulty: 0x20000
14+
currentNumber: 1
15+
currentTimestamp: 1000
16+
currentGasLimit: 0x10000000000000
17+
currentBaseFee: 10
18+
19+
pre:
20+
A00000000000000000000000000000000000000A:
21+
balance: 1000000000000000000
22+
nonce: 0
23+
code: |
24+
:yul {
25+
switch selector()
26+
27+
case 0x883264e8 { // doCall(uint)
28+
let n:= calldataload(4)
29+
doCall(n)
30+
}
31+
32+
case 0xf7d6c0eb { // doNStores(n)
33+
let n := calldataload(32)
34+
doNStores(n)
35+
}
36+
37+
function doCall(n) {
38+
mstore(0, hex"f7d6c0eb") // doNStores(n)
39+
mstore(32, n)
40+
let t := call(gas(), address(), 0, 0, 64, 0, 32)
41+
sstore(0, t) // should revert
42+
43+
sstore(2, mload(0))
44+
45+
let v := verbatim_1i_1o(hex"5C", 0)
46+
sstore(1, v)
47+
}
48+
49+
function doNStores(n) {
50+
let i
51+
for {i := 0 } lt(i, n) { i := add(i, 1) } {
52+
verbatim_2i_0o(hex"5D", i, 48)
53+
}
54+
mstore(0, i)
55+
revert(0, 32)
56+
}
57+
58+
function selector() -> s {
59+
let value := calldataload(0)
60+
s := shr(224, value)
61+
}
62+
}
63+
storage: { 0x00: 0xffff, 0x01: 0xffff }
64+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
65+
balance: 1000000000000000000000
66+
code: "0x"
67+
nonce: 0
68+
storage: {}
69+
70+
transaction:
71+
data:
72+
- data: :abi doCall(uint) 0x249F0
73+
accessList: []
74+
gasLimit:
75+
- "30000000"
76+
nonce: 0
77+
to: A00000000000000000000000000000000000000A
78+
value:
79+
- 0
80+
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
81+
maxPriorityFeePerGas: 0
82+
maxFeePerGas: 2000
83+
84+
expect:
85+
- network:
86+
- ">=Cancun"
87+
result:
88+
A00000000000000000000000000000000000000A:
89+
storage:
90+
0x00: 0
91+
0x01: 0
92+
0x02: 0x249F0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# 17
2+
# Tstore arbitrary value in arbitrary slot costs 100 gas : TSTORE(x, y) costs 100 gas.
3+
#
4+
# Expect storage slot 1 to be 100. Cost of tstore.
5+
6+
17_tstoreGas:
7+
_info:
8+
comment: Tstore arbitrary value in arbitrary slot costs 100 gas.
9+
10+
env:
11+
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
12+
currentDifficulty: 0x20000
13+
currentNumber: 1
14+
currentTimestamp: 1000
15+
currentGasLimit: 0x10000000000000
16+
currentBaseFee: 10
17+
18+
pre:
19+
A00000000000000000000000000000000000000A:
20+
balance: 1000000000000000000
21+
nonce: 0
22+
code: |
23+
:yul {
24+
let extraOpcodes := 7
25+
26+
// calculate tstore gas
27+
let g1 := gas()
28+
verbatim_2i_0o(hex"5D", 0, 3)
29+
let g2 := gas()
30+
sstore(1, sub(sub(g1, g2), extraOpcodes))
31+
}
32+
storage: {}
33+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
34+
balance: 1000000000000000000000
35+
code: "0x"
36+
nonce: 0
37+
storage: {}
38+
39+
transaction:
40+
data:
41+
- data: 0x
42+
accessList: []
43+
gasLimit:
44+
- "400000"
45+
nonce: 0
46+
to: A00000000000000000000000000000000000000A
47+
value:
48+
- 0
49+
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
50+
maxPriorityFeePerGas: 0
51+
maxFeePerGas: 2000
52+
53+
expect:
54+
- network:
55+
- ">=Cancun"
56+
result:
57+
A00000000000000000000000000000000000000A:
58+
storage:
59+
0x01: 100

0 commit comments

Comments
 (0)