-
Notifications
You must be signed in to change notification settings - Fork 402
Exchange splice_locked
messages
#3741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
👋 Thanks for assigning @wpaulino as a reviewer! |
The logic around determining if the |
When processing confirmed transactions and updates to the best block, ChannelManager may be instructed to send a channel_ready message when a channel's funding transaction has confirmed and has met the required number of confirmations. A similar action is needed for sending splice_locked once splice transaction has confirmed with required number of confirmations. Generalize do_chain_event signature to allow for either scenario.
When processing confirmed transactions, if the funding transaction is found then information about it in the ChannelContext is updated. In preparation for splicing, move this data to FundingScope.
When processing confirmed transactions, if the funding transaction is found then information about it in the ChannelContext is updated. In preparation for splicing, move this data to FundingScope.
When processing confirmed transactions, if the funding transaction is found then information about it in the ChannelContext is updated. In preparation for splicing, move this data to FundingScope.
When processing confirmed transactions, if the funding transaction is found then information about it in the ChannelContext is updated. In preparation for splicing, move this data to FundingScope.
When checking if channel_ready should be sent, the funding transaction must reach minimum_depth confirmations. The same logic is needed for splicing a channel, so refactor it into a helper method.
dfbc04e
to
e4c0566
Compare
@wpaulino Ok, this is in better shape for a high-level look. I don't believe it correctly handles unconfirmed splice transactions yet. Also, doesn't yet re-send |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3741 +/- ##
==========================================
+ Coverage 89.10% 90.15% +1.04%
==========================================
Files 156 156
Lines 123431 132183 +8752
Branches 123431 132183 +8752
==========================================
+ Hits 109985 119164 +9179
+ Misses 10760 10435 -325
+ Partials 2686 2584 -102 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔔 1st Reminder Hey @wpaulino! This PR has been waiting for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The preparational changes are very clear. The WIP part also makes sense so far.
@@ -11725,6 +11727,13 @@ where | |||
log_trace!(logger, "Sending channel_ready WITHOUT channel_update for {}", funded_channel.context.channel_id()); | |||
} | |||
}, | |||
#[cfg(splicing)] | |||
Some(FundingConfirmedMessage::Splice(splice_locked)) => { | |||
pending_msg_events.push(MessageSendEvent::SendSpliceLocked { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO note: An event will have to be sent here as well, similar to ChannelReady
-- ChannelReady
with a flag indicating it is for splicing, or a new, splicing-specific event.
@@ -1864,6 +1864,8 @@ impl FundingScope { | |||
#[cfg(splicing)] | |||
struct PendingSplice { | |||
pub our_funding_contribution: i64, | |||
sent_funding_txid: Option<Txid>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this field set? Is it when signatures have been exchanged for the the negotiated funding transaction / it has been broadcast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these are specific to splice_locked
, so when that is sent/received.
return None; | ||
} | ||
|
||
let confirmed_funding_txid = match funding.get_funding_txo().map(|txo| txo.txid) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: FundingScope
could offer to return TXID, to avoid the need for such maps.
🔔 2nd Reminder Hey @wpaulino! This PR has been waiting for your review. |
lightning/src/ln/channel.rs
Outdated
self.context.minimum_depth = Some(COINBASE_MATURITY); | ||
self.funding.minimum_depth.unwrap_or(0) > 0 && | ||
self.funding.minimum_depth.unwrap_or(0) < COINBASE_MATURITY { | ||
self.funding.minimum_depth = Some(COINBASE_MATURITY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we somehow enforce the coinbase maturity without updating minimum_depth
? We always keep the funding transaction around now so we should be able to check if it's a coinbase transaction or not. That would prevent us from tracking minimum_depth
per scope.
@@ -1864,6 +1864,8 @@ impl FundingScope { | |||
#[cfg(splicing)] | |||
struct PendingSplice { | |||
pub our_funding_contribution: i64, | |||
sent_funding_txid: Option<Txid>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these are specific to splice_locked
, so when that is sent/received.
|
||
let funding_tx_confirmations = height as i64 - funding.funding_tx_confirmation_height as i64 + 1; | ||
if funding_tx_confirmations <= 0 { | ||
funding.funding_tx_confirmation_height = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels weird to have this done here, as opposed to doing so in funding_transaction_unconfirmed
or when we see the block at funding_tx_confirmation_height
get disconnected.
None | ||
}, | ||
_ => { | ||
Some(msgs::SpliceLocked { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't sent_funding_txid
get set here?
|
||
match pending_splice.sent_funding_txid { | ||
Some(sent_funding_txid) if confirmed_funding_txid == sent_funding_txid => { | ||
debug_assert!(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to replay splice_locked
if a disconnect happened before they were able to process it. Unclear if we'd want to use this same code path for it or not.
}; | ||
|
||
let mut confirmed_funding_tx = None; | ||
for &(index_in_block, tx) in txdata.iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may want to iterate over the funding scopes for each transaction instead, since we may be processing full block data with thousands of transactions and having to compute the txid
of each one.
After a splice has been negotiated, each party must send a
splice_locked
message to the other party once the splice transaction has had an acceptable number of confirmations. Update the logic for processing newly confirmed transactions and updated best block to sendsplice_locked
when appropriate.TODO: Likewise, handle
splice_locked
and promote the channel'sFundingScope
once bothsplice_locked
messages have been exchanged.