fix(policy)!: Fix SatisfiableItem id calculation for Thresh nodes#439
Open
ValuedMammal wants to merge 1 commit intobitcoindevkit:masterfrom
Open
fix(policy)!: Fix SatisfiableItem id calculation for Thresh nodes#439ValuedMammal wants to merge 1 commit intobitcoindevkit:masterfrom
ValuedMammal wants to merge 1 commit intobitcoindevkit:masterfrom
Conversation
by special-casing Thresh to derive the checksum payload from the structural data only (threshhold and child ids). Prevents the id from being influenced by policy satisfaction/ contribution which depend on runtime state. BREAKING: As this can permanently change the item's id calculation, any previously persisted ids should be recomputed from the descriptor. The id calculation should be stable from now on.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #439 +/- ##
==========================================
- Coverage 80.04% 79.84% -0.20%
==========================================
Files 24 24
Lines 5336 5344 +8
Branches 242 242
==========================================
- Hits 4271 4267 -4
- Misses 987 999 +12
Partials 78 78
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Description
Fixes #123.
SatisfiableItem::id()previously produced unstable ids forThreshnodes becauseSatisfiableItem::ThreshcontainsVec<Policy>, andPolicycarriescontributionandsatisfaction— both of which are runtime-dependent (they differ based on whether private or public keys are loaded into the signer). This meant the policy node id changed for the same descriptor structure depending on signing context, breaking any use-case that persists ids (e.g. storing signing paths in a database keyed by policy id).The fix special-cases
ThreshinSatisfiableItem::id(), computing the checksum preimage from only structural data:thresh(<threshold>,[<child_id0>,<child_id1>,...])Child ids are themselves already stable (leaf ids are unaffected). Leaf item ids are unchanged — they still use JSON serialization of their content, which contains no runtime state.
Notes to the reviewers
No library API surface changes — method signatures, types, and public fields are all unchanged. The breaking nature of this change is behavioral: the id derivation for
Threshnodes produces different values than before, so any ids persisted prior to this fix (e.g. as database keys for signing paths) are now stale and must be recomputed from the descriptor. This is documented in theid()doc comment under a# Migration noteheading, with a link back to issue #123.The one hardcoded
Threshid intests/wallet.rs(test_taproot_psbt_populate_tap_key_origins_repeated_key) was updated from"rn4nre9c"to"vj73w7cm"to reflect the new stable id.Changelog notice
Fixed
fix(policy)!:SatisfiableItem::id()now produces a stable id forThreshnodes regardless of which signing keys are present in the descriptor. Previously the id varied based on runtimecontribution/satisfactionstate. Breaking (behavioral): no API signatures change, but any persistedThreshpolicy node ids must be recomputed from the descriptor.Checklists
All Submissions:
just pbefore pushingBugfixes: