Skip to content

funding: fix race in itest for zero-conf funding#10440

Merged
ziggie1984 merged 1 commit intolightningnetwork:masterfrom
ziggie1984:bugfix/itest-race
Dec 11, 2025
Merged

funding: fix race in itest for zero-conf funding#10440
ziggie1984 merged 1 commit intolightningnetwork:masterfrom
ziggie1984:bugfix/itest-race

Conversation

@ziggie1984
Copy link
Collaborator

@ziggie1984 ziggie1984 commented Dec 10, 2025

Fix a race condition where forwarding through a public zero-conf channel
could fail with UnknownNextPeer when using the confirmed SCID. The issue
occurred because ReportShortChanID (which updates the switch's baseIndex
to handle the confirmed SCID) was called AFTER addToGraph (which announces
the confirmed SCID to the network).

With slow backends like postgres, addToGraph takes significant time,
creating a window where other nodes learn about the confirmed SCID from
gossip and attempt to route through it, but the receiving node's switch
hasn't been updated yet to handle forwards using the confirmed SCID.

The fix reorders operations to call ReportShortChanID before addToGraph,
ensuring the switch is ready to handle the confirmed SCID before it's
announced to the network. Forwards using either the alias or confirmed
SCID will work since getLinkByMapping uses baseIndex to map both to the
same link in forwardingIndex.

Fixes flaky test: zero_conf-channel_policy_update_public_zero_conf

Fix #9912

@ziggie1984 ziggie1984 self-assigned this Dec 10, 2025
@ziggie1984 ziggie1984 added no-changelog itests Issues related to integration tests. funding Related to the opening of new channels with funding transactions on the blockchain labels Dec 10, 2025
Fix a race condition where forwarding through a public zero-conf channel
could fail with UnknownNextPeer when using the confirmed SCID. The issue
occurred because ReportShortChanID (which updates the switch's baseIndex
to handle the confirmed SCID) was called AFTER addToGraph (which announces
the confirmed SCID to the network).

With slow backends like postgres, addToGraph takes significant time,
creating a window where other nodes learn about the confirmed SCID from
gossip and attempt to route through it, but the receiving node's switch
hasn't been updated yet to handle forwards using the confirmed SCID.

The fix reorders operations to call ReportShortChanID before addToGraph,
ensuring the switch is ready to handle the confirmed SCID before it's
announced to the network. Forwards using either the alias or confirmed
SCID will work since getLinkByMapping uses baseIndex to map both to the
same link in forwardingIndex.

Fixes flaky test: zero_conf-channel_policy_update_public_zero_conf
Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

Copy link
Collaborator

@starius starius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🏆

Thanks for fixing this! The test is wonderful - it serves as a regression test.

Just one comment: if ReportShortChanID fails because of a transient DB error, does it make sense to call addToGraph?

@ziggie1984 ziggie1984 merged commit f4b3ed7 into lightningnetwork:master Dec 11, 2025
38 of 41 checks passed
@ziggie1984 ziggie1984 deleted the bugfix/itest-race branch December 11, 2025 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

funding Related to the opening of new channels with funding transactions on the blockchain itests Issues related to integration tests. no-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: failed to send payments in zero_conf-channel_policy_update_public_zero_conf

3 participants