Skip to content

docs(bridge-core): correct the fee-free-return rationale — it describes a deleted design - #93

Merged
AvivYossef-starkware merged 1 commit into
mainfrom
docs/fee-free-return-rationale
Sep 2, 2026
Merged

AvivYossef-starkware merged 1 commit into
mainfrom
docs/fee-free-return-rationale

Conversation

@AvivYossef-starkware

@AvivYossef-starkware AvivYossef-starkware commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

assertFeeFreeReturn's comment, and its maxFee error message, justify the guard with ledger[commitment], receive_and_bind crediting the GROSS burned amount, and the claim reverting INSUFFICIENT_CLAIMABLE.

None of those exist any more.

How the drift happened

commit date what
eeed7e03 2026-07-07 guard added — the ledger design was live, so the rationale was true
d77edee2 2026-07-08 claim-fold rewrite removes ledger[commitment] / receive_and_bind
3da04702 same day adapts the test to the rewrite — but not the rationale
#703 2026-07-23 forces Fast finality globally, noting "the return leg is unaffected — it self-enforces Standard finality", taking the stale guard as given

So the comment has described a deleted mechanism for over a month.

What actually happens now

InboundAnonymizer snapshots balance_of, calls receive_message, and hands the pool after - before. The pool asserts only non-zero / note-exists / open-salt / not-already-deposited / token-match — no comparison to any proven or burned amount — and the proof carries no amount at all (the Open sentinel).

So a per-call CCTP fee does not revert the claim. It silently credits a SMALLER note.

What changes, and what doesn't

The guard stays exactly as-is. It is still correct, and still the right direction: a caller asking to return N must get N or an error, never N − fee. Only the reason changes, from "the claim would revert" to "the note would silently shrink".

Also recorded, from an investigation in the consuming repo:

  • This costs nothing today. Circle sells no Fast tier from Polygon (standard attestation ~8s) and quotes 0 bps on both tiers for this route, confirmed against the live fee API. So there is no latency or fee being left on the table by refusing Fast here.
  • "Fee-free" is live-quoted state, not a protocol constant. CCTP v2 documents a per-deployment TokenMessengerV2 fee switch that can impose a minimum fee on STANDARD transfers. If it is ever set for this route, this guard fails the leg closed rather than shrinking the note — which is the intended direction, and worth stating so nobody "optimizes" the check away.

Why it is worth a PR

This is load-bearing documentation on a fund-safety guard, and it has now demonstrably misled two independent readers: #703 above, and an audit in the consuming repo that built a "forcing Fast is dangerous because the proof pins the amount" argument on this paragraph before verification refuted it. The guard's behavior was never wrong; the explanation was, and the explanation is what people reason from.

The test file's header comment repeated the same false claim, so it is corrected too.

Verification

Comments and message strings only — no behavior change. The existing assertion is /fee-?free|maxFee|per-call fee/i, which the reworded message still satisfies.

Run locally in packages/bridge-core:

  • tsc --noEmit — clean
  • tsc (build) — clean
  • vitest run src/core/returnIn.feeFree.test.ts src/core/returnIn.test.ts src/core/avnuPaymaster.test.ts — 43/43 passed

avnuPaymaster is included deliberately: it uses INSUFFICIENT_CLAIMABLE as a fixture for its felt-decoder, which is unrelated to the return path's ledger design and is intentionally left untouched.


This change is Reviewable

…es a deleted design

`assertFeeFreeReturn`'s comment (and its maxFee error message) explains the guard by
`ledger[commitment]`, `receive_and_bind` crediting the GROSS burned amount, and the claim
reverting INSUFFICIENT_CLAIMABLE. None of those exist any more.

That design was live when the guard was added (eeed7e03, 2026-07-07) and was removed the
next day by the claim-fold rewrite (d77edee2). Its sibling commit adapted the *test* but
nobody updated the *rationale*, so the comment has described a deleted mechanism since.

What actually happens now: InboundAnonymizer snapshots balance_of, calls receive_message,
and hands the pool `after - before`; the pool asserts only non-zero / note-exists /
token-match, and the proof carries no amount (the Open sentinel). So a per-call CCTP fee
does NOT revert the claim — it silently credits a SMALLER note.

The guard is still correct and stays as-is; only its reason changes. A caller asking to
return N must get N or an error, never N - fee.

Two readers were misled by this paragraph. #703 forced Fast finality globally and noted
"the return leg is unaffected — it self-enforces Standard finality", taking the stale
rationale as given; and an audit in the consuming repo built a "forcing Fast is dangerous
because the proof pins the amount" argument on it before verification refuted it.

Also records what the investigation established: this costs nothing today, because Circle
sells no Fast tier from Polygon (standard attestation ~8s) and quotes 0 bps on both tiers
for this route — and that "fee-free" is live-quoted state rather than a protocol constant,
since CCTP v2 documents a per-deployment TokenMessengerV2 fee switch that can impose a
minimum fee on STANDARD transfers.

Comments and message strings only; no behavior change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Comments and one error message only; no runtime or guard behavior change.

Overview
Documentation-only update for the assertFeeFreeReturn guard and the fee-free return test header. assertFeeFreeReturn logic is unchanged — still rejects maxFee > 0 and sub-Standard finality.

The rationale is rewritten because it still described the removed ledger / gross-amount / INSUFFICIENT_CLAIMABLE model. It now states that the folded claim credits whatever actually minted (InboundAnonymizer balance delta; proof has no amount), so a CCTP fee shrinks the pool note silently rather than reverting the claim. The maxFee error string matches that story.

New comment notes: Polygon route is effectively fee-free today (no Fast tier, 0 bps quoted); “fee-free” is live CCTP config, not a constant — if Circle enables a standard-tier minimum fee, failing closed at the return entry points is intentional.

Reviewed by Cursor Bugbot for commit a0b18ef. Bugbot is set up for automated code reviews on this repo. Configure here.

@AvivYossef-starkware
AvivYossef-starkware merged commit 0e6ac6c into main Sep 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant