Skip to content

feat: add .is_network_note() helper method for Note#2365

Merged
PhilippGackstatter merged 14 commits intonextfrom
ajl-network-note-newtype
Mar 2, 2026
Merged

feat: add .is_network_note() helper method for Note#2365
PhilippGackstatter merged 14 commits intonextfrom
ajl-network-note-newtype

Conversation

@partylikeits1983
Copy link
Contributor

This PR adds a new NetworkNote type which makes it easy to determine if a Note is a network note or not.

Resolves: #2362

@partylikeits1983 partylikeits1983 force-pushed the ajl-network-note-newtype branch from 3b1b042 to c1aea73 Compare January 29, 2026 01:03
@partylikeits1983 partylikeits1983 marked this pull request as ready for review January 29, 2026 01:05
@partylikeits1983 partylikeits1983 marked this pull request as draft January 29, 2026 15:07
@mmagician mmagician added the pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority label Feb 9, 2026
@partylikeits1983 partylikeits1983 marked this pull request as ready for review February 18, 2026 21:46
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 introduces a new AccountTargetNetworkNote type and NetworkNoteExt trait to make it easier to determine if a Note is a network note and to access network-specific properties. This addresses issue #2362 by providing a cleaner, more discoverable API compared to the previous approach of using NetworkAccountTarget::try_from(note.metadata().attachment()).

Changes:

  • Added AccountTargetNetworkNote<'a> struct providing a view over notes with NetworkAccountTarget attachments
  • Added NetworkNoteExt trait with is_network_note() and as_account_target_network_note() convenience methods
  • Added integration test test_network_note_unwrap() verifying the new API works correctly

Reviewed changes

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

File Description
crates/miden-standards/src/note/network_note.rs New module defining AccountTargetNetworkNote struct and NetworkNoteExt trait for working with network notes
crates/miden-standards/src/note/mod.rs Exports the new AccountTargetNetworkNote and NetworkNoteExt types
crates/miden-testing/src/kernel_tests/tx/test_output_note.rs Adds integration test verifying the new network note API
CHANGELOG.md Documents the addition of the NetworkNote type in release 0.14.0

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

@partylikeits1983 partylikeits1983 changed the title feat: implement NetworkNote newtype feat: add .is_network_note() helper method for Note Feb 20, 2026
Copy link
Contributor

@PhilippGackstatter PhilippGackstatter 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 to me! Sorry for the delay!

Left a small comment re usability of this type in the node. I think copilot makes some good points as well.

Comment on lines +13 to +14
pub struct AccountTargetNetworkNote<'a> {
note: &'a Note,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably make this own the underlying note and provide unwrap functionality like AccountTargetNetworkNote::into_note(self) -> Note and AccountTargetNetworkNote::as_note(&self) -> &Note. NetworkNoteExt::as_account_target_network_note would become into_*.
I think without this the node would probably not be able to use the wrapper (and maybe that's fine?) cc @Mirko-von-Leipzig @sergerad .

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed - I think wrapping a full note (rather than just a reference) would make this more flexible. AFAIK, it most relevant contexts, we'd be converting a Note into AccountTargetNetworkNote. But also, if that's not the case, cloning here wouldn't be too bad either (and if we do want to avoid cloning, using Arc could be a better option).

Copy link
Contributor

@bobbinth bobbinth 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! Thank you! I left a couple of comments inline.

Comment on lines +13 to +14
pub struct AccountTargetNetworkNote<'a> {
note: &'a Note,
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed - I think wrapping a full note (rather than just a reference) would make this more flexible. AFAIK, it most relevant contexts, we'd be converting a Note into AccountTargetNetworkNote. But also, if that's not the case, cloning here wouldn't be too bad either (and if we do want to avoid cloning, using Arc could be a better option).

/// other types of network notes may exist (e.g., SWAP notes that can be consumed by network
/// accounts but are not targeted at a specific one).
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct AccountTargetNetworkNote<'a> {
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 love the name AccountTargetNetworkNote, but also don't have much better suggestions. Maybe something like AccountBoundNetworkNote?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think SingleTargetNetworkNote is a better name? As @PhilippGackstatter wrote above, we will later on have network notes which could theoretically be filled by multiple network accounts (although not sure how that would work, but that is a separate discussion).

@partylikeits1983
Copy link
Contributor Author

partylikeits1983 commented Feb 27, 2026

@PhilippGackstatter @bobbinth I addressed all of your comments: AccountTargetNetworkNote now owns the Note with into_note()/as_note() accessors, added execution_hint() convenience method, and updated tests accordingly.

Although already approved, would appreciate one more quick round of review to verify updates, and to think about potentially a better name for AccountTargetNetworkNote, as outlined in this thread: #2365 (comment)

If everything looks good, feel free to merge!

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

All looks good! Thank you!

I do slightly prefer AccountBoundNetworkNote - but I wouldn't make the change in this PR. Let's open an issue to discuss potential name changes.

@partylikeits1983 partylikeits1983 changed the base branch from next to agglayer March 2, 2026 11:09
@partylikeits1983 partylikeits1983 changed the base branch from agglayer to next March 2, 2026 11:10
Copy link
Contributor

@PhilippGackstatter PhilippGackstatter left a comment

Choose a reason for hiding this comment

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

Thank you, looks great!

@PhilippGackstatter PhilippGackstatter merged commit 592fcbe into next Mar 2, 2026
17 checks passed
@PhilippGackstatter PhilippGackstatter deleted the ajl-network-note-newtype branch March 2, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Add method for determining if Note is a network note

6 participants