Skip to content

feat: Handle NoteExecutionHints in NTB and manage failed notes#1116

Merged
Mirko-von-Leipzig merged 49 commits intonextfrom
sergerad-note-management
Aug 19, 2025
Merged

feat: Handle NoteExecutionHints in NTB and manage failed notes#1116
Mirko-von-Leipzig merged 49 commits intonextfrom
sergerad-note-management

Conversation

@sergerad
Copy link
Copy Markdown
Collaborator

@sergerad sergerad commented Jul 29, 2025

Context

Closes #1071.

The Network Transaction Builder currently does not have any logic to manage notes that have failed. We perform a shuffle of the note list so that we don't get blocked on a forever-failing note.

Changes

  • Add InflightNetworkNote struct to allow AccountState and NTB State to keep track of failed notes.
  • Update NTB State note selection logic to consider note failure counts and relevant block numbers.

@sergerad
Copy link
Copy Markdown
Collaborator Author

Still a draft but worth considering at this stage.

Comment thread crates/ntx-builder/src/state/mod.rs
@sergerad sergerad force-pushed the sergerad-note-management branch from e596651 to 6208f1b Compare July 31, 2025 02:33
@sergerad sergerad marked this pull request as ready for review July 31, 2025 03:17
Copy link
Copy Markdown
Collaborator

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

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

Some nits and suggestions but overall a good implementation.

Comment thread crates/ntx-builder/src/state/mod.rs
Comment thread crates/ntx-builder/src/state/mod.rs Outdated
Comment thread crates/ntx-builder/src/state/mod.rs Outdated
Comment thread crates/ntx-builder/src/state/mod.rs Outdated
Comment thread crates/ntx-builder/src/state/mod.rs Outdated
Comment thread crates/ntx-builder/src/state/account.rs Outdated
Comment thread crates/ntx-builder/src/state/mod.rs Outdated
Comment thread crates/ntx-builder/src/state/account.rs Outdated
@sergerad sergerad force-pushed the sergerad-note-management branch from 1ca419b to 24cacad Compare August 1, 2025 01:10
Copy link
Copy Markdown
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 some comments inline.

Beyond these, I think the main thing we are missing (unless I missed it somehow) is updating the failure count based on the result of the NoteConsumptionChecker. Currently, this check happens inside NtxContext::filter_notes(). There, we try to execute the notes and get the first failed not - but we don't propagate this information anywhere.

This is actually the place where we need to capture failures as most notes that fail to execute will not pass the NoteConsumptionChecker.

Comment thread crates/ntx-builder/src/transaction.rs Outdated
Comment thread crates/ntx-builder/src/builder/mod.rs Outdated
Comment thread crates/ntx-builder/src/state/account.rs Outdated
Comment thread crates/ntx-builder/src/state/account.rs Outdated
Comment thread crates/ntx-builder/src/state/mod.rs Outdated
Comment thread crates/ntx-builder/src/state/account.rs Outdated
@sergerad sergerad requested a review from bobbinth August 4, 2025 01:53
Comment thread crates/ntx-builder/src/transaction.rs Outdated
Copy link
Copy Markdown
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 some more comments inline. Most of them are small nits and minor code improvements.

Comment thread crates/ntx-builder/src/transaction.rs Outdated
Comment thread crates/ntx-builder/src/transaction.rs
Comment thread crates/ntx-builder/src/transaction.rs
Comment thread crates/ntx-builder/src/transaction.rs Outdated
Comment thread crates/ntx-builder/src/state/mod.rs Outdated
Comment thread crates/ntx-builder/src/builder/mod.rs Outdated
Comment thread crates/ntx-builder/src/state/account.rs
Comment thread crates/ntx-builder/src/state/account.rs Outdated
Comment thread crates/ntx-builder/src/state/account.rs Outdated
Comment thread crates/ntx-builder/src/state/account.rs Outdated
@sergerad sergerad force-pushed the sergerad-note-management branch from d77d902 to dcb6d94 Compare August 17, 2025 23:44
Comment thread crates/ntx-builder/src/builder/mod.rs Outdated
Comment thread crates/ntx-builder/src/state/mod.rs Outdated
@sergerad sergerad requested a review from bobbinth August 18, 2025 22:25
Copy link
Copy Markdown
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 one comment for the future inline.

Also, would be good to run client integration tests (especially the ones related to network transactions) against this branch.

Comment on lines +121 to +126
let notes = notes.into_iter().map(Note::from).collect::<Vec<_>>();
let (successful, failed) = self.filter_notes(&data_store, notes).await?;
let executed = Box::pin(self.execute(&data_store, successful)).await?;
let proven = Box::pin(self.prove(executed)).await?;
self.submit(proven).await?;
Ok(())
Ok(failed)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is fine for now (no need to change anything) but if self.execute() or self.prove() fail for some reason, failed notes will never be marked as "failed". We can take this into consideration as we refactor this in the future to work more in the actor-model-like fashion.

@sergerad
Copy link
Copy Markdown
Collaborator Author

Also, would be good to run client integration tests (especially the ones related to network transactions) against this branch.

All passed 👍

@Mirko-von-Leipzig Mirko-von-Leipzig merged commit 23018b9 into next Aug 19, 2025
8 checks passed
@Mirko-von-Leipzig Mirko-von-Leipzig deleted the sergerad-note-management branch August 19, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve note execution management

3 participants