Skip to content

Conversation

@partylikeits1983
Copy link
Contributor

This PR adds a procedure to be able to compute a NoteTag for based on a local account AccountId. This is needed for for the agglayer bridge in asset flow, but is also useful in other contexts.

@partylikeits1983 partylikeits1983 marked this pull request as ready for review January 7, 2026 14:59
@partylikeits1983 partylikeits1983 added contracts Related to standard note scripts or account components agglayer labels Jan 7, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a build_note_tag_for_local_account procedure in MASM to compute a NoteTag for local accounts (private and public) based on their AccountId. This functionality is needed for the agglayer bridge in asset flow and other contexts.

Key Changes

  • Added build_note_tag_for_local_account MASM procedure that constructs a LocalAny note tag with the top 14 bits from the account ID prefix
  • Added test case to verify the MASM implementation matches the Rust NoteTag::from_account_id() behavior for local accounts
  • Updated CHANGELOG to document the new procedure

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
crates/miden-protocol/asm/protocol/note.masm Implements the new build_note_tag_for_local_account procedure with bit manipulation to extract and format account ID bits into a note tag
crates/miden-testing/src/kernel_tests/tx/test_note.rs Adds test that verifies the MASM procedure produces the same tag as the Rust implementation for a private account
CHANGELOG.md Documents the addition of the new procedure

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#! The tag is constructed as follows:
#! - The two most significant bits are set to `0b11` to indicate a LOCAL_ANY tag.
#! - The next 14 bits are set to the most significant bits of the account ID prefix.
#! - The remaining bits are set to zero.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it makes sense to build on the NoteTag format from next that will be outdated as soon as #2219 is merged, since that PR completely refactors the current format. This PR should rather build on top of #2219.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense! What is the timeline to merge #2219?

Once 2219 is merged I will update this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good.

What is the timeline to merge #2219?

Sometime early next week if everything goes well.

#! Outputs: [local_account_tag]
#!
#! Invocation: exec
pub proc build_note_tag_for_local_account
Copy link
Contributor

Choose a reason for hiding this comment

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

As for the structure/naming, maybe it makes sense to introduce a note_tag.masm module and name the procedure new_account_target so we can use this as note_tag::new_account_target, and for completeness it seems it would make sense to have a new_custom_account_target as well (I think with_ would also work for consistency).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea!

@partylikeits1983 partylikeits1983 marked this pull request as draft January 7, 2026 17:23
@partylikeits1983
Copy link
Contributor Author

Converting to draft until #2219 is merged to next.

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

Labels

agglayer contracts Related to standard note scripts or account components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants