Restructure TP flow with onlyRouter access - #850
Open
krebernisak wants to merge 6 commits into
Open
Conversation
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.
Summary
Reworks the Token Pool (TP) access-control model so that all inbound/outbound token operations are authenticated solely by the Router, rather than by per-pool onRamp/offRamp mappings. The pool no longer performs ramp authentication — the Router becomes the single chokepoint that verifies the sender is the correct OnRamp/OffRamp and applies its own RMN curse policy before dispatching to the pool. The pool keeps only an independent, owner-managed local curse policy.
Motivation
Previously each token pool stored a
mirroredPolicywithonRamps/offRampsmaps and ranensureOutboundAccess/ensureInboundAccessguards (with overridable hooks) to authenticate callers. This duplicated ramp authentication that the Router already owns, and the overridable access hooks let a custom pool bypass the Router boundary if it mishandled the check. Centralizing authentication in the Router removes this class of bug and simplifies pool storage/config.Key changes
Access control (
entrypoint.tolk)onLockOrBurnandonReleaseOrMintnow call a newonlyRouter(sender)guard before invoking any overridable operation hook, so a custom pool cannot bypass the Router boundary.onlyAdvancedPoolHooks(sender)guards the four async hook continuations (onPreflightCheckFinished/Failed,onPostflightCheckFinished/Failed), preventing a forger from injecting a fake success/failure continuation after the Router-authenticated op returns to the async flow.ensureOutboundAccess/ensureInboundAccesshooks and their base ramp-lookup implementations.ensureNotCursednow always enforces the pool's local curse policy first (hooks may add restriction but cannot bypass it).rmnProxybecomes nullable (address?); the owner can now disable RMN-proxy updates by settingaddr_none.setRMNProxy/getRMNProxyandonlyOwnerOrRMNProxyupdated accordingly.Storage/types (
types.tolk, concrete pools)TokenPool_MirroredPolicy(onRamps + offRamps + cursedSubjects) with a slimmerTokenPool_LocalPolicy(cursedSubjects only). RemovedTokenPool_RampUpdateand theTokenPool_UpdateRampAccessmessage/flow, itsRampAccessUpdatedevent, and theonRamp/offRamp/getMirroredPolicygetters.burn_mint,lock_release,lock_release_lockbox) updated: removed null access hooks and ramp getters, switched storage init tolocalPolicy.setDynamicConfignow asserts the router address is non-zero.Router (
contract.tolk,messages.tolk,errors.tolk)Router_LockOrBurnnow performs a Router-side curse check (isCursedon the destination selector) and returns a structuredRouter_TokenPoolLockOrBurnFailedto the executor when rejected.Router_RelayReleaseOrMint— the registered OffRamp relays the release-or-mint request to the Router, which asserts the sender is that OffRamp, bindsdetails.remoteChainSelector == sourceChainSelector(newSourceChainSelectorMismatcherror), applies its RMN curse policy, and forwards aTokenPool_ReleaseOrMintto the pool.Router_RichBouncedMessagehandling inonBouncedMessage: pre-admission pool bounces (viaRichBounce) are caught and surfaced as canonicalRouter_TokenPool…Failedmessages.Send executor (
ccipsend_executor)TokenPool_LockOrBurnFailure(structured pool failure, may arrive before or during withdrawal) andRouter_TokenPoolLockOrBurnFailed(Router policy rejection / pre-admission bounce), both drivingexitWithError(newTokenPoolBounceerror). Validates sender is the pool/router and thattokenPoolmatches state.Tests & wrappers
Router.ts, pools,MockTokenPool,CCIPSendExecutor).