← Back to Pull requests

channeldb: scope confirmation hints by script #11481

Merged
Roasbeef merged 6 files (304 lines) on Nov 04, 2026 20:05 UTC
View on GitHub
Roasbeef Roasbeef commented on Nov 04, 2026 05:16 UTC
Author

In this PR, we key confirmation hints by the txid and output script used by ConfRequest.MatchesTx. Two pending confirmation requests can share a txid while watching different scripts. Because the old cache key used only the txid, the confirmation scan of one request could advance the hint of the other, so a request could resume from its caller-provided height instead of the block where its transaction confirmed.

We append the script to the txid in confHintKey, so each request tracks its own hint. Existing txid-only cache entries are ignored; registration falls back to its caller-provided height, which may repeat scanning but cannot skip the relevant block. The same key separation also covers close-confirmation and channel-announcement waits that reuse this cache after restart.

The new integration case places a pending funding request alongside a breach confirmation that shares its txid, confirms the revoked commitment, and requires justice to spend both the revoked to_local and Alice's to_remote output while the funding request remains pending.

Validation

  • go test ./channeldb -count=1

  • go vet ./channeldb

  • make itest-only backend='bitcoind notxindex' icase='breach.conf.hint.isolated.by.script' timeout=15m (pass)

  • make itest-only backend=neutrino icase='breach.conf.hint.isolated.by.script' timeout=15m (pass)
  • This is a draft while hosted CI and normal review run.

    Diff: 304 lines (+284 / -20) across 6 files Reviewer: litbot-9000 Review duration: 889m
    All Vouch review confidence checks passed
    Residual risk 0.08 = Change Risk (0.45) × (1 − Review Confidence (0.81)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 304 lines diff across 6 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.72 · 3 substantive comment(s)
    0.72
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    81%
    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.342
    Real PR Conversation Timeline
    6 items
    github-actions[bot] github-actions[bot] commented on Nov 04, 2026 05:53 UTC
    Bot

    🔴 PR Severity: CRITICAL

    files changed | 5 files | 268 lines changed

    <details>
    <summary>🔴 <strong>Critical</strong> (1 file)</summary>

  • channeldb/height_hint.go - modifies height-hint cache persistence logic in channeldb, which underpins chain-sync and breach/confirmation tracking state
  • </details>

    <details>
    <summary>🟢 <strong>Low</strong> (4 files)</summary>

  • channeldb/height_hint_test.go - test-only change

  • docs/release-notes/unreleased/139.md - release notes

  • itest/list_on_test.go - itest registration, test-only

  • itest/lnd_breach_conf_hint_poison_test.go - new integration test, test-only
  • </details>

    Analysis

    The core change touches channeldb/height_hint.go, which falls under the channeldb/* category (channel state persistence) and is classified CRITICAL regardless of its small diff size (+7/-3), since it affects height-hint cache data used in chain rescan and breach-remediation flows. The remaining files are test additions (including a new itest for breach/confirmation-hint "poisoning") and release notes, which don't change the overall severity. No bump thresholds (file count, line count, or multiple critical packages) were triggered beyond the inherent CRITICAL classification of the touched package.

    ---
    <sub>To override, add a severity-override-{critical,high,medium,low} label.</sub>
    <!-- pr-severity-bot -->

    litbot-9000 litbot-9000 approved these changes on Nov 04, 2026 19:12 UTC
    Approved Reviewer

    /gateway review

    Approve. The key change is exactly as described: confHintKey now keys on txid‖script, so two requests sharing a txid track independent hints. Legacy txid-only entries simply never match again, which degrades to a re-scan from the caller-provided height — the safe direction (repeat scanning, never skip a confirmed block).

    Verified: go test ./channeldb -run TestHeightHintCache -count=1 passes, including the new TestHeightHintCacheConfirmsPerScript (separation, unknown-script miss, purge isolation). Mutation check: dropping the script from the key fails the new test, so the coverage is real. Raw append after the fixed 32-byte txid is unambiguous. Release note present.

    Not verified: the itest (lnd_breach_conf_hint_poison_test.go) — reviewed by reading only, no Docker here; CI covers it.

    — claudell ⚡ (OpenClaw dev agent; approval posts as litbot-9000 and does not count toward branch protection)

    ziggie1984 ziggie1984 approved these changes on Nov 04, 2026 19:27 UTC
    Approved Reviewer

    LGTM

    github-actions[bot] github-actions[bot] commented on Nov 04, 2026 21:23 UTC
    Bot

    Successfully created backport PR for v0.20.x-branch:

  • #11493
  • github-actions[bot] github-actions[bot] commented on Nov 04, 2026 21:23 UTC
    Bot

    Successfully created backport PR for v0.21.x-branch:

  • #11494
  • Reviewers
    Assignees
    Roasbeef Roasbeef
    Labels
    risk: low confidence: 81.4% 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: 44.5% (MEDIUM) · Higher = larger blast radius
    44.5%
    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: 81.4% · Lower = rushed or shallow review
    81.4%
    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: 8.3% · Safe to merge
    8.3%