Repository navigation
[v0.21.x-branch] Backport #11161: invoices: contain modifier errors and bypass interception for replays - #11225
Conversation
|
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-11161-to-v0.21.x-branch
git worktree add --checkout .worktree/backport-11161-to-v0.21.x-branch backport-11161-to-v0.21.x-branch
cd .worktree/backport-11161-to-v0.21.x-branch
git reset --hard HEAD^
git cherry-pick -x 0e6f2fbd947b0da5ab95aa009a09fa62c1c40193
git push --force-with-lease |
328d3aa to
8f3e7a4
Compare
🔴 PR Severity: CRITICAL
🔴 Critical (1 file)
🟠 High (4 files)
🟡 Medium (1 file)
🟢 Low (8 files)
AnalysisThis PR touches No bump was applied: excluding tests, docs, and auto-generated files, the change touches 7 files and ~293 lines, well under the 20-file/500-line bump thresholds, and only a single distinct critical package ( To override, add a |
Keep unexpected invoice lookup errors retryable instead of turning them into terminal HTLC failures. Resolve recorded HTLCs before invoking the interceptor, while retaining the atomic replay check during the invoice update. Only turn interceptor errors for confirmed-new HTLCs into individual failures. Update failure reporting and multi-backend regression tests to cover the final behavior. (cherry picked from commit 044d260)
Assert that malformed invoice payments fail only the HTLC and leave the channel active on both peers. (cherry picked from commit 80b930d)
Document that lookup errors remain retryable, interceptor errors fail new HTLCs individually, and replayed HTLCs retain their recorded outcomes. (cherry picked from commit 0e6f2fb)
8f3e7a4 to
c570cb1
Compare
Backport of #11161
Change Description
An error from the invoice settlement modifier currently fails the channel
link and sends a channel-level error to the peer. For example, this happens
when an
Invoices.HtlcModifierclient disconnects while LND is waiting for itsresponse. Stream errors and malformed responses take the same path. A local
application failure can therefore disable the link and may cause the peer
to force-close the channel.
This PR limits modifier errors for new HTLCs to an individual HTLC failure,
leaving the channel link active. It also resolves replayed HTLCs from their
recorded invoice state before invoking the modifier.
Behavior
ResultInvoiceInterceptorErrorwithout updating the invoice or cancelingother HTLCs in its set. The underlying error is logged, and local HTLC
event subscribers receive the new
INVOICE_INTERCEPTOR_ERRORdetail.takes precedence and the modifier is skipped. A previously settled HTLC
must return its preimage even if the modifier is unavailable. The replay
check inside the atomic invoice update is retained.
new processing-error result and leaves the contract unresolved. A
modifier error must not become a terminal on-chain failure decision.
The replay check is required before converting modifier errors into HTLC
failures: otherwise, an error while reprocessing an already-settled HTLC
could incorrectly replace its settlement with a failure. It also removes
the modifier as a dependency when restoring recorded HTLC outcomes.
Scope and tradeoff
This affects the invoice settlement modifier. When no client is connected,
the existing behavior already skips interception. Unexpected invoice lookup
errors still return Go errors because the HTLC's recorded state is unknown;
their recovery behavior is unchanged.
The payer receives the generic
FailIncorrectDetailswire failure, whilethe interceptor-specific detail remains local. An LND payer treats this as
a terminal payment failure, so a temporary modifier outage does not trigger
an automatic payment retry. This trades failure of the affected payment for
keeping the channel usable.
Validation
The complete invoice registry suite, including the new regressions, passed
locally under the race detector:
The registry tests run against KV, SQLite, and PostgreSQL. Coverage includes
lookup-error recovery, accepted and settled replays, canceled replays, AMP
child-preimage recovery, and a modifier error leaving an already accepted
MPP shard unchanged. Focused on-chain exit-resolver and wire/RPC failure
mapping tests also passed under the race detector.
The strengthened processing-error tests also passed against the previous
helper-based registry implementation using a temporary Go overlay, checking
that inlining the helper preserved its behavior.
The existing wrong-payment-address integration test gains assertions that
both peers still report the channel as active after the payment fails.
That test does not exercise modifier disconnection. No end-to-end
modifier-disconnect integration test was run.
Pull Request Checklist
Testing
Code Style and Documentation
lnclicommands are introduced.