You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
node: closeChannel→record_pending is non-atomic — a crash in the gap strands a fully-drawn channel's remainder with no recovery scan #839
Surfaced by a full-repository review (2026-06-09).
Finding
send_close confirms the closeChannel receipt landed, then separately does getChannel + record_pending (record_pending_after_close, crates/node/src/payment_settlement.rs:638-679). If the process crashes — or getChannel/record_pending fails — between the landed close and the durable pending-settle write, no local record exists that settlement is owed.
Impact
For a fully-drawn channel (clientRefund == 0 — the exact case the pending-settle feature targets), the provider's un-withdrawn remainder is stranded; recovery is manual operator settleChannel. The code documents the window and escalates to error!, but there is no boot-time reconciliation that scans on-chain Closing channels this node provides.
This is the seller-side analog of the buyer-side orphan-deposit gap tracked in #763 item 1.
Fix
Add a bootstrap reconciliation scan of provider channels in Closing status (the ChannelOpened backfill in payment_settlement.rs already demonstrates the filter pattern) that rebuilds the pending-settle set on start.
A correctness gap in payment_settlement.rs makes the closeChannel → record_pending flow non-atomic on the seller side: if the node crashes (or the getChannel/record_pending call fails) after the close transaction lands on-chain but before the local pending-settle record is durably written, no record exists that settlement is owed. For the specific case of a fully-drawn channel (clientRefund == 0), the provider's remainder is permanently stranded until an operator manually invokes settleChannel. The code already emits error! at the gap but provides no automated recovery. The proposed fix — a bootstrap reconciliation scan for provider channels in Closing status using the existing ChannelOpened filter pattern — is well-defined and scoped.
📊 Assessment
Dimension
Value
Reasoning
Type
Bug
Correctness gap: provider funds can be durably stranded with no automated recovery path
Labels
bug, medium, technical, rust
Pre-existing bug+medium are correct; added technical+rust for routing
Coding agent
Suitable
Exact file/line anchor (payment_settlement.rs:638-679), concrete fix pattern (reuse ChannelOpened_filter already in the same file), clear success criterion (boot-time reconciliation repopulates pending-settle set)
Affected code path:send_close → record_pending_after_close in crates/node/src/payment_settlement.rs:638-679. The gap is the two sequential async steps after the closeChannel receipt is confirmed: getChannel RPC call, then record_pending write.
Fix shape:
Add a startup reconciliation function (analogous to the ChannelOpened log-backfill in payment_settlement.rs) that:
Queries on-chain for PaymentChannel entries where provider == self_address and status is Closing.
For each such channel, checks whether a local pending-settle record already exists.
If not, inserts one — effectively rehydrating any entries dropped in the crash window.
Wire this scan into the existing bootstrap sequence so it runs before the settle sweep starts.
Scope boundary: Only the seller-side Closing status matters here (buyer-side is #763). The ChannelOpened event filter in the same file is the direct template.
Testing: Consider adding a test in crates/node/tests/anvil_settlement_e2e.rs (feature anvil-e2e) that simulates a crash after closeChannel mines but before record_pending writes, then restarts and verifies the reconciliation scan picks up the channel and drives it to settlement.
Priority note:medium seems right — the manual settleChannel escape hatch means funds aren't permanently lost, but the window is real in production and requires operator awareness to exercise.
Activity
github-actions commentedon Jun 9, 2026
🎯 Triage report
A correctness gap in
payment_settlement.rsmakes thecloseChannel → record_pendingflow non-atomic on the seller side: if the node crashes (or thegetChannel/record_pendingcall fails) after the close transaction lands on-chain but before the local pending-settle record is durably written, no record exists that settlement is owed. For the specific case of a fully-drawn channel (clientRefund == 0), the provider's remainder is permanently stranded until an operator manually invokessettleChannel. The code already emitserror!at the gap but provides no automated recovery. The proposed fix — a bootstrap reconciliation scan for provider channels inClosingstatus using the existingChannelOpenedfilter pattern — is well-defined and scoped.📊 Assessment
bug,medium,technical,rustbug+mediumare correct; addedtechnical+rustfor routingpayment_settlement.rs:638-679), concrete fix pattern (reuseChannelOpened_filteralready in the same file), clear success criterion (boot-time reconciliation repopulates pending-settle set)🔗 Similar issues
ChannelOpenedbackfill pattern the fix should reuse was established here💡 Notes and suggestions
Affected code path:
send_close→record_pending_after_closeincrates/node/src/payment_settlement.rs:638-679. The gap is the two sequential async steps after thecloseChannelreceipt is confirmed:getChannelRPC call, thenrecord_pendingwrite.Fix shape:
ChannelOpenedlog-backfill inpayment_settlement.rs) that:PaymentChannelentries whereprovider == self_addressand status isClosing.Scope boundary: Only the seller-side
Closingstatus matters here (buyer-side is #763). TheChannelOpenedevent filter in the same file is the direct template.Testing: Consider adding a test in
crates/node/tests/anvil_settlement_e2e.rs(featureanvil-e2e) that simulates a crash aftercloseChannelmines but beforerecord_pendingwrites, then restarts and verifies the reconciliation scan picks up the channel and drives it to settlement.Priority note:
mediumseems right — the manualsettleChannelescape hatch means funds aren't permanently lost, but the window is real in production and requires operator awareness to exercise.Add this agentic workflows to your repo
To install this agentic workflow, run
docs(node): make CycleOutcome::RecoveryPending doc + watcher log cove…
fix(node): close re-review nits — recoverable-close doc, None-block f…
fix(node): reconcile provider-side Closing channels into the settle s…
fix(node): keep buyer record when the post-close settle handoff fails (…
feat(node): buyer-side unilateral close→settle for unreachable provid…