Skip to content

channeld: fail channel on zero next_commitment_number - #9435

Open
vincenzopalazzo wants to merge 2 commits into
ElementsProject:masterfrom
vincenzopalazzo:channeld-fail-zero-reestablish-commit
Open

channeld: fail channel on zero next_commitment_number#9435
vincenzopalazzo wants to merge 2 commits into
ElementsProject:masterfrom
vincenzopalazzo:channeld-fail-zero-reestablish-commit

Conversation

@vincenzopalazzo

@vincenzopalazzo vincenzopalazzo commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

BOLT #2 says if next_commitment_number is zero we MUST immediately fail the channel and broadcast the latest commitment. On an advanced channel a reset peer sends 0 for both numbers; we warned about the stale next_revocation_number and never reached the zero check, so the channel stayed up.

The existing BOLT quote already required this. The first bullet was unimplemented: the only zero check sat under next_commitment_number == next_index[REMOTE] - 1, after the revocation warning. Implement that bullet next to the quote, and drop the nested copy.

Two commits, test then fix:

  1. tests: reproduce zero next_commitment_number on advanced channel
  2. channeld: fail channel on zero next_commitment_number

Local: test_reestablish_zero_commitment_number fails on the first commit (transient warning, no close) and passes on the second.

Thanks to Leo Nash (@tankyleo) for the report.

Fixes: #9425
Reported-by: Leo Nash (@tankyleo)
Changelog-Fixed: Protocol: immediately fail the channel if channel_reestablish next_commitment_number is zero.

@vincenzopalazzo
vincenzopalazzo force-pushed the channeld-fail-zero-reestablish-commit branch from e90f23d to 281e95c Compare August 18, 2026 09:31
BOLT ElementsProject#2 says if next_commitment_number is zero we MUST immediately
fail the channel and broadcast the latest commitment.  On an
advanced channel a reset peer sends 0 for both numbers; we warn
about the stale revocation_number and never reach the zero check,
so the channel stays up.

The test funds, pays so next_index is past 1, then injects that
reestablish.  It fails until the next commit.

Reproduces: ElementsProject#9425
Reported-by: Leo Nash (@tankyleo)
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
The existing BOLT ElementsProject#2 quote already required this, but the first
bullet was unimplemented: the only zero check sat under
next_commitment_number == next_index[REMOTE] - 1, after the
stale-revocation warning.

Implement that bullet next to the quote, and drop the nested copy.

Fixes: ElementsProject#9425
Changelog-Fixed: Protocol: immediately fail the channel if channel_reestablish next_commitment_number is zero.
Reported-by: Leo Nash (@tankyleo)
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@vincenzopalazzo
vincenzopalazzo force-pushed the channeld-fail-zero-reestablish-commit branch from 281e95c to bb2efbc Compare August 18, 2026 11:51
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.

Zero next_commitment_number does not immediately fail channel

1 participant