Skip to content

Reserve metadata slot at SplicePending/ChannelPending#59

Merged
benthecarman merged 1 commit into
masterfrom
race-fix
May 12, 2026
Merged

Reserve metadata slot at SplicePending/ChannelPending#59
benthecarman merged 1 commit into
masterfrom
race-fix

Conversation

@benthecarman
Copy link
Copy Markdown
Collaborator

ldk-node adds the splice or channel funding tx to its payment store as an outbound on-chain payment the moment it broadcasts, but our tx_metadata entry is only inserted later, when the graduated rebalancer's OnChainRebalanceInitiated handler runs after await_splice_pending / await_channel_pending returns. A concurrent list_transactions call (e.g. from a test's wait_for_condition, or from the user after observing the SplicePending event) hitting the gap sees an outbound payment with no metadata and trips the debug_assert_ne! in list_transactions.

Reserve a PendingRebalance placeholder inside LdkEventHandler's SplicePending and ChannelPending branches, using the funding txid delivered with each event. SplicePending inserts the placeholder before signalling splice_pending_sender and before enqueueing the public Event::SplicePending, so any caller waking up on either signal already sees the entry. list_transactions already skips PendingRebalance, and the rebalancer's OnChainRebalanceInitiated handler upserts the slot to OnchainToLightning once it has the trigger info. User-initiated splice-outs likewise overwrite the placeholder with TxType::Payment when pay_lightning finishes.

@benthecarman benthecarman force-pushed the race-fix branch 5 times, most recently from 8fc86b9 to 47cacb6 Compare May 11, 2026 22:17
ldk-node lists the splice or channel funding tx as an outbound
on-chain payment the moment it broadcasts, but our tx_metadata
entry isn't inserted until the rebalancer's
OnChainRebalanceInitiated handler runs. A concurrent
list_transactions call sees an outbound payment with no metadata
and trips a debug_assert.

Reserve a PendingRebalance placeholder at SplicePending and
ChannelPending, which list_transactions already skips. Combine the
trigger promotion and splice upsert in OnChainRebalanceInitiated
into a single write-lock acquisition so the trigger and splice
metadata are never visible to a reader in a half-updated state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@benthecarman benthecarman merged commit 50ed4a8 into master May 12, 2026
2 checks passed
@benthecarman benthecarman deleted the race-fix branch May 12, 2026 01:39
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