Skip to content

channeld: accept retransmits under the pre-splice reserves and keep ours above both - #109

Merged
kwsantiago merged 5 commits into
blake2b-unifiedfrom
splice-reserve-leniency
Nov 14, 2026
Merged

kwsantiago merged 5 commits into
blake2b-unifiedfrom
splice-reserve-leniency

Conversation

@kwsantiago

Copy link
Copy Markdown

Summary

A splice's reserves change when channeld starts for the first connection after the lock. Updates the peer first sent before that change were added under the earlier reserves, and when they are retransmitted after it they can fail the new check. After a splice-in raises the reserve, a retransmitted update_add_htlc gets Bad peer_add_htlc: CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED, and the warning and disconnect repeat on every reconnect until the HTLC times out. A retransmitted update_fee hits the same loop.

  • lightningd persists the reserves from before a splice (pre_splice_reserve_*), so a restart between the lock and the next connection no longer loses them, and at the switch it keeps them as the earlier reserves (earlier_reserve_*) and hands them to channeld.
  • The peer's updates (update_add_htlc, update_fee as opener, and the opener check on its commitment_signed) pass if the earlier reserves allow them, from the switch connection until the peer's first commitment_signed on a later connection. A new splice ends that window, so earlier reserves never stack. The window spans the whole switch connection because a peer can switch one connection after us (when it completes the lock from our channel_reestablish), and until then it is still sending under the earlier reserves. The most it concedes is the difference between the two reserves.
  • On the switch connection our own updates must satisfy both the earlier and the new reserves, so a peer still holding us to the earlier ones never sees us break them. From the next connection only the new reserves apply.
  • Channels that never spliced are unchanged.

This adds four nullable columns to channels, so a node that has run this cannot go back to an older release without the downgrade tool, which drops them.

Known limits:

  • If a second splice locks during the switch connection, the next switch keeps only the reserves used on that connection, so a peer two splices behind can still be refused.
  • listpeerchannels spendable and receivable amounts use the current reserves, so on the switch connection a payment only the new reserve allows fails locally with Capacity exceeded.

Changelog-None

Test plan

  • New tests: test_splice_reserve_retransmit (with and without a restart), test_splice_reserve_leniency_ends, test_splice_reserve_leniency_ends_at_splice (a splice on the switch connection and on a later one), test_splice_reserve_floor and test_splice_reserve_lost_splice_locked.
  • Each part was disabled in turn and the matching tests fail. Without the leniency, l1 logs Bad peer_add_htlc: CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED. Without the floor, test_splice_reserve_floor doesn't raise.
  • run-full_channel covers the peer's adds and a remote opener's feerate under the earlier reserves, and the floor on ours. run-wallet saves and reloads both reserve pairs.
  • tests/test_splicing.py, test_splicing_disconnect.py, test_splicing_insane.py, test_db.py and test_downgrade.py: 103 passed, 1 skipped. Reserve tests with EXPERIMENTAL_DUAL_FUND=1: 9 passed. make check-units passes.

@kwsantiago

Copy link
Copy Markdown
Author

The four new columns made the channels SELECT longer than the 2048-byte span line the tracer writes, and trace_emit() cut it mid-value, leaving invalid JSON that the tracing tests failed to parse. 2060c3b now cuts a long tag value to fit, so the line stays valid. run-trace-long-tag fails on the old code and passes with it, and the three tracing tests that failed here pass locally. f148183 initializes the test's span key for gcc -O3 -Werror, and 921442a stops test_splice_reserve_retransmit[True] waiting for a connection that l2 is set to drop.

@kwsantiago
kwsantiago merged commit d5d6c9a into blake2b-unified Nov 14, 2026
46 checks passed
@kwsantiago
kwsantiago deleted the splice-reserve-leniency branch November 14, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant