Repository navigation
feat(test-types,test-specs,tests): add a BlockReward post term and merge zero/non-zero value call tests - #3997
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
spencer-tb
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:DELEGATECALLfails, thenRETURNDATACOPYhalts on an out-of-bounds read.test_trans_storage_ok,test_refund_call_a_oog: identical call,SSTOREandTSTOREsequences.- 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) andToNonZeroBalance(100 wei) fillers become onefunded_eoacase in all seven merged files, 13 fewer cases per fork.ported_fromstill lists every filler, so filler counts don't show it. test_returndatacopy_after_failing_delegatecallnow sends the transaction to the contract. The upstream filler targets0x0f572e..., which has no code, so the base test ran nothing.test_zero_valueandtest_non_zero_value_callmeasure gas withCodeGasMeasure, andtest_non_zero_value_calladdsfunded_callercases.
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.pycould be two more cases instNonZeroCallsTest/test_non_zero_value.py, which already merges the otherNonZeroValue_*fillers the same way (needs a caller balance parameter to keepcaller_without_balance).stReturnDataTest: thereturndatacopy/returndatasizeafter_failing/after_successfulfiles forcallcode,delegatecallandstaticcalldiffer mostly in the opcode and could be parametrized.- 31 untouched
stReturnDataTestfiles still passdata=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_mutableintest_block504980.py,test_eoa_empty_paris.py,test_failed_tx_xcf416c53_paris.py,test_tx_e1c174e2.py; thefee_recipient,prev_randao,base_fee_per_gas=10environment this PR drops instRefundTestis still set intest_deployment_error.py,test_selfdestruct_eip2929.py,test_stack_depth_limit_sec.py.stExample/test_add11.py: the environment this PR drops fromtest_add11_yml.py;test_add11.pyandtest_yul_example.pykeepdata=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_fromfiller set of the wholetests/ported_statictree at the base and at the PR head. No PR drops a filler. - Cases: fill
state_testfixtures 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 (droppingpre_alloc_mutableor 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
--traceson 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/hexcomments and raw hex bytecode in the files the PR touches.
|
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
left a comment
There was a problem hiding this comment.
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_ParisandToNonZeroBalancefillers merged into onefunded_eoacase,returndatacopy_after_failing_delegatecallnow sending its transaction to the contract (the upstream filler targets an account without code), and theCodeGasMeasuregas measurement intest_zero_valueandtest_non_zero_value_call. - We could still clean-up in
stReturnDataTestfiles this PR doesn't touch (follow-up?!): thereturndatasize_after_failing_*and*_after_successful_*callcode/delegatecall/staticcall files could be parametrized liketest_returndatacopy_after_failing_call.py, and 31 files still passdata=Bytes("").
| @pytest.mark.execute( | ||
| pytest.mark.skip(reason="requires env.fee_recipient as block coinbase") | ||
| ) |
There was a problem hiding this comment.
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.pytest_refund50_2.pytest_refund50percent_cap.pytest_refund600.pytest_refund_call_a.pytest_refund_call_a_not_enough_gas_in_call.pytest_refund_call_a_oog.pytest_refund_change_non_zero_storage.pytest_refund_get_ether_back.pytest_refund_multimple_suicide.pytest_refund_no_oog_1.pytest_refund_oog.pytest_refund_single_suicide.pytest_refund_tx_to_suicide.pytest_refund_tx_to_suicide_oog.py
…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.
Store the result of the second call or create, and check that a failing create leaves no account, so a case that stops failing is caught.
bdff0e2 to
a41ea24
Compare
|
@danceratopz I've fixed all your comments and found many issues in I'll merge for now, and tag you on the next one. |
Description
Part of finalizing the
tests/ported_static/port: cleanup to reduce pre-alloc groups, removepre_alloc_mutablewhere not needed, and turn converter output into maintained, fork-agnostic tests. Files are disjoint from the otherfinalize-ported-static-*PRs, so each can be reviewed and merged independently.Framework
BlockReward(tx)balance term next toGasFee/Tip/BlobFee. It resolves tofork.get_reward()in blockchain fixtures and to zero in state fixtures (and post-Merge), so fee-recipient checks can be written once asTip(tx, gas=...) + BlockReward(tx)on every fork.TipandBlockRewardshare aFeeRecipientTermbase for the recipient check.Merged / parametrized tests
stZeroCallsTest,stZeroCallsRevert,stNonZeroCallsTest: per-opcode/per-recipient files merged intotest_zero_value.py,test_zero_value_oog_revert.pyandtest_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 intotest_returndatacopy_after_failing_call.py(CALL/CALLCODE/DELEGATECALL/STATICCALL × INVALID callee / out-of-gas callee).test_revert_ret_data_size.pyrewritten;test_too_long_return_data_copy.pyparametrized on the returned length and copied range, with the outcome derived.stRefundTest:refund_call_to_suicide_{no_storage,storage,twice}merged intotest_refund_call_to_suicide.py.stEIP1153_transientStorage:test_trans_storage_ok.pysplit into one test per scenario. Both transient storage tests rewritten from the filler Yul withConditional/Switch, so no hardcoded jump targets or addresses remain.stPreCompiledContracts/test_modexp_tests.pyandstZeroKnowledge/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: theToEmpty_ParisandToNonZeroBalancefillers differ only in the callee's balance (10 and 100), so both are now a singlefunded_eoarecipient case (an EOA funded with 1 wei) intest_zero_value.py,test_zero_value_suicide.pyandtest_zero_value_transaction_call.py.returndatacopy_after_failing_delegatecall: the upstream filler sends its transaction to an account without code, so the contract doing theDELEGATECALLandRETURNDATACOPYnever runs and the expected storage holds trivially.test_returndatacopy_after_failing_call.pysends the transaction to the contract, so the copy after the failing delegatecall is actually exercised.test_zero_valueandtest_non_zero_value_call: the fillers storedGASbefore the call, which only pins the intrinsic gas. The call is now measured withCodeGasMeasureand checked againstgas_cost(fork)(minus the call stipend intest_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
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.d/g/vindexes andresolve_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 usebalance_change=-GasFee(...).Tip + BlockReward, with an execute skip marker.valid_fromwherever 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
just static<type>(<area>): <description>, where<type>and<area>come from an appropriateC-<type>, respectivelyA-<area>, label. The title should match the target squash commit message.Cute Animal Picture