Skip to content

Fix/bridge route accounting#27

Draft
juanbono wants to merge 1 commit into
audit_1from
fix/bridge-route-accounting
Draft

Fix/bridge route accounting#27
juanbono wants to merge 1 commit into
audit_1from
fix/bridge-route-accounting

Conversation

@juanbono

Copy link
Copy Markdown
Collaborator

No description provided.

The bridge contracts had no on-chain ledger of cumulative
burned-outbound or minted-inbound amounts per route — operators had to
reconstruct route liabilities from indexed events, which is fragile
and observability-only (no on-chain invariant can be expressed against
it).

Add additive per-route counters:
- `BridgeBurner.totalBurnedTo[dstChain]` — incremented on every
  successful `sendTo`, emitting `RouteBurned(dstChain, recipient, amount, newTotal)`.
- `BridgeMinter.totalMintedFrom[srcChain]` — incremented ONLY on
  successful `stablecoin.mint`, emitting `RouteMinted(srcChain, recipient, amount, newTotal)`.

The mint-side increment is routed through a new internal
`_accountForMint(srcChain, recipient, amount)` helper so any future
quarantine / retry / redirect path can call the same site and keep
the counter consistent with actual on-chain supply (counter must NOT
advance on queue, only on actual mint).

Counters are strictly additive observability — never enforced as a cap.
Operators reconcile across chains by comparing
`BridgeBurner.totalBurnedTo[A]` (on chain B) against
`BridgeMinter.totalMintedFrom[B]` (on chain A), modulo confirmation lag.

Storage layout: new mappings appended after existing storage. Safe under
standard UUPS rules — no inherited base contracts' storage shifts.

Regression coverage:
- `test_RouteAccountingIncrementsOnSendTo` / `OnHandleMessage` — happy
  path, single + accumulated.
- `test_RouteAccountingPerDstChainIsolation` / `PerSrcChainIsolation`
  — counters do not bleed across routes.
- `test_RouteAccountingNotIncrementedOnRevert` (both sides) — failed
  ops roll back the counter write.
@juanbono
juanbono changed the base branch from main to audit_1 May 26, 2026 20:56
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