1 minor finding · 2 suggestions
Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.
Findings
[minor] · A large PSBT can evict its own MuSig2 nonces while publishing pubnonces
A single walletprocesspsbt call can evict secret nonces needed for later signing; restarting repeats the eviction, so the spend must be split, though no affected production workflow was identified.
Location: src/musig.cpp:133 (head).
Details and suggested fix
The 2048-session cap counts sessions created during one walletprocesspsbt call. DescriptorScriptPubKeyMan::FillPSBT processes every input using the descriptor's shared nonce store. For each unsigned Taproot input, SignTaproot tries the key path and then each script-path leaf, and SignMuSig2 creates a nonce for each musig() expression containing our key.
With the supplied functional-test descriptor, participant $1 creates three sessions per input. Thus 683 inputs create 2049 sessions, exceeding the cap. The earliest sessions are evicted during the same call that puts their pubnonces in the returned PSBT.
In round two, CreateMuSig2PartialSig cannot find a secnonce for an evicted session. Because our pubnonce is already present, SignMuSig2 does not create a replacement nonce, and the RPC returns complete: false. With 700 inputs, 52 sessions are evicted, including all three sessions for each of the first 17 inputs, leaving those inputs unable to complete.
Restarting from the clean PSBT recreates sessions in the same input order and evicts the same ones. At base, the unbounded nonce store allowed this PSBT to sign. The affected cosigners' round-one nonces are wasted, and the workaround is to split the spend into smaller PSBTs. No current workflow with this many inputs was identified, so the production impact is unconfirmed.
Avoid evicting sessions created during the current FillPSBT call. If they do not fit, stop creating nonces for later inputs so they can receive nonces in a subsequent round, or return an error. Do not return a pubnonce unless its secnonce is stored. If Add refuses inserts, also relax the Assert(inserted) in FlatSigningProvider::SetMuSig2SecNonce.
Optional improvements
[suggestion] · Evicted MuSig2 sessions are not distinguishable from rounds awaiting cosigners
When more than 2048 unfinished sessions share a descriptor, an evicted session can leave the RPC reporting only complete: false, with no visible indication that all participants must restart.
Location: src/musig.cpp:134 (head).
Details and suggested fix
When sessions on the same descriptor push an entry out, Add erases the oldest nonce without logging or returning an eviction status. A later walletprocesspsbt cannot find the secnonce in CreateMuSig2PartialSig. Since our pubnonce is present, SignMuSig2 does not create a new nonce; if any cosigner partial signature is present for that key, it skips the key as well. FillPSBT accepts INCOMPLETE, and the RPC returns only the PSBT and complete: false, just as it does while waiting for cosigners.
A coordinator can therefore continue collecting data for a round that cannot finish. Before this change, a session was lost only on wallet unload or restart; now it can be lost while the wallet remains loaded. Recovery requires all participants to redo both rounds from a PSBT created before any nonces were added, because cosigners who already signed have used their nonces. The trigger requires more than 2048 unfinished sessions on one descriptor, and how often it occurs in practice is unconfirmed.
Log evictions in the wallet category, including the count, and document the cap and full restart procedure in a release note.
[suggestion] · The bounded-store test does not verify the cap or FIFO removal order
The test would still pass with a different capacity, incorrect retained IDs, or a Remove implementation that corrupts the eviction order; production signing behavior is unchanged.
Location: src/wallet/test/scriptpubkeyman_tests.cpp:79 (head).
Details and suggested fix
The test checks only that the first ID is gone, the last is present, and fewer than 4096 IDs remain. A cap of 1 or 4095, or eviction of the wrong middle entries, would still pass. The test removes only the newest ID, so a Remove implementation that pops the back of m_order instead of removing the matching ID would also go undetected.
Assert that exactly MAX_SESSIONS entries remain and that they are the last IDs added. Then remove a middle ID, add more sessions, and check which IDs are evicted next. A direct unit test of MuSig2SecNonces could cover this without wallet setup.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Remove the unused
Size()accessor