Repository navigation
staticaddr/loopin: Reject mismatched server nonce counts - #1300
Conversation
A server response can contain valid signing-info messages but fewer nonces than deposits. Signing indexes those lists by deposit and panics. Reject missing or extra nonces for every fee tier during initialization, using the existing invoice cancellation and deposit release path. Cover each fee tier and retain valid initialization coverage.
starius
left a comment
There was a problem hiding this comment.
LGTM! 💾
The fix is great! Two issues in tests and a bunch of nits.
-
The fee-guard test no longer tests the fee guard.
TestInitHtlcActionCancelsInvoiceOnFeeGuardFailurebuilds its response inline with one deposit and no nonces. It now fails at the new nonce-count check and never reaches the fee guard. It still passes because it only assertsOnErrorand the invoice cancellation, and it is the only test of the fee-guard error path. Please give each tier onemusig2.PubNonceSizenonce and assertrequire.ErrorIs(t, f.LastActionError, ErrFeeTooHigh). -
No success case with more than one deposit. Every
InitHtlcActiontest uses one deposit, so a check hard-coded to one nonce per tier would pass all of them. Could one existing success case use two deposits and two nonces per tier?testStaticAddressLoopInResponsehard-codes one nonce per tier; a count parameter would make that fixture easy to reuse.
Nits:
TestInitHtlcActionRejectsInvalidSigningInfosets noStore. If the nonce-count check were missing, the new cases would panic atCreateLoopInrather than fail theOnErrorassertion. SettingStore: &mockStore{}would make that kind of regression fail cleanly.- The loop variable is still named
missing, but it now also covers the "extra ..." cases. wantErris worked out after the switch, from whether all three tiers are non-nil. Setting the expected error per case would be easier to read.- The error message doesn't say which tier failed or give the actual and expected nonce counts.
Keep the fee-guard test reaching its intended error path and cover a successful two-deposit initialization. Make malformed-response tests fail cleanly without the guard and specify their expected errors. Include the fee tier and actual and expected counts in nonce errors.
A static-address Loop In response with fewer server nonces than deposits can panic
loopdduring HTLC signing. Require exactly one nonce per deposit for all three fee tiers during initialization, using the existing abort path to notify the server, cancel the invoice, and release deposits.Includes regression coverage for malformed nonce counts across all fee tiers, successful initialization with two deposits, the fee guard, and invoice/deposit cleanup, plus a release note.
Validation:
make fmtgo test ./staticaddr/loopin -count=1go test -race ./staticaddr/loopin -run '^TestInitHtlcAction' -count=1./staticaddr/loopin/....make commitmsg-lint range='upstream/master..HEAD'