Skip to content

refactor: reorient CLAIM note consumption flow#2528

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

refactor: reorient CLAIM note consumption flow#2528
partylikeits1983 wants to merge 44 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 and others added 10 commits March 2, 2026 17:39
Co-authored-by: Andrey Khmuro <andrey@polygon.technology>
Co-authored-by: Andrey Khmuro <andrey@polygon.technology>
Co-authored-by: Andrey Khmuro <andrey@polygon.technology>
Co-authored-by: Andrey Khmuro <andrey@polygon.technology>
Co-authored-by: Andrey Khmuro <andrey@polygon.technology>
Co-authored-by: Andrey Khmuro <andrey@polygon.technology>
Co-authored-by: Andrey Khmuro <andrey@polygon.technology>
Co-authored-by: Andrey Khmuro <andrey@polygon.technology>
Co-authored-by: Andrey Khmuro <andrey@polygon.technology>
@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.

Comment on lines 407 to +410
exec.asset_conversion::verify_u256_to_native_amount_conversion
# => [y, pad(15)]
# => [y]

drop push.0
# => [pad(16)]
drop
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like we never use the native amount y, so probably verify_u256_to_native_amount_conversion doesn't need to return it WDYT?

(in line with #2523)

Copy link
Collaborator

Choose a reason for hiding this comment

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

addressed in #2602 if you agree

Comment on lines +313 to +316
static AGGLAYER_FAUCET_SLOT_NAME: LazyLock<StorageSlotName> = LazyLock::new(|| {
StorageSlotName::new("miden::agglayer::faucet")
.expect("agglayer faucet storage slot name should be valid")
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

the faucet no longer calls the bridge via FPI, so this slot is no longer needed AFAICS

/// ## Storage Layout
///
/// - [`Self::metadata_slot`]: Stores [`TokenMetadata`].
/// - [`Self::bridge_account_id_slot`]: Stores the AggLayer bridge account ID.
Copy link
Collaborator

Choose a reason for hiding this comment

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

to be removed as well, see above

Comment on lines +424 to +431
let bridge_account_id_word = Word::new([
Felt::ZERO,
Felt::ZERO,
faucet.bridge_account_id.suffix(),
faucet.bridge_account_id.prefix().as_felt(),
]);
let bridge_slot =
StorageSlot::with_value(AGGLAYER_FAUCET_SLOT_NAME.clone(), bridge_account_id_word);
Copy link
Collaborator

Choose a reason for hiding this comment

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

as per above comments, no longer needed

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