-
Notifications
You must be signed in to change notification settings - Fork 366
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
[Splicing] Preserve funding_transaction
for the later lifecycle of the channel
#3317
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3317 +/- ##
==========================================
+ Coverage 89.66% 90.88% +1.22%
==========================================
Files 126 127 +1
Lines 102676 115316 +12640
Branches 102676 115316 +12640
==========================================
+ Hits 92062 104806 +12744
+ Misses 7894 7869 -25
+ Partials 2720 2641 -79
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
2e925ee
to
78f428e
Compare
78f428e
to
bb043a1
Compare
bb043a1
to
020ac76
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.
Does this mean existing channels cannot be spliced?
lightning/src/ln/channel.rs
Outdated
@@ -5336,7 +5349,10 @@ impl<SP: Deref> Channel<SP> where | |||
(matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if !flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH)) || | |||
matches!(self.context.channel_state, ChannelState::ChannelReady(_))) | |||
{ | |||
self.context.funding_transaction.take() | |||
let res = self.context.funding_transaction_unless_rebroadcast(); | |||
// Note: this is legacy logic, prevents (re)broadcasting twice, unclear if needed |
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.
Not sure what is meant by this. Why is it legacy logic?
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.
What I mean by legacy:
- I don't fully understand why it works this way
- I suspect it is not by intention
- but I chose to introduce an extra field just to keep the exact behavior
- changing it would break one unit tests, and who knows what else in the field
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.
@TheBlueMatt Any thoughts on making funding_transaction
a three-state enum instead of introducing a flag and continuing to use Option
? We'd probably need the flag in the serialization logic, though.
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 could do that. That said, I do think the rebroadcasting logic is really dumb right now, so this may be an opportunity to clean it up. We could/maybe should drop all the tracking of if we broadcasted a transaction and replace it with a much simpler "if its not confirmed, broadcast it" heuristic.
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.
Is there any downside for occasional repeated broadcast? At most some unnecessary resource usage?
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.
Not hugely, no. We do get users confused when broadcasts fail all the time, so we mostly try to avoid it, but there's not a huge cost. We should definitely not rebroadcast forever though.
020ac76
to
8339270
Compare
lightning/src/ln/channel.rs
Outdated
@@ -8934,6 +8954,8 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider { | |||
let cur_holder_commitment_point = Some(self.context.holder_commitment_point.current_point()); | |||
let next_holder_commitment_point = self.context.holder_commitment_point.next_point(); | |||
|
|||
let funding_transaction_rebroadcast_flag = Some(self.context.funding_transaction_rebroadcast_flag); |
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.
Instead of wrapping this, use required
below.
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.
It's optional due to backwards compatibility.
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.
It's an odd TLV so older versions will simply ignore it.
lightning/src/ln/channel.rs
Outdated
@@ -9289,6 +9312,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch | |||
let mut next_holder_commitment_point_opt: Option<PublicKey> = None; | |||
let mut is_manual_broadcast = None; | |||
|
|||
let mut funding_transaction_rebroadcast_flag: Option<bool> = None; |
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.
And then use (default_value, false)
below instead of option
.
lightning/src/ln/channel.rs
Outdated
@@ -5336,7 +5349,10 @@ impl<SP: Deref> Channel<SP> where | |||
(matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if !flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH)) || | |||
matches!(self.context.channel_state, ChannelState::ChannelReady(_))) | |||
{ | |||
self.context.funding_transaction.take() | |||
let res = self.context.funding_transaction_unless_rebroadcast(); | |||
// Note: this is legacy logic, prevents (re)broadcasting twice, unclear if needed |
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.
@TheBlueMatt Any thoughts on making funding_transaction
a three-state enum instead of introducing a flag and continuing to use Option
? We'd probably need the flag in the serialization logic, though.
Note: Changing this behavior causes a single test case to fail: The check that fails expects 1 broadcasted transaction, while with the change it will have the transaction broadcasted 4 times. I suspect this change does not really affect the desired behavior, this checks is simply over-specific and that can be updated, and the change is acceptable.
|
8339270
to
6103652
Compare
Alternative simpler solution in #3380 -- never clears the |
Supersceded by #3380. |
Fixes #3300
In splicing, the funding transaction (not just the ID) is needed during splice negotiation.
Funding transaction is kept in field
ChannelContext.funding_transaction
.However, the way it is currently used is that it is cleared when the tx is broadcast, and this fact is used in some logic.
This change:
ChannelContext.funding_transaction
when tx is broadcast, but it's preservedfunding_transaction_broadcast
bool field to indicate if it has been broadcastSo behavior of not (re)broadcasting twice is preserve (though I am not sure whether this was intentional and it is needed, one test fails if this is changed (
test_completed_payment_not_retryable_on_reload
)).Alternative would be to leave
funding_transaction
unchanged, and introduce a newfunding_transaction_saved
field, that is set the same way, but never cleared. This way existing logic would not be affected, but the tx would be kept in two copies.