Reserve metadata slot at SplicePending/ChannelPending#59
Merged
Conversation
8fc86b9 to
47cacb6
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_metadataentry is only inserted later, when the graduated rebalancer'sOnChainRebalanceInitiatedhandler runs afterawait_splice_pending/await_channel_pendingreturns. A concurrentlist_transactionscall (e.g. from a test'swait_for_condition, or from the user after observing theSplicePendingevent) hitting the gap sees an outbound payment with no metadata and trips thedebug_assert_ne!inlist_transactions.Reserve a
PendingRebalanceplaceholder insideLdkEventHandler'sSplicePendingandChannelPendingbranches, using the funding txid delivered with each event.SplicePendinginserts the placeholder before signallingsplice_pending_senderand before enqueueing the publicEvent::SplicePending, so any caller waking up on either signal already sees the entry.list_transactionsalready skipsPendingRebalance, and the rebalancer'sOnChainRebalanceInitiatedhandler upserts the slot toOnchainToLightningonce it has the trigger info. User-initiated splice-outs likewise overwrite the placeholder withTxType::Paymentwhenpay_lightningfinishes.