-
Notifications
You must be signed in to change notification settings - Fork 412
[Splicing] Tx negotiation during splicing #3736
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! |
7f6dfbd
to
c3778bc
Compare
1 similar comment
1 similar comment
1 similar comment
1 similar comment
1 similar comment
1 similar comment
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.
Sorry about the late review. We were traveling to an off site last week. Just a high-level pass on the first four commits. Will need to take a closer look at the last one.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3736 +/- ##
==========================================
+ Coverage 89.73% 90.28% +0.55%
==========================================
Files 159 160 +1
Lines 128910 132032 +3122
Branches 128910 132032 +3122
==========================================
+ Hits 115676 119207 +3531
+ Misses 10536 10172 -364
+ Partials 2698 2653 -45 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
88d2e83
to
866368d
Compare
Ready for a new round of review. I have addressed the comments, applied most of them. There is still one to-do (update channel reserve values), that I will do, but the rest is ready for review. |
Ready for a new round of review. All pending and newly raised comments addressed. |
Let us know when this is ready for another round, no need to wait on #3842 to get more review on this. |
20233de
to
e14f4c9
Compare
e14f4c9
to
3eca72f
Compare
Commits squashed, rebased (post #3741), fmt. Ready for a new round of review. |
59e9b23
to
3577418
Compare
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.
There are a handful of comments from my last review that still need to be addressed
fn begin_interactive_funding_tx_construction<ES: Deref>( | ||
&mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey, | ||
change_destination_opt: Option<ScriptBuf>, | ||
is_initiator: bool, change_destination_opt: Option<ScriptBuf>, | ||
prev_funding_input: Option<(TxIn, TransactionU16LenLimited)>, |
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.
Should we just drop this commit and revisit once #3842 lands? Or we can just drop the prev_funding_input
part for now.
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.
🔔 1st Reminder Hey @jkczyz! This PR has been waiting for your review. |
🔔 2nd Reminder Hey @jkczyz! This PR has been waiting for your review. |
This is a simple rename, DualFundingContext to FundingNegotiationContext, to suggest that this is use not only in dual-funded channel open. Also rename the field dual_funding_context to funding_negotiation_context.
The begin_interactive_funding_tx_construction() method is extended with `is_initiator` parameter (splice initiator), and `prev_funding_input` optional parameter, containing the previous funding transaction, which will be added to the negotiation as an input by the initiator.
Introduce struct NegotiatingChannelView to perform transaction negotiation logic, on top of either PendingV2Channel (dual-funded channel open) or FundedChannel (splicing).
Fill the logic for including transaction negotiation during splicing, implement the functions: splice_channel, splice_init, splice_ack, funding_tx_constructed. Also extend the test case test_v1_splice_in with the steps for funding negotiation during splicing.
3577418
to
586a094
Compare
Comments addressed, minor fixes. Ready for 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.
Please go back through all previous review comments, there are still a handful that need to addressed...
fn begin_interactive_funding_tx_construction<ES: Deref>( | ||
&mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey, | ||
change_destination_opt: Option<ScriptBuf>, | ||
is_initiator: bool, change_destination_opt: Option<ScriptBuf>, |
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.
If we make is_initiator
part of FundingNegotiationContext
, it seems like we could just provide a reference of it to calculate_change_output_value
to clean things up a bit.
if let Some(ref mut pending_splice) = &mut self.pending_splice { | ||
if let Some(ref mut funding) = &mut pending_splice.funding_scope { | ||
if pending_splice.funding_negotiation_context.our_funding_satoshis != 0 | ||
|| pending_splice | ||
.funding_negotiation_context | ||
.their_funding_satoshis | ||
.unwrap_or_default() != 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.
Somehow my comment here disappeared, but there's no need to check our/their_funding_satoshis
, pending_splice.funding_scope
being set implies those are also set.
@@ -10028,9 +10110,26 @@ where | |||
"Insufficient inputs for splicing; channel ID {}, err {}", | |||
self.context.channel_id(), err, | |||
)})?; | |||
// Convert inputs | |||
let mut funding_inputs = Vec::new(); | |||
for (tx_in, tx, _w) in our_funding_inputs.into_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.
Can our_funding_inputs
be an owned value without cloning now?
self.funding.value_to_self_msat, | ||
our_funding_contribution_satoshis, | ||
); | ||
// TODO: Early check for reserve requirement |
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.
You still have a PR open for this that needs to be updated
funded_channel.splice_ack( | ||
msg, &self.signer_provider, &self.entropy_source, | ||
&self.get_our_node_id(), &self.logger | ||
), chan_entry); |
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: extract splice_ack
result into its var
Implementation of transaction negotiation during splicing.
Builds on 3407 and 3443.
No new phase,Funded(FundedChannel)
is used throughout splicingFundedChannel
andPendingV2Channel
can act as a transaction constructorPendingV2Channel
logic is put behind a trait --FundingTxConstructorV2
RenegotiatingScope
is used to store extra state during splicingFundingChannel
can act as aFundingTxConstructorV2
, using the state fromRenegotiatingScope
(if present)Since bothFundedChannel
andFundingTxConstructor
has context(), context accessors are extracted into a common base trait,ChannelContextProvider
(it is also shared byInitialRemoteCommitmentReceiver
).(Also relevant: #3444)