test: regression for payable-multicall counterexample (#178)#585
Open
michael-moffett wants to merge 1 commit into
Open
test: regression for payable-multicall counterexample (#178)#585michael-moffett wants to merge 1 commit into
michael-moffett wants to merge 1 commit into
Conversation
Adds a regression test under tests/regression/test/ that reproduces the counterexample described in issue a16z#178: the payable multicall pattern used by Uniswap V3 Periphery lets a single msg.value be counted more than once by any subcall that reads msg.value for accounting. - New test file: tests/regression/test/PayableMulticall.t.sol - Expected results added to tests/expected/all.json for the two new test names (one expected fail, one expected pass control). Local verification: halmos --root tests/regression --contract PayableMulticallTest => 1 passed; 1 failed (counterexample at any positive amount) Drafted with AI assistance; contract shape and counterexample were validated locally against the full regression suite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #178.
Adds a regression test under
tests/regression/test/that reproduces thecounterexample described in the issue: the
payable multicallpatternused by Uniswap V3 Periphery (Uniswap/v3-periphery#52) lets a single
msg.valuebe counted more than once when a subcall readsmsg.valuefor accounting.
What the test does
Multicallmirroring the Uniswap V3 Peripheryshape (
payable,address(this).delegatecallper element).VulnerableWETH, a minimal deposit-shaped contract thatreads
msg.valuefor accounting.check_multicall_no_double_credit_fail(uint256)asserts that acaller's balance after a two-element multicall of
deposit()isbounded by
msg.value. Halmos finds the counterexample: any positiveamountcredits the caller2 * amount.check_single_deposit_no_over_credit_pass(uint256)is a control:the invariant holds under a plain single
deposit(), which anchorsthe failure to the payable-multicall pattern rather than to
deposit()itself.Local verification
Full regression harness (
pytest tests/test_halmos.py -k tests/regression)passes with the corresponding entries added to
tests/expected/all.json.Notes
_fail/_passsuffix convention seen inArith.t.soland elsewhere to make the intended verdict explicit.MulticallandVulnerableWETHcontracts are inlined in thetest file, matching the style used by
SmolWETH.t.sol.src/, solver config, or CI wiring.counterexample were validated by running halmos locally against the
full regression suite (12/13 pytest targets green on this workstation;
the
tests/ffitarget failure is unrelated; it needs--ffienabled and does not intersect with this PR).