Commit e7043cc
authored
feat(scripts): use dynamic addresses in ported static tests (#2695)
Convert all ported static tests under `tests/ported_static/` from hard-coded addresses (literal `Address(0x…)` and `EOA(key=…)`) to dynamic allocation (`pre.fund_eoa()`, `pre.deploy_contract()` without `address=`). Tests now behave like hand-written EEST tests, where the framework picks addresses at fill time. 68 of 2151 tests become runnable under the `execute` plugin against live networks (no `pre_alloc_mutable` marker).
Achieved without changing test semantics — verified by 39,002 / 39,002 trace comparisons equivalent under `exact-no-stack` against pre-conversion baseline traces.
### What changed
**`scripts/filler_to_python/analyzer.py`** — bulk of the work. New analyzer logic:
- Topological sort of contracts by bytecode address references; substitute known addresses with variable names (`addr_to_var`) in emitted Op expressions.
- Resolve CREATE-derived addresses in post-state storage and account references via `compute_create_address(...)` (depth 2, nonce 0–15).
- Coinbase pinning: any account whose address equals `env.current_coinbase` is kept hardcoded so the env's `fee_recipient` and the pre-state entry agree.
- Sender pinning when post-state has unresolvable addresses or address-like storage values (>2³² ints) — keeps CREATE addresses derivable from sender consistent with baseline.
- Short-PUSH detection: contracts referenced via `PUSH<20` (i.e. addresses with leading-zero bytes) are pinned to baseline addresses.
- Same for EOAs (precompile-touch case): EOAs referenced via short PUSH or hint-overridden into the precompile range (`<eoa:0x...01>`) are pinned literally at `0x01–0x10`.
- Computed call targets (`address=Op.ADD/MLOAD/CALLDATALOAD/...`) and address arithmetic trigger a global hardcoded fallback.
- `FORCE_HARDCODED_TESTS` allowlist (144 entries) for tests that fundamentally don't survive dynamic addresses (gas-precise tests, keccak-derived storage keys, cryptographic signatures in tx-data, CREATE2 collisions, structural pre-execution rejections).
- `needs_mutable_pre` flag — emitted only when `assert_mutable()` would actually fire (sender or any account hardcoded, sender funded with non-default nonce, or any contract emitted with `nonce=0`).
**`scripts/filler_to_python/ir.py`** — `use_dynamic` on `AccountIR`/`SenderIR`/`AccessListEntryIR`, `nonce` on `SenderIR`, `needs_mutable_pre` on `IntermediateTestModel`.
**`scripts/filler_to_python/templates/state_test.py.j2`** — conditional rendering: `pre.fund_eoa(amount=...)` / `pre.deploy_contract(...)` for dynamic tests, `EOA(key=...)` / `pre[var] = Account(...)` / `pre.deploy_contract(..., address=Address(...))` for hardcoded ones. `@pytest.mark.pre_alloc_mutable` is only emitted when `needs_mutable_pre`.
**`scripts/filler_to_python/render.py`** — `format_storage` handles string variable references; new context fields piped to the template.
**`tests/ported_static/`** — all 2151 test files regenerated. 14 `@manually-enhanced` files preserved as-is via the existing skip mechanism.
### Verification
| Check | Result |
|---|---|
| Regeneration | 2137 / 2151 OK + 14 skipped (manually-enhanced) |
| `just static` | clean |
| Full fill (CI mode) | 60,476 / 60,476 passed |
| Full fill `--traces` | 60,476 / 60,476 passed (depends on PR #2709 in `forks/amsterdam`) |
| `--verify-traces` `exact-no-stack` | **39,002 / 39,002 equivalent** |
> **Note:** The trace report shows 78 additional "divergences" on 3 STRUCTURAL tests (CREATE-collision / EIP-3607). These are spurious and tracked in #2758 — an asymmetry between in-memory and disk-loaded traces in the verify-traces machinery (extends #2709). The tests themselves pass, fixtures are byte-identical to baseline, and the comparison artifact is independent of this PR.1 parent 5a2cba1 commit e7043cc
2,037 files changed
Lines changed: 26845 additions & 33972 deletions
File tree
- scripts
- filler_to_python
- templates
- tests/ported_static
- stArgsZeroOneBalance
- stAttackTest
- stBadOpcode
- stBugs
- stCallCodes
- stCallCreateCallCodeTest
- stCallDelegateCodesCallCodeHomestead
- stCallDelegateCodesHomestead
- stCodeCopyTest
- stCodeSizeLimit
- stCreate2
- stCreateTest
- stDelegatecallTestHomestead
- stEIP1153_transientStorage
- stEIP150Specific
- stEIP150singleCodeGasPrices
- stEIP1559
- stEIP158Specific
- stEIP2930
- stEIP3651_warmcoinbase
- stEIP3855_push0
- stEIP3860_limitmeterinitcode
- stEIP4844_blobtransactions
- stEIP5656_MCOPY
- stExample
- stHomesteadSpecific
- stInitCodeTest
- stLogTests
- stMemExpandingEIP150Calls
- stMemoryStressTest
- stMemoryTest
- stNonZeroCallsTest
- stPreCompiledContracts2
- stPreCompiledContracts
- stQuadraticComplexityTest
- stRandom2
- stRandom
- stRecursiveCreate
- stRefundTest
- stReturnDataTest
- stRevertTest
- stSStoreTest
- stSelfBalance
- stShift
- stSolidityTest
- stSpecialTest
- stStackTests
- stStaticCall
- stStaticFlagEnabled
- stSystemOperationsTest
- stTimeConsuming
- stTransactionTest
- stTransitionTest
- stWalletTest
- stZeroCallsRevert
- stZeroCallsTest
- stZeroKnowledge
- vmArithmeticTest
- vmBitwiseLogicOperation
- vmIOandFlowOperations
- vmLogTest
- vmTests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| 113 | + | |
111 | 114 | | |
| 115 | + | |
112 | 116 | | |
113 | 117 | | |
114 | 118 | | |
| |||
136 | 140 | | |
137 | 141 | | |
138 | 142 | | |
| 143 | + | |
139 | 144 | | |
140 | 145 | | |
141 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| |||
271 | 275 | | |
272 | 276 | | |
273 | 277 | | |
| 278 | + | |
274 | 279 | | |
275 | 280 | | |
276 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
162 | 163 | | |
| 164 | + | |
163 | 165 | | |
164 | 166 | | |
165 | 167 | | |
| |||
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
179 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
180 | 188 | | |
181 | 189 | | |
182 | 190 | | |
| |||
205 | 213 | | |
206 | 214 | | |
207 | 215 | | |
208 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
209 | 219 | | |
| 220 | + | |
| 221 | + | |
210 | 222 | | |
211 | 223 | | |
212 | 224 | | |
213 | 225 | | |
214 | 226 | | |
215 | 227 | | |
216 | | - | |
| 228 | + | |
217 | 229 | | |
218 | 230 | | |
219 | 231 | | |
| |||
238 | 250 | | |
239 | 251 | | |
240 | 252 | | |
| 253 | + | |
241 | 254 | | |
| 255 | + | |
242 | 256 | | |
243 | 257 | | |
244 | 258 | | |
| |||
287 | 301 | | |
288 | 302 | | |
289 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
290 | 307 | | |
| 308 | + | |
291 | 309 | | |
292 | 310 | | |
293 | 311 | | |
| |||
357 | 375 | | |
358 | 376 | | |
359 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
360 | 381 | | |
| 382 | + | |
361 | 383 | | |
362 | 384 | | |
363 | 385 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
Lines changed: 1 addition & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | | - | |
62 | | - | |
63 | | - | |
| 60 | + | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
| |||
85 | 82 | | |
86 | 83 | | |
87 | 84 | | |
88 | | - | |
89 | 85 | | |
90 | 86 | | |
91 | 87 | | |
| |||
Lines changed: 1 addition & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | | - | |
62 | | - | |
63 | | - | |
| 60 | + | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
| |||
86 | 83 | | |
87 | 84 | | |
88 | 85 | | |
89 | | - | |
90 | 86 | | |
91 | 87 | | |
92 | 88 | | |
| |||
Lines changed: 1 addition & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | | - | |
62 | | - | |
63 | | - | |
| 60 | + | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
| |||
85 | 82 | | |
86 | 83 | | |
87 | 84 | | |
88 | | - | |
89 | 85 | | |
90 | 86 | | |
91 | 87 | | |
| |||
Lines changed: 1 addition & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | | - | |
62 | | - | |
63 | | - | |
| 60 | + | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
| |||
86 | 83 | | |
87 | 84 | | |
88 | 85 | | |
89 | | - | |
90 | 86 | | |
91 | 87 | | |
92 | 88 | | |
| |||
Lines changed: 1 addition & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | | - | |
62 | | - | |
63 | | - | |
| 60 | + | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
| |||
85 | 82 | | |
86 | 83 | | |
87 | 84 | | |
88 | | - | |
89 | 85 | | |
90 | 86 | | |
91 | 87 | | |
| |||
0 commit comments