feat(rust-client): screen NTL notes - #2474
Open
ricomateo wants to merge 9 commits into
Open
Conversation
ricomateo
marked this pull request as ready for review
September 1, 2026 15:39
ricomateo
requested review from
SantiagoPittella,
TomasArrachea,
igamigo and
juan518munoz
September 1, 2026 17:49
juan518munoz
reviewed
Sep 2, 2026
| client.sync_state().await.unwrap(); | ||
| let notes = client.get_input_notes(NoteFilter::All).await.unwrap(); | ||
| assert!(notes.is_empty(), "a note no tracked account can consume must not be stored"); | ||
| } |
Collaborator
There was a problem hiding this comment.
we can add a sanity check here, to verify that the note was registered correctly:
assert_eq!(mock_node.read().get_notes(&[tag], NoteTransportCursor::init()).0.len(), 1);
juan518munoz
approved these changes
Sep 2, 2026
Comment on lines
+440
to
+456
| async fn screen_transport_notes( | ||
| &self, | ||
| notes: &mut Vec<(Note, Option<BlockNumber>)>, | ||
| ) -> Result<(), ClientError> { | ||
| let account_tags = self.tracked_account_tags().await?; | ||
|
|
||
| let notes_to_screen: Vec<Note> = notes | ||
| .iter() | ||
| .filter(|(note, _)| account_tags.contains(¬e.metadata().tag())) | ||
| .map(|(note, _)| note.clone()) | ||
| .collect(); | ||
| let consumable = self.note_screener().get_batch_consumability(¬es_to_screen).await?; | ||
|
|
||
| // Discard the notes whose tag match the tracked accounts but are not consumable. | ||
| notes.retain(|(note, _)| { | ||
| !account_tags.contains(¬e.metadata().tag()) || consumable.contains_key(¬e.id()) | ||
| }); |
Collaborator
There was a problem hiding this comment.
We are not using the block number at all, we can just change the parameter to Vec<Note>
Contributor
Author
There was a problem hiding this comment.
The thing is that the caller function fetch_note_transport_updates requires to have the note binded to the block number, since it uses it as a hint when fetching the notes from the node, so I think is simpler to keep it that way.
| /// The screening filter must not discard a note the client can actually consume: same delivery | ||
| /// path as the test above, with the note targeting the account that tracks the tag. | ||
| #[tokio::test] | ||
| async fn note_delivered_by_tag_match_is_kept_when_a_tracked_account_can_consume_it() { |
Collaborator
There was a problem hiding this comment.
maybe we can just merge the tests into one
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
SantiagoPittella
approved these changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
Do not merge before #2453
Motivation
When the client fetches notes from the NTL using its tracked tags, the NTL can return notes that match a tag but are addressed to a different account (since an account's note tag covers only the 14 most significant bits of its ID prefix, so it is not unique to that account). This can lead to storing notes that none of the tracked accounts can consume.
Description
Updates the
sync_stateso that the notes fetched from the NTL are now screened when their tag matches a tracked account's tag, discarding the ones that none oft he tracked account can consume.Closes #2448