Skip to content

refactor: enforce CLAIM note consumer via NetworkAccountTarget attachment, not NoteStorage#2480

Merged
mmagician merged 6 commits intoagglayerfrom
claim-note-attachment
Feb 25, 2026
Merged

refactor: enforce CLAIM note consumer via NetworkAccountTarget attachment, not NoteStorage#2480
mmagician merged 6 commits intoagglayerfrom
claim-note-attachment

Conversation

@mmagician
Copy link
Collaborator

Replace the storage-based assert_aggfaucet_is_consumer check with the standard network_account_target::active_account_matches_target_account attachment check, unifying how all agglayer note scripts enforce their target consumer.

The CLAIM note already carries the target faucet ID in its NetworkAccountTarget attachment (set during note creation in Rust).

Closes #2468

@mmagician mmagician added no changelog This PR does not require an entry in the `CHANGELOG.md` file 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 20, 2026
@mmagician mmagician marked this pull request as ready for review February 20, 2026 13:34
Comment on lines 389 to 394
#! OUTPUT_NOTE_DATA_KEY => [
#! output_p2id_serial_num[4], // P2ID note serial number (4 felts, Word)
#! agglayer_faucet_account_id[2], // Agglayer faucet account ID (2 felts, prefix and suffix)
#! output_note_tag[1], // P2ID output note tag
#! miden_claim_amount[1], // Miden claim amount (1 felt)
#! padding[2], // padding (2 felts)
#! ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's wait for this PR to land as it refactors OUTPUT_NOTE_DATA_KEY and removes output_p2id_serial_num

Or could you rebase off of #2484

Copy link
Contributor

@partylikeits1983 partylikeits1983 left a comment

Choose a reason for hiding this comment

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

LGTM, but lets combine these two PRs since they overlap a lot.

#2484

@mmagician mmagician force-pushed the mmagician-note-account-checks branch from e7ed7c1 to 86fcb9e Compare February 23, 2026 09:09
Base automatically changed from mmagician-note-account-checks to agglayer February 24, 2026 15:16
cursoragent and others added 4 commits February 24, 2026 16:03
…ment

Replace the storage-based assert_aggfaucet_is_consumer check with the
standard network_account_target::active_account_matches_target_account
attachment check, unifying how all agglayer note scripts enforce their
target consumer.

The CLAIM note already carries the target faucet ID in its
NetworkAccountTarget attachment (set during note creation in Rust).
This change makes the note script use that attachment for the consumer
check instead of reading target_faucet_account_id from note storage.

Closes #2468

Co-authored-by: marti <marti@hungrycats.studio>
Now that the consumer check uses the NetworkAccountTarget attachment,
the target_faucet_account_id no longer needs to be serialized into
NoteStorage. The field is kept in OutputNoteData (used to build the
attachment in Rust) but excluded from to_elements().

The OutputNoteData memory layout changes from:
  [serial_num(4), faucet_id(2), tag(1), amount(1)]
to:
  [serial_num(4), tag(1), amount(1), padding(2)]

Updated MASM constants:
- OUTPUT_NOTE_TAG_MEM_ADDR: 574 -> 572
- OUTPUT_NOTE_FAUCET_AMOUNT: 575 -> 573

Co-authored-by: marti <marti@hungrycats.studio>
…im_note param

The target faucet account ID is only needed to build the
NetworkAccountTarget attachment, not as part of the note storage data.
Move it from OutputNoteData to a direct parameter of create_claim_note.

Co-authored-by: marti <marti@hungrycats.studio>
@mmagician mmagician force-pushed the claim-note-attachment branch from d995f28 to bde7af3 Compare February 24, 2026 16:03
Copy link
Contributor

@partylikeits1983 partylikeits1983 left a comment

Choose a reason for hiding this comment

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

Looks good!

I am working on a PR which fixes the comments I left, so I think lets go ahead and merge this out of the interest of time.

Comment on lines +203 to +204
// Padding to keep 8 felts (2 words) for pipe_double_words_preimage_to_memory
elements.extend([Felt::ZERO; 2]);
Copy link
Contributor

@partylikeits1983 partylikeits1983 Feb 25, 2026

Choose a reason for hiding this comment

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

this actually doesn't have to be padded to 8 felts, (2 words) in NoteStorage for pipe_double_words_preimage_to_memory. But my follow up PR fixes this, so nothing to do here now.


/// Output note data for CLAIM note creation.
/// Contains note-specific data and can use Miden types.
/// TODO: Remove all but target_faucet_account_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: technically should not remove this TODO just yet.

@mmagician mmagician merged commit 6bc6903 into agglayer Feb 25, 2026
17 checks passed
@mmagician mmagician deleted the claim-note-attachment branch February 25, 2026 08:24
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