Repository navigation
Description
Found by the multi-agent review of #1518. Pre-existing — confirmed with git log -S"received < minDeposit", which shows the predecessor check arrived in #777 with no fixture, and topUp on main already carried the identical untested received == 0.
The gap
contracts/test/ has no fee-on-transfer or rebasing token mock. contracts/test/mocks/ holds only MintableUSDC, MockCapacityBond, MockEd25519Verifier, MockFeeRouter, MockSlashJudgeEvidence, and PaymentChannelTest uses a plain OZ MockUSDC. So four guard sites are unreachable by the suite:
openChannelpre-transferdeposit == 0(covered —test_openChannel_revertsOnZeroDeposit)openChannelpost-transferreceived == 0— untested, and// slither-disable-next-line incorrect-equalitymeans static analysis won't comment eithertopUppre-transferadditionalDeposit == 0topUppost-transferreceived == 0— untested
The more valuable assertion this unlocks
Not the reverts — the delta accounting. openChannel credits ch.deposit = received, deliberately, so a fee-on-transfer proxy cannot over-state a channel. Nothing tests that the credited value is received rather than the requested deposit. That is the case that would silently lose money.
And there is a live inconsistency on the Rust side: crates/client-pull/src/buyer_channel.rs records the requested deposit in the local channel row rather than opened.deposit (the decoded ChannelOpened value, which is the contract's received). A one-word fix. Today it is unreachable — USDC is immutable at deployment and Arbitrum USDC is not fee-on-transfer — but it means the buyer's local watermark could over-state the on-chain deposit, its vouchers exceed it, and _advanceClaimWatermark reverts at withdraw/settleChannel: the seller has delivered bytes it can never claim.
Note on what #1518 narrowed
Before #1515, a proxy shaving a 10 USDC deposit to 0.4 USDC reverted DepositBelowMinimum(400000, 1000000) and rolled the transfer back. Now only a shave to exactly zero reverts; a partial shave opens a channel at the shaved value. #1518's commit message and CHANGELOG are accurate about this ("cannot shave a deposit to nothing"), and it matches topUp's long-standing behaviour, so it is defensible — but it is a narrowing, and it is currently undocumented as an intentional decision rather than an unexercised path.
Proposal
A ~15-line FeeOnTransferUSDC (an ERC20 whose _update burns a fixed bps) covering:
- both post-transfer
ZeroAmountreverts, at 100% fee getChannel(id).deposit == received(notdeposit) at a partial fee, on bothopenChannelandtopUp— the assertion that actually matters- a decision, pinned by a test either way, on whether a partial shave should revert (
received != deposit, or a bps tolerance) or be accepted as it is today
Temper the priority: the USDC address is immutable at deployment and the deployed token is not fee-on-transfer, so this is defensive depth for a token that will never be configured. It is cheap, though, and it converts three "we think this is fine" comments into assertions.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
test(contracts): assert the received-delta accounting with a fee-on-t…
fix: address the multi-agent review of #1519/#1520/#1521
test(contracts): assert the received-delta accounting with a fee-on-t…
fix: address the multi-agent review of #1519/#1520/#1521