Skip to content

feat(test-types,test-specs,tests): add a BlockReward post term and merge zero/non-zero value call tests - #3997

Merged
marioevz merged 16 commits into
ethereum:forks/bogotafrom
marioevz:finalize-ported-static-base
Dec 2, 2026
Merged

marioevz merged 16 commits into
ethereum:forks/bogotafrom
marioevz:finalize-ported-static-base

Conversation

@marioevz

@marioevz marioevz commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Description

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

Framework

  • Add a BlockReward(tx) balance term next to GasFee/Tip/BlobFee. It resolves to fork.get_reward() in blockchain fixtures and to zero in state fixtures (and post-Merge), so fee-recipient checks can be written once as Tip(tx, gas=...) + BlockReward(tx) on every fork. Tip and BlockReward share a FeeRecipientTerm base for the recipient check.

Yes, a framework feature is riding along in a "refactor(tests)" PR. We
were promised a test cleanup; nobody said what the cleanup was allowed
to bring home. Let's see if the reviewers like it 🤞

Bold move, let's see if it pays off

Merged / parametrized tests

  • stZeroCallsTest, stZeroCallsRevert, stNonZeroCallsTest: per-opcode/per-recipient files merged into test_zero_value.py, test_zero_value_oog_revert.py and test_non_zero_value_call.py. The suicide and transaction-call tests also cover the nonexistent recipient without a state gas reservoir.
  • stReturnDataTest: returndatacopy_after_failing_{callcode,delegatecall,staticcall} merged into test_returndatacopy_after_failing_call.py (CALL/CALLCODE/DELEGATECALL/STATICCALL × INVALID callee / out-of-gas callee). test_revert_ret_data_size.py rewritten; test_too_long_return_data_copy.py parametrized on the returned length and copied range, with the outcome derived.
  • stRefundTest: refund_call_to_suicide_{no_storage,storage,twice} merged into test_refund_call_to_suicide.py.
  • stEIP1153_transientStorage: test_trans_storage_ok.py split into one test per scenario. Both transient storage tests rewritten from the filler Yul with Conditional/Switch, so no hardcoded jump targets or addresses remain.
  • stPreCompiledContracts/test_modexp_tests.py and stZeroKnowledge/test_pairing_test.py: parametrized on their inputs, with expected results derived (pow(), pairing result) and gas measured or bounded instead of pinned.

Changes to what is tested

Beyond restructuring, three changes alter what the ported tests check compared with their upstream fillers:

  • stZeroCallsTest: the ToEmpty_Paris and ToNonZeroBalance fillers differ only in the callee's balance (10 and 100), so both are now a single funded_eoa recipient case (an EOA funded with 1 wei) in test_zero_value.py, test_zero_value_suicide.py and test_zero_value_transaction_call.py.
  • returndatacopy_after_failing_delegatecall: the upstream filler sends its transaction to an account without code, so the contract doing the DELEGATECALL and RETURNDATACOPY never runs and the expected storage holds trivially. test_returndatacopy_after_failing_call.py sends the transaction to the contract, so the copy after the failing delegatecall is actually exercised.
  • test_zero_value and test_non_zero_value_call: the fillers stored GAS before the call, which only pins the intrinsic gas. The call is now measured with CodeGasMeasure and checked against gas_cost(fork) (minus the call stipend in test_non_zero_value_call). The call's success flag is stored inside the measured window, since a call that wrongly fails costs the same gas as a successful one into an empty callee or EOA.

General cleanup

  • Expected gas comes from framework calculators (gas_cost, refund, max_refund_quotient, inner_call_cost, intrinsic calculators) instead of Cancun literals plus hand-computed fork deltas; out-of-gas budgets are derived so each scenario holds on every fork.
  • Removed d/g/v indexes and resolve_expect_post, hardcoded addresses, env, leftover ABI selectors, yul/lll comments, default kwargs, and transaction fields nothing depends on (gas_price, empty access lists, unused calldata, legacy gas limits). Sender balances use balance_change=-GasFee(...).
  • Restored the coinbase checks the earlier pass had dropped, using Tip + BlockReward, with an execute skip marker.
  • Lowered valid_from wherever possible: most refund and non-zero-call tests now start at Frontier, and the return-data, modexp and pairing tests at Byzantium or Berlin. Cancun+ fixtures were verified byte-identical wherever the bytecode didn't change.

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-->

@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.37%. Comparing base (1576df3) to head (8e28eb6).

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/bogota    #3997      +/-   ##
================================================
+ Coverage         95.31%   95.37%   +0.05%     
================================================
  Files               677      677              
  Lines             41907    41907              
  Branches           3939     3939              
================================================
+ Hits              39944    39969      +25     
+ Misses             1370     1359      -11     
+ Partials            593      579      -14     
Flag Coverage Δ
unittests 95.36% <ø> (+0.05%) ⬆️

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: every ported_from entry against the fillers, the refund gas constants, a leading-zero address fill, a full-range fill with the eoa_with_storage marker dropped, 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 to me. No test case is lost and the fixes are right. My main suggestion is to make test_revert_ret_data_size check that the call or create really fails, and to drop the legacy comments that no longer match the merged code.

No case dropped: on each fork from Cancun to Bogota every base case maps to a case at this head (334 to 323 per fork through Prague, 207 to 196 after), 13 per fork fold into funded_eoa and 2 funded_caller cases are new. Gas used is unchanged outside the five rewritten tests, and my agent traced the changed cases on Cancun: all behave as intended, apart from the gap below.

Traces (Cancun), base vs this head
  • test_zero_value, test_zero_value_oog_revert, test_non_zero_value_call[call-caller_without_balance]: same call outcomes and storage as the base cases; only the gas measurement differs, as intended.
  • test_returndatacopy_after_failing_delegatecall: base runs no code (21,000 gas). This head: DELEGATECALL fails, then RETURNDATACOPY halts on an out-of-bounds read.
  • test_trans_storage_ok, test_refund_call_a_oog: identical call, SSTORE and TSTORE sequences.
  • The 127 modexp cases match on calldata, result and gas used.

Main points: see the inline comments on stReturnDataTest/test_revert_ret_data_size.py line 117 and on the legacy comments in the merged stZeroCallsTest, stNonZeroCallsTest and stZeroCallsRevert files.

Area: documentation
Priority: Minor

Three changes alter what is tested and should be in the PR body, so the squash commit tells the story:

  • The ToEmpty_Paris (10 wei) and ToNonZeroBalance (100 wei) fillers become one funded_eoa case in all seven merged files, 13 fewer cases per fork. ported_from still lists every filler, so filler counts don't show it.
  • test_returndatacopy_after_failing_delegatecall now sends the transaction to the contract. The upstream filler targets 0x0f572e..., which has no code, so the base test ran nothing.
  • test_zero_value and test_non_zero_value_call measure gas with CodeGasMeasure, and test_non_zero_value_call adds funded_caller cases.

Area: readability
Priority: Minor

Clean-up of the same kind left in the touched directories, could be a follow-up PR:

  • test_non_zero_value_call.py could be two more cases in stNonZeroCallsTest/test_non_zero_value.py, which already merges the other NonZeroValue_* fillers the same way (needs a caller balance parameter to keep caller_without_balance).
  • stReturnDataTest: the returndatacopy/returndatasize after_failing/after_successful files for callcode, delegatecall and staticcall differ mostly in the opcode and could be parametrized.
  • 31 untouched stReturnDataTest files still pass data=Bytes("").
  • Legacy # Source: blocks that still match their code stay in 35 of the 37 touched files at this head (99 to 60 blocks, 608 to 533 comment lines). The ones that no longer match are inline comments. No raw hex bytecode is left.
Other leftovers (found by search only, not checked by fill)
  • stSpecialTest: pre_alloc_mutable in test_block504980.py, test_eoa_empty_paris.py, test_failed_tx_xcf416c53_paris.py, test_tx_e1c174e2.py; the fee_recipient, prev_randao, base_fee_per_gas=10 environment this PR drops in stRefundTest is still set in test_deployment_error.py, test_selfdestruct_eip2929.py, test_stack_depth_limit_sec.py.
  • stExample/test_add11.py: the environment this PR drops from test_add11_yml.py; test_add11.py and test_yul_example.py keep data=Bytes("").
  • stPreCompiledContracts/test_precomps_eip2929_cancun.py: a pinned address and the same environment.

Spencer's inline comments on nonce=0 and the pre_alloc_mutable marker match what my agent found; I replied there.

How my agent checked all ten finalize-ported-static PRs (#3997 to #4006)

I asked my agent to review each PR in its own session, against the shared merge base 4c8ae33f90, and to verify through Bogota (not Osaka). The same checks ran for every PR:

  • Fillers: compare the ported_from filler set of the whole tests/ported_static tree at the base and at the PR head. No PR drops a filler.
  • Cases: fill state_test fixtures for every fork through Bogota at the base and at the PR head, then map each old case (its d/g/v ids or old file) to its new parametrized case on a fork both sides cover. Fork totals alone would hide drops where a PR widens fork ranges.
  • Pure refactors: match old and new fixtures by _info.hash, so a renamed or merged case still matches when its content is identical. Most PRs change addresses (dropping pre_alloc_mutable or fixed addresses), which changes every hash, so for those my agent compared the post state per contract role (storage, balance direction, nonce) with addresses masked.
  • Intent: for changed cases and every claimed fix, fill the old and new case with --traces on one or two forks and compare what executes (opcodes reached, CALL and CREATE outcomes, SSTOREs, which frame fails). Each review says which cases were traced and how they were sampled.
  • Clean-up: look for missed merges or parametrizations of the kind the PR already does, and for leftover # Source: lll/raw/yul/hex comments and raw hex bytecode in the files the PR touches.

@marioevz
marioevz marked this pull request as ready for review November 18, 2026 01:23
@bt-recneps

Copy link
Copy Markdown
Contributor

Filled the merged tests Frontier to Bogota with derived and Engine X formats, pre-Merge BlockReward checks hold, Bogota OOG reverts still follow the call :)

Reviewed in 7m 01s

@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.

Lol, yes, we accept the fw changes here, updated the PR title accordingly tho!

All comments are fixed at this head. I asked my agent to re-check the new head (bdff0e28f4) the same way as before (case mapping, fixture comparison, traces, plus a blockchain fill of stRefundTest from Frontier to Bogota for BlockReward): no case is dropped. The method is described in the first review.

Comments inline.

  • The PR description could still mention three changes to what is tested: the ToEmpty_Paris and ToNonZeroBalance fillers merged into one funded_eoa case, returndatacopy_after_failing_delegatecall now sending its transaction to the contract (the upstream filler targets an account without code), and the CodeGasMeasure gas measurement in test_zero_value and test_non_zero_value_call.
  • We could still clean-up in stReturnDataTest files this PR doesn't touch (follow-up?!): the returndatasize_after_failing_* and *_after_successful_* callcode/delegatecall/staticcall files could be parametrized like test_returndatacopy_after_failing_call.py, and 31 files still pass data=Bytes("").

Comment on lines +40 to +42
@pytest.mark.execute(
pytest.mark.skip(reason="requires env.fee_recipient as block coinbase")
)

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.

Just a quick check regarding execute, pretty low prio in the grand scheme of things!

Restoring the coinbase checks puts this execute skip on 15 refund tests that could run on live networks at the previous head. The sender's GasFee balance check already pins the gas used, and so the refund, so the coinbase check mostly adds the pre-Merge block reward. Would it be worth keeping the coinbase check in one or two tests and leaving the rest executable?

Details

I asked my agent to check the 15 files at the previous head (e176252f91): none used a mutable pre-alloc, a custom environment or the coinbase, and none had an execute marker. At this head all 15 carry pytest.mark.execute(pytest.mark.skip(reason="requires env.fee_recipient as block coinbase")):

  • test_refund50_1.py
  • test_refund50_2.py
  • test_refund50percent_cap.py
  • test_refund600.py
  • test_refund_call_a.py
  • test_refund_call_a_not_enough_gas_in_call.py
  • test_refund_call_a_oog.py
  • test_refund_change_non_zero_storage.py
  • test_refund_get_ether_back.py
  • test_refund_multimple_suicide.py
  • test_refund_no_oog_1.py
  • test_refund_oog.py
  • test_refund_single_suicide.py
  • test_refund_tx_to_suicide.py
  • test_refund_tx_to_suicide_oog.py

@danceratopz danceratopz changed the title refactor(tests): merge zero/non-zero value call tests, clean up ported tests feat(test-types,test-specs,tests): add a BlockReward post term and merge zero/non-zero value call tests Dec 1, 2026
…d tests

- stZeroCallsTest, stZeroCallsRevert, stNonZeroCallsTest: merge the
  per-opcode/per-recipient files into test_zero_value.py,
  test_zero_value_oog_revert.py and test_non_zero_value_call.py.
- stReturnDataTest/test_revert_ret_data_size.py: rewrite.
- stEIP1153_transientStorage, stRefundTest, stExample, and single files in
  stPreCompiledContracts, stSpecialTest, stZeroKnowledge: fix and drop
  boilerplate to reduce pre-alloc groups.

Removed:
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_call_to_non_non_zero_balance.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_callcode_to_non_non_zero_balance.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_suicide_to_empty_paris.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_suicide_to_non_non_zero_balance.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_suicide_to_one_storage_key_paris.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_transaction_cal_lwith_data.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_transaction_cal_lwith_data_to_empty_paris.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_transaction_cal_lwith_data_to_non_non_zero_balance.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_transaction_cal_lwith_data_to_one_storage_key_paris.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_transaction_call_to_empty_paris.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_transaction_call_to_non_non_zero_balance.py
- tests/ported_static/stNonZeroCallsTest/test_non_zero_value_transaction_call_to_one_storage_key_paris.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_call_oog_revert.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_call_to_empty_oog_revert_paris.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_call_to_non_zero_balance_oog_revert.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_call_to_one_storage_key_oog_revert_paris.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_callcode_oog_revert.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_callcode_to_empty_oog_revert_paris.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_callcode_to_non_zero_balance_oog_revert.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_callcode_to_one_storage_key_oog_revert_paris.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_delegatecall_oog_revert.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_delegatecall_to_empty_oog_revert_paris.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_delegatecall_to_non_zero_balance_oog_revert.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_delegatecall_to_one_storage_key_oog_revert_paris.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_suicide_to_empty_oog_revert_paris.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_suicide_to_non_zero_balance_oog_revert.py
- tests/ported_static/stZeroCallsRevert/test_zero_value_suicide_to_one_storage_key_oog_revert_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_call.py
- tests/ported_static/stZeroCallsTest/test_zero_value_call_to_empty_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_call_to_non_zero_balance.py
- tests/ported_static/stZeroCallsTest/test_zero_value_call_to_one_storage_key_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_callcode.py
- tests/ported_static/stZeroCallsTest/test_zero_value_callcode_to_empty_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_callcode_to_non_zero_balance.py
- tests/ported_static/stZeroCallsTest/test_zero_value_callcode_to_one_storage_key_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_delegatecall.py
- tests/ported_static/stZeroCallsTest/test_zero_value_delegatecall_to_empty_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_delegatecall_to_non_zero_balance.py
- tests/ported_static/stZeroCallsTest/test_zero_value_delegatecall_to_one_storage_key_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_suicide_to_empty_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_suicide_to_non_zero_balance.py
- tests/ported_static/stZeroCallsTest/test_zero_value_suicide_to_one_storage_key_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_transaction_cal_lwith_data.py
- tests/ported_static/stZeroCallsTest/test_zero_value_transaction_cal_lwith_data_to_empty_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_transaction_cal_lwith_data_to_non_zero_balance.py
- tests/ported_static/stZeroCallsTest/test_zero_value_transaction_cal_lwith_data_to_one_storage_key_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_transaction_call_to_empty_paris.py
- tests/ported_static/stZeroCallsTest/test_zero_value_transaction_call_to_non_zero_balance.py
- tests/ported_static/stZeroCallsTest/test_zero_value_transaction_call_to_one_storage_key_paris.py
- Drop deploy_contract(nonce=1), which is the default, and
  Transaction(data=Bytes("")), which is the default empty calldata.
- stPreCompiledContracts/test_modexp_tests.py: parametrize on
  (base, exponent, modulus) instead of an index into tx_data, and
  derive the expected result as pow(base, exponent, modulus), or 0 for
  a zero modulus. All 127 legacy expectations match the formula.
…ge cases

No test reads the callee nonce, so the default EOA nonce works.
The fixed limit leaves too little gas for the trailing SSTOREs if a
reverted CREATE does not return its leftover gas.
@marioevz
marioevz force-pushed the finalize-ported-static-base branch from bdff0e2 to a41ea24 Compare December 2, 2026 21:19
@marioevz

marioevz commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

@danceratopz I've fixed all your comments and found many issues in stReturnDataTest folder, but the refactor requires many changes, so I think we should defer to a follow up PR (🥲).

I'll merge for now, and tag you on the next one.

@marioevz
marioevz merged commit 0063c55 into ethereum:forks/bogota Dec 2, 2026
27 checks passed
@marioevz
marioevz deleted the finalize-ported-static-base branch December 2, 2026 21:55
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.

4 participants