fix(tx): make NoteConsumptionChecker bundle-aware - #3801
Draft
Fumuran wants to merge 1 commit into
Draft
Conversation
A feature note and the FEE_SPONSORSHIP notes bound to it are consumable only together: fee collection rejects a sponsorship whose feature note is absent, and a feature note whose fee is uncovered. Because fee collection runs in the auth procedure, an uncovered note fails in the epilogue, which routed the batch into find_largest_executable_combination. That search grew its candidate set one note at a time from the empty set, so it only ever reached sets containing a consumable subset with one note fewer. A bound pair has none, so intact pairs were dropped alongside the note that actually failed. Group input notes into bundles that must be consumed together, derived from the note ID a sponsorship names in its storage, and make the bundle the unit of the search. Notes of a rejected bundle that were not blamed for the failure are reported with FailedNote::bundled_with set, so callers can tell a collateral drop from a genuine failure. Closes #3710 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GSDwt99bX6hr5TEfaff1Uf
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.
Summary
Closes #3710.
A feature note and the
FEE_SPONSORSHIPnotes bound to it are consumable only together. Anuncovered feature note fails in the epilogue, which lands the batch in
find_largest_executable_combination;that search grew its candidate set one note at a time, and neither half of a bound pair executes
alone. Intact pairs were therefore dropped alongside the note that actually failed - with
F1uncovered,
[F0, S0, F1]reported nothing successful rather than{F0, S0}.The fix makes the bundle, not the note, the unit of the search.
Changes
NoteBundle::groupgroups the inputs by the binding that already exists on chain, since aFEE_SPONSORSHIPnote names its feature note byNoteId. No caller has to supply the grouping,so the ntx builder and clients are fixed together. A sponsorship whose feature note is absent
forms its own bundle and so fails alone rather than taking others down with it.
find_largest_executable_combinationappends whole bundles, and itsfor size in 1..=nloopgives way to a round loop that stops when a pass adds nothing - which also fixes the loop bound
having been computed before
remaining_notesstarted shrinking.FailedNote::errorbecomesArc<TransactionExecutorError>so one error can be shared across arejected bundle;
newanderrorkeep their signatures, so this stays source-compatible. Newbundled_with()marks the notes dropped as collateral, which callers need in order to tell thoseapart from genuine failures.
FeeSponsorshipNote::sponsored_feature_note_idputs the binding rule in one public place thenode can call for its own checks.
The elimination path is untouched: it is only reached on note-script failures, where it already
converges on bundles, and leaving it alone avoids inventing an error for collaterally-dropped notes
there. No MASM, commitment or account ID changes.
Open questions
order-sensitive config notes, and a
NoteConsumptionStatusvariant for "consumable had the feebeen covered". Both look like separate issues to me rather than v0.17 blockers on this PR, but
worth confirming before this is marked ready.