fix: reorder UtxoOwners writes to prevent inconsistent persistence (PM-20218)#762
Draft
fix: reorder UtxoOwners writes to prevent inconsistent persistence (PM-20218)#762
Conversation
Audit finding Issue I: UtxoOwners persist inconsistently in handle_create and handle_redemption_create. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
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
Add test coverage for the event construction failure path in the NTO pallet's
handle_create, verifying thatUtxoOwnersis not modified whenconstruct_cnight_generates_dust_eventfails. This addresses the remaining acceptance criterion for audit finding Issue I (PM-20218).🎫 PM-20218
Motivation
The core fix for audit finding Issue I (UtxoOwners persist inconsistently in
handle_create) has already been merged —UtxoOwners::insertnow occurs inside theOkarm of the event construction match. However, acceptance criterion #5 ("new tests cover the event construction failure path") has not been addressed. Without this test, there is no automated verification that a regression would be caught if the operation ordering were inadvertently reverted.Changes
Implementation (coming next):
asset_create_with_invalid_dust_key_should_not_insert_utxo_owner— registers a wallet with invalidDustPublicKeyBytes, submitsAssetCreate, verifiesUtxoOwnersis empty and noSystemTransactionAppliedevent emittedasset_spend_without_create_should_not_emit_destroy_event— verifieshandle_spendguards against Destroy events for UTXOs without prior Create🗹 TODO before merging
📌 Submission Checklist
🧪 Testing Evidence
Please describe any additional testing aside from CI:
🔱 Fork Strategy
Links