Skip to content

refactor(tests): drop pre_alloc_mutable from stRandom tests - #3999

Draft
marioevz wants to merge 13 commits into
ethereum:forks/bogotafrom
marioevz:finalize-ported-static-random
Draft

marioevz wants to merge 13 commits into
ethereum:forks/bogotafrom
marioevz:finalize-ported-static-random

Conversation

@marioevz

Copy link
Copy Markdown
Member

Description

Warning

This PR was AI-produced. I need to manually review it before marking it ready for review.

Part of finalizing the tests/ported_static/ port: cleanup to reduce pre-alloc groups and remove pre_alloc_mutable where not needed. Files are disjoint from the other finalize-ported-static-* PRs, so each can be reviewed and merged independently.

  • Drop pre_alloc_mutable and pinned addresses from stRandom/stRandom2.
  • Run 25 Prague-only tests on all forks.
  • Assert the outcome of stRandom 173 and stRandom2 643, which previously checked nothing meaningful.
  • Remove byte-identical duplicate tests and the high block gas limit from stRandom2 644.

Filled on all forks through Bogota.

Related Issues or PRs

N/A.

Checklist

  • Ran fast static checks to avoid CI fails, see Code Standards & Verifying Changes: just static
  • PR title has the form <type>(<area>): <description>, where <type> and <area> come from an appropriate C-<type>, respectively A-<area>, label. The title should match the target squash commit message.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

Remove the pre_alloc_mutable marker from all 22 mutable stRandom and
stRandom2 tests; none depends on a fixed address, nonce or collision.

- Legacy coinbase-contract layout (107, 173, 246, 263, 362, 367, 372,
  41, 64, 66, 437, 473, 545, 564): fund the sender with fund_eoa(),
  deploy the coinbase and target contracts at generated addresses, drop
  the redundant number/timestamp/base_fee env fields. Code that pushes
  the coinbase address as data either keeps the original literal or
  derives the post from the deployed address (107, 246, 545).
- 144, 184, 642, 645, 646: delete unused pre-funded accounts with
  non-zero nonces.
- 643, 644: self-references use Op.ADDRESS.
- 384: fund_eoa(), drop fixed address, nonces, gas price and env.

All 22 tests now join the main pre-alloc group.
These tests were capped at Prague only because the tx gas limit
(2e8-2e9) exceeds the Osaka transaction gas limit cap. Their outcome
does not depend on the extra gas: set the tx gas limit to 2**24 and drop
the HIGH_GAS_LIMIT block gas limit, which also moves them into the main
pre-alloc group.

stRandom 36, 308 and stRandom2 476, 498 stay Prague-only: their post
state changes with the lower gas limit. stRandom 263 needs its
2**63-1 block gas limit and stays Prague-only as well.
- stRandom 173: the contract self-destructs to 0x6BAC...8E4A, but the
  post only checked that the beneficiary has no code or nonce. Assert it
  receives the tx value. Mutation check: tx value 0 now fails.
- stRandom2 643: the creation tx returns ~1 MB out of bounds of the
  init code, which must fail, but nothing asserted it. Assert the
  created address does not exist. Mutation check: RETURN(0, 0x10) now
  fails.
Ten sets of stRandom/stRandom2 tests port to byte-identical code, pre,
tx and post. Keep one test per set and list every source filler in its
ported_from marker.

- stRandom 111 <- stRandom2 560
- stRandom 146 <- stRandom2 632
- stRandom 151 <- stRandom2 456
- stRandom 163 <- stRandom 326
- stRandom 260 <- stRandom2 469
- stRandom 4 <- stRandom 335, stRandom2 387
- stRandom 53 <- stRandom 341, stRandom2 448, stRandom2 589
- stRandom 36 <- stRandom2 476
- stRandom2 641 <- stRandom2 randomStatetest
- stRandom2 410 <- stRandom2 582

Removed:
- tests/ported_static/stRandom/test_random_statetest326.py
- tests/ported_static/stRandom/test_random_statetest335.py
- tests/ported_static/stRandom/test_random_statetest341.py
- tests/ported_static/stRandom2/test_random_statetest.py
- tests/ported_static/stRandom2/test_random_statetest387.py
- tests/ported_static/stRandom2/test_random_statetest448.py
- tests/ported_static/stRandom2/test_random_statetest456.py
- tests/ported_static/stRandom2/test_random_statetest469.py
- tests/ported_static/stRandom2/test_random_statetest476.py
- tests/ported_static/stRandom2/test_random_statetest560.py
- tests/ported_static/stRandom2/test_random_statetest582.py
- tests/ported_static/stRandom2/test_random_statetest589.py
- tests/ported_static/stRandom2/test_random_statetest632.py
The tx runs with ~49k gas against a precompile; the HIGH_GAS_LIMIT
block gas limit only split it into its own pre-alloc group.
Drop deploy_contract(nonce=1) and Transaction(data=Bytes("")), which
are the defaults.
@marioevz marioevz added this to the Finalize Ported-Static milestone Nov 14, 2026
@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.10%. Comparing base (4c8ae33) to head (1012cc2).
⚠️ Report is 12 commits behind head on forks/bogota.

Additional details and impacted files
@@              Coverage Diff              @@
##           forks/bogota    #3999   +/-   ##
=============================================
  Coverage         95.10%   95.10%           
=============================================
  Files               673      673           
  Lines             40904    40904           
  Branches           3778     3778           
=============================================
  Hits              38903    38903           
  Misses             1393     1393           
  Partials            608      608           
Flag Coverage Δ
unittests 95.10% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danceratopz danceratopz added the A-tests Area: Consensus tests. label Nov 17, 2026

@spencer-tb spencer-tb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! AI Swarm Review, 3x rotation of 10 fresh agents, findings re-checked by fills, traces and spec mutants, small things inline :)

Checked: the dedups against the fillers, an EELS trace of each test from Cancun to Bogota, a full-range fill, a fill with gas_limit dropped, where 163, 418, 547 and 583 succeed on Cancun and Prague (47.7M to 113.7M gas, under the 120M default), and spec mutants of try/catch rules against base.

@danceratopz danceratopz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Spencer already found that 163, 185, 418, 547 and 583 now run out of gas; I agree and replied on his threads. What's left from my side is clean-up.

No case dropped: the touched files have 259 base cases, 99 byte-identical in the PR and 160 changed, and every filler is still used. The 13 deleted files are exact duplicates of their survivors, and Cancun traces of the 22 pre_alloc_mutable tests match the base (384 differs only in one LOG1 size, same post).

My agent ran the same checks as described in the #3997 review.

Area: readability
Priority: Minor

All 55 files left at the head still carry # Source: raw hex comments that only repeat the Op code below them (106 blocks, 132 at the base), and some quote stale placeholders such as <contract:0x945304eb...> for what is now the deployed coinbase. Suggest dropping them. 6 contracts are still raw bytes.fromhex(...) (stRandom 4, 111, 151, 163, 173 and stRandom2 547), and stRandom2/test_random_statetest647.py still passes data=Bytes(""), which the last commit removed from 384 and 639. The comment and hex parts could be a follow-up PR.

Details

Files that still carry blocks:

  • stRandom: 4, 33, 36, 41, 42, 48, 53, 64, 66, 107, 111, 144, 146, 150, 151, 154, 159, 163, 173, 178, 184, 185, 226, 246, 260, 263, 286, 306, 362, 367, 372, 378, 384
  • stRandom2: 410, 418, 437, 458, 467, 473, 507, 510, 545, 547, 554, 564, 583, 618, 636, 639, 641, 642, 643, 644, 645, 646

Comments quoting the old fixed coinbase 0x945304eb... while the code uses the deployed coinbase (already so at the base): stRandom 53, 226, 286 and stRandom2 410, 418, 507, 510, 583, 618, 641. The 11 recursive tests quote <contract:target:0x095e7b...>. 107 is the one the PR changed, noted inline.

Raw-hex code: 4, 151, 163, 173 and 547 end in a truncated PUSH, which is likely why the converter kept them raw. 111 decodes cleanly, so it is the easy one to convert.

No other leftovers of the kinds the PR removes are in the two directories: no pre_alloc_mutable, address pins, deploy_contract(nonce=1) or legacy env fields, and no two remaining files are code-identical.

Two smaller things are inline.

Tests 163, 418, 547 and 583 need 47.7M to 113.7M gas for their final
LOG and 185 needs about 203M, all above the 2**24 transaction gas cap.
Restore valid_until Prague and drop the capped gas_limit so the LOG
succeeds again on Cancun and Prague; 185 keeps its high block gas
limit.
The implicit gas limit already clamps to the fork's transaction gas
cap.
Execute deploys every contract at nonce 1.
@danceratopz danceratopz mentioned this pull request Nov 20, 2026
13 of 27 tasks

@danceratopz danceratopz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes since the last review, Mario. I asked my agent to re-check the new head (case mapping, fixture comparison, traces) and no case was dropped; the method is the same as in the #3997 review.

Comments inline.

)
@pytest.mark.valid_from("Cancun")
@pytest.mark.pre_alloc_mutable
@pytest.mark.execute(pytest.mark.skip(reason="needs a high-nonce contract"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as here: stRandom 347 deploys target at nonce 233 and addr at nonce 89 and checks both in post, so it will fail in execute too, and its skip should match this one. I asked my agent to scan stRandom and stRandom2 for other high-nonce deploys, and 347 is the only one left without the skip (647 only checks the sender). It isn't in this PR, so happy for it to be a follow-up.

Suggested diff (fills on Cancun to Bogota: 5 passed)
diff --git a/tests/ported_static/stRandom/test_random_statetest347.py b/tests/ported_static/stRandom/test_random_statetest347.py
index 295db1c944..0e16c11d5a 100644
--- a/tests/ported_static/stRandom/test_random_statetest347.py
+++ b/tests/ported_static/stRandom/test_random_statetest347.py
@@ -25,6 +25,7 @@ REFERENCE_SPEC_VERSION = "N/A"
     ["state_tests/stRandom/randomStatetest347Filler.json"],
 )
 @pytest.mark.valid_from("Cancun")
+@pytest.mark.execute(pytest.mark.skip(reason="needs a high-nonce contract"))
 def test_random_statetest347(
     state_test: StateTestFiller,
     pre: Alloc,

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tests Area: Consensus tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants