← Back to Pull requests

invoices: contain modifier errors and bypass interception for replays #11161

Closed
unknown closed this pull request without merging on Sep 22, 2026 13:04 UTC
View on GitHub
unknown unknown commented on Sep 03, 2026 02:01 UTC
Author

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.HtlcModifier client disconnects while LND is waiting for its
response. 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

  • For a new HTLC, a modifier error returns

  • ResultInvoiceInterceptorError without updating the invoice or canceling
    other HTLCs in its set. The underlying error is logged, and local HTLC
    event subscribers receive the new INVOICE_INTERCEPTOR_ERROR detail.
  • For an accepted, settled, or canceled HTLC replay, the recorded outcome

  • 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.
  • During on-chain resolution, the incoming contest resolver recognizes the

  • 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 FailIncorrectDetails wire failure, while
    the 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:

    go test -race ./invoices \
      -run '^TestInvoiceRegistry$|^TestResolveReplayedHtlcSettled$|^TestHtlcModificationInterceptor$|^TestInvoiceProcessingFailResolutionResults$' \
      -count=1
    

    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

  • Your PR passes all CI checks.

  • Tests covering the positive and negative (error paths) are included.

  • Bug fixes contain tests triggering the bug to prevent regressions.
  • Code Style and Documentation

  • The change is not insubstantial.

  • The change obeys the Code Documentation and Commenting guidelines, and lines wrap at 80.

  • Commits follow the Ideal Git Commit Structure.

  • New logging statements use an appropriate subsystem and logging level.

  • No new lncli commands are introduced.

  • There is a change description in the release notes.
  • Diff: 553 lines (+414 / -139) across 6 files Reviewer: gijswijs Review duration: 28023m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 553 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.378
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #11161"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.8% · Safe to merge
    20.8%