Skip to content

refactor: reorient CLAIM note consumption flow#2528

Open
partylikeits1983 wants to merge 52 commits intoagglayerfrom
ajl-reorient-claim-note-flow
Open

refactor: reorient CLAIM note consumption flow#2528
partylikeits1983 wants to merge 52 commits intoagglayerfrom
ajl-reorient-claim-note-flow

Conversation

@partylikeits1983
Copy link
Contributor

@partylikeits1983 partylikeits1983 commented Feb 27, 2026

This PR reorients the flow in which the CLAIM note is consumed.

This PR reorients the flow from:

CLAIM -> aggfaucet -> (FPI call) bridge_in -> P2ID

CLAIM note is consumed by AggFaucet account, which does an FPI call to bridge to verify merkle proof, if valid creates P2ID note

to:

CLAIM -> bridge_in -> MINT -> aggfaucet -> P2ID

CLAIM note is consumed by AggBridge account which verifies the merkle proof, if valid creates a MINT note, which is then consumed by AggFaucet account in separate tx, which creates P2ID note.


This PR adds a mapping to the AggBridge which stores the bytes20 origin token address in the faucet registry as hash(bytes20) -> AccountId.

This is so that when creating the MINT note, the correct network note attachment target can be set. Storing the hash of the destination address as the key in a mapping, where the value is the aggfaucet AccountId is essential, as previously we only stored registered AggFaucets in a mapping like this: AccountId -> bool.


Note: Both the MINT note & P2ID note which created by the consumption of the MINT note, both use the PROOF_DATA_KEY (hash of proof data) as their serial numbers.

Resolves #2506

@partylikeits1983 partylikeits1983 self-assigned this Feb 27, 2026
@partylikeits1983 partylikeits1983 added agglayer PRs or issues related to AggLayer bridging integration pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority labels Feb 27, 2026
@partylikeits1983 partylikeits1983 force-pushed the ajl-reorient-claim-note-flow branch from 55ee9fb to 57cfbb5 Compare February 27, 2026 22:25
@partylikeits1983 partylikeits1983 added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Feb 27, 2026
@partylikeits1983 partylikeits1983 modified the milestone: v0.14.0 Feb 27, 2026
@partylikeits1983 partylikeits1983 marked this pull request as ready for review March 2, 2026 10:46
Copy link
Contributor

@Fumuran Fumuran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you! I left some nits and questions inline.

This is partial review, I only looked through the MASM code (but mostly in a way of code optimization, not the algorithm correctness).

@partylikeits1983 partylikeits1983 force-pushed the ajl-reorient-claim-note-flow branch from ee64a9b to 6a602df Compare March 2, 2026 14:51
Copy link
Contributor

@Fumuran Fumuran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you! I left just one nit inline.

partylikeits1983 and others added 4 commits March 16, 2026 12:46
* chore: pass faucet ID on stack to verify_claim_amount

* chore: pass faucet ID on stack to build_mint_output_note

* chore: completely remove CLAIM_FAUCET_ID_PREFIX_MEM_ADDR

* chore: drop "y" in verify_u128_to_native_amount_conversion

* chore: avoid uplicating y only to drop it later

* chore: adjust comments; no longer reading faucetID from mem

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* fix: rename to output & fix copilot suggestion

---------

Co-authored-by: Alexander John Lee <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: riemann <[email protected]>
Copy link
Collaborator

@mmagician mmagician left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge changes look good now 👍🏼

I left a few more questions / open items to investigate, but other than those we should be ready to merge soon.

Comment on lines +41 to +42
const CLAIM_PROOF_DATA_WORD_LEN = 134
const CLAIM_LEAF_DATA_WORD_LEN = 8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it might need some more thinking, but at least we should not duplicate the constants that refer to the same underlying data, which these do

Comment on lines +644 to +648
# Compute note tag targeting the faucet account
loc_load.BUILD_MINT_FAUCET_PREFIX_LOC
# => [faucet_prefix, note_type, MINT_RECIPIENT, pad(16)]

exec.note_tag::create_account_target
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this is the case, could you pinpoint why this is needed?
IIUC, this is a tag for the faucet, nothing to do with the P2ID that is created later?
The faucet is a network account, and the consumption of notes should not be determined by tag, but by note attachment.

@partylikeits1983 partylikeits1983 enabled auto-merge (squash) March 16, 2026 19:14
@partylikeits1983
Copy link
Contributor Author

Comment #1

yes it might need some more thinking, but at least we should not duplicate the constants that refer to the same underlying data, which these do

Resolved.

Comment #2

I don't understand why this is the case, could you pinpoint why this is needed?
IIUC, this is a tag for the faucet, nothing to do with the P2ID that is created later?
The faucet is a network account, and the consumption of notes should not be determined by tag, but by note attachment.

I set the tag of the MINT note to be the DEFAULT tag, i.e. 0. Resolved in the latest commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agglayer PRs or issues related to AggLayer bridging integration no changelog This PR does not require an entry in the `CHANGELOG.md` file pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants