Skip to content

feat(ntx-builder): bundle and execute sponsorship and feature notes - #2514

Merged
Mirko-von-Leipzig merged 14 commits into
santiagopittella-sponsorship-note-introductionfrom
igamigo-exec-sponsorship-notes
Aug 27, 2026
Merged

feat(ntx-builder): bundle and execute sponsorship and feature notes #2514
Mirko-von-Leipzig merged 14 commits into
santiagopittella-sponsorship-note-introductionfrom
igamigo-exec-sponsorship-notes

Conversation

@igamigo

@igamigo igamigo commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Part 2 for #2327, and alternative take on #2499

  • Fixes the poisoning denial of service by adding many more manual VM checks (see Make NoteConsumptionChecker bundle-aware protocol#3710 for more information)
  • Removes GroupIndex and the re-pairing logic. The reasoning here is that if the checker returns succesful notes, they would have been sponsored correctly and so there is never need of re-pairing
  • Removes the require_sponsorship CLI/config flag.
  • Always considers unsponsored feature notes.
  • Removes random sponsorship selection and the rand dependency.
  • Caps sponsorships at three. This was mostly to simplify for now but we can roll it back (not sure if the operator has a good way of tuning it in a way that helps the service).
  • Uses the actual transaction arguments when checking consumability. This can also be rolled back as it's very optional, but it feels a bit more correct (maybe it was a deliberate optimization).

Changelog

[[entry]]
scope       = "ntx-builder"
impact      = "added"
description = "Network transactions now bundle each feature note with the `FEE_SPONSORSHIP` notes that pay its fee, so a network note whose fee a sponsor covers is executed rather than left pending."

@igamigo
igamigo marked this pull request as ready for review August 25, 2026 04:02
@igamigo igamigo changed the title Igamigo exec sponsorship notes feat(ntx-builder): execute sponsorship and feature notes Aug 25, 2026
@igamigo igamigo changed the title feat(ntx-builder): execute sponsorship and feature notes feat(ntx-builder): bundle and execute sponsorship and feature notes Aug 25, 2026
@igamigo
igamigo force-pushed the igamigo-exec-sponsorship-notes branch from b0fae0b to fd9bf91 Compare August 25, 2026 16:51

@SantiagoPittella SantiagoPittella left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall looks good, thanks for the improvements. We need to modify the changelog entry in the PR description to remove the "--require-sponsorship" flag.

Left some comments, mostly nits and could be addressed in a followup pR

Comment thread bin/ntx-builder/src/actor/mod.rs Outdated
};
// Prefer the largest fee contributions both when applying the cap and when filtering
// later walks down successively smaller sponsorship prefixes.
group.sort_sponsorships_by_amount();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The thing with this sort is that someone could create a faucet and create 3 sponsorship notes for the feature note using an amount that will always "win" the 3 slots, and then fail at execution since we aren't checking the asset ID, right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that's true. We can read the storage slot and use that to retain "valid" sponsorship notes, or we can remove the ordering altogether and make it random or arbitrary in some other way. I went with the first approach but perhaps for simplicity we should do the latter approach?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I prefer the first approach 👍🏼

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At the moment we should only accept fees in the native asset - everything else is invalid/unaccepted atm.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean the network's native token? Or native as in native to the network faucet? Because I believe nothing enforces anything related to this at the moment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I might be misunderstanding, but I don't think we need to support multiple token types - we can't even compare/sort them by value yet.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The protocol forces the sponsorship asset to match the network account configures in its fee policy, but I think that it does not forces a match with the native token

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I might be misunderstanding, but I don't think we need to support multiple token types - we can't even compare/sort them by value yet.

I think nothing forces network account developers to be paid in a specific token (like the native one). AFAICT, they can decide to charge fees from a random asset ID. Obviously these are different than the network fees, which are currently only payable in the native token. Whether this is a problem or not, I'm not sure, but with my comment I mostly wanted to make sure assumptions are aligned.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Right you are; I was confused

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I ended up re-adding the sort with the filter of expected assets.

Comment thread bin/ntx-builder/src/actor/mod.rs Outdated
Comment thread bin/ntx-builder/src/db/queries/sponsored_accounts/mod.rs Outdated

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving though I'm unsure if all the complexity in searching/grouping is required i.e. could we simplify by taking only the single most valuable sponsor note per feature note and call it a day.

Comment thread bin/ntx-builder/src/actor/candidate.rs Outdated
/// without every selected sponsorship when its required fee is otherwise covered. A group with no
/// sponsorships is a plain network note.
#[derive(Clone, Debug)]
pub struct NoteGroup {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Perhaps

Suggested change
pub struct NoteGroup {
pub struct SponsoredFeatureNote {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I suggested that in the original PR as well. I think it works except it implies the note is always sponsored which is not really the case (0 fees is possible and no note is required). I might still change it

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ended up doing the rename

Comment thread bin/ntx-builder/src/actor/candidate.rs Outdated
Comment thread bin/ntx-builder/src/db/queries/tests.rs
@igamigo
igamigo force-pushed the igamigo-exec-sponsorship-notes branch from 9e077f0 to c06ab01 Compare August 26, 2026 19:44
@igamigo

igamigo commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

@Mirko-von-Leipzig I think we are ready to merge the stack

@Mirko-von-Leipzig
Mirko-von-Leipzig merged commit b809ca1 into next Aug 27, 2026
28 checks passed
@Mirko-von-Leipzig
Mirko-von-Leipzig deleted the igamigo-exec-sponsorship-notes branch August 27, 2026 08:38
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.

3 participants