channeldb: scope confirmation hints by script #11481
🔴 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 changedocs/release-notes/unreleased/139.md - release notesitest/list_on_test.go - itest registration, test-onlyitest/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 -->
/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)
LGTM
Successfully created backport PR for v0.20.x-branch:
Successfully created backport PR for v0.21.x-branch:
litbot-9000
Roasbeef
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_localand Alice'sto_remoteoutput while the funding request remains pending.Validation
go test ./channeldb -count=1go vet ./channeldbmake 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.