-
Notifications
You must be signed in to change notification settings - Fork 9
Function closures for CCIP token pool hooks #320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JohnChangUK
wants to merge
24
commits into
develop
Choose a base branch
from
function-closures
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
b9ecf0d to
4c1ce0e
Compare
4c1ce0e to
cefd423
Compare
cefd423 to
ca10dbd
Compare
ca10dbd to
11d1792
Compare
JohnChangUK
commented
Oct 27, 2025
Contributor
Author
|
Tests for both V1 and V2 execution in the SAME test, make sure both routes are compatible. |
1ac084d to
be0161b
Compare
be0161b to
e4d9299
Compare
e4d9299 to
3cc4d5e
Compare
71ec404 to
06e1b87
Compare
06e1b87 to
c7c32db
Compare
c7c32db to
c20ed28
Compare
c20ed28 to
694e30a
Compare
fd83714 to
3b00f76
Compare
4c368ac to
139193f
Compare
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.
Function Closures Migration for CCIP Token Pools and Receivers
Migrates CCIP token pool and receiver infrastructure to use function closures, removing the need for
dispatchable_fungible_assetpattern on token pools and receivers.V1 Reentrancy Problem
When Receiver contracts try to transfer tokens within PTTs, if they call
dispatchable_fungible_asset::withdraw/deposit(), this causes reentrancy as receivers in V1 are invoked via dynamic dispatch.With closures, there is no need to invoke hooks via dynamic dispatch.
V2 Receiver
How to Register with V2
Token Pool Registration
Complete example from
burn_mint_token_pool:Receiver Registration
Key Points
Closure Signatures:
lock_or_burnandrelease_or_mintccip_receivehas drop + copy + storeabilitiesCallback Functions:
Backward Compatibility
Dual Registration
All pools support V1 and V2 simultaneously:
Automatic Dispatcher Routing
Dispatcher automatically prefers V2 when available:
if (has_token_pool_config(pool_address)) { lock_or_burn_v2(...) // V2 path - fast, no lock } else { // V1 fallback - slow, module lock }Migration Path
upgrade_v2::init_module()adds V2 to existing poolTechnical Requirements
REQUIRED: Move 2.2
aptos move compile --dev --language-version 2.2 aptos move test --dev --language-version 2.2