Fix/bridge route accounting#27
Draft
juanbono wants to merge 1 commit into
Draft
Conversation
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.
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.
No description provided.