-
Notifications
You must be signed in to change notification settings - Fork 364
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
Don't rebroadcast redundant closing TX upon restart #2001
Don't rebroadcast redundant closing TX upon restart #2001
Conversation
While we don't rebroadcast the latest holder commitment transactions in `ChannelMonitor::update_monitor()` anymore if we had previously seen a closing tx on-chain, we still do so upon restarting / deserlization of `ChannelManager` With this change, we now also refrain from rebroadcasting upon restarting.
Thanks @tnull this should resolve the issue when initialising a node from an existing config after closing the channel |
Codecov ReportBase: 90.90% // Head: 90.88% // Decreases project coverage by
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #2001 +/- ##
==========================================
- Coverage 90.90% 90.88% -0.03%
==========================================
Files 99 99
Lines 52570 52576 +6
Branches 52570 52576 +6
==========================================
- Hits 47789 47783 -6
- Misses 4781 4793 +12
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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, just one minor comment
Because this broadcast is on init, its likely we have a stale view of the chain. What happens (and maybe its worth adding a test) if we start thinking a channel's funding output is spent (with 1 conf) but then after running for a second we see a reorg and now its not spent? We'd need to rebroadcast our local commitment tx in that case. |
I'm curious what this issue is - transactions may fail to broadcast for any number of reasons, it shouldn't be an error to see a transaction which fails to enter the mempool. |
Agreed.
We def. need to rebroadcast the commitment tx in case the original closing tx is reorged out, as even before #1922 our redundant broadcast would have failed. Relying on rebroadcasting on restart doesn't work, as it may be a long time before the node is restarted. I hope we do this right anyways, but currently fail to see where we do it. Will see to include a fix and test.
Ah, when restarting LDK Node nodes we'd hit an |
Ah, good point. I guess here we'd only want to avoid the broadcast once we've seen a commitment onchain with >= 6 confs, i.e., once |
Not sure why the restart case would be that different from #1922? After the restart we to sync to chain tip anyways and then need to react to any reorgs encountered? |
Wait, why would it have failed? The bitcoind we're sending to should be synced, hopefully, even if we aren't.
Yea, that's true. we should handle this explicitly, no complaints here.
Heh, right, can't do that :). I guess if we fix this properly we can change ChannelManager to not broadcast during read, which would be nice for issues like this. |
For one broadcast to everything besides a local bitcoind instance's mempool could be pretty unreliable. My main point however was that any redundant broadcasts would just fail, and broadcasting once more on restart really doesn' t protect us at all from a reorg happening just after having read ChannelManager: in both cases (avoiding redundancy or just having it fail), we'd need to be able to react to reorgs ASAP. |
Just noting we could avoid the broadcast on restart if the commitment is confirmed past our expectation for reorgs. However, I agree we should avoid broadcasting at all during restart and should only broadcast if it's not confirmed anymore after we detect a reorg and we're synced. |
So it sounds like we're all on the same page. IMO we should hold this until we can remove the broadcast-during-deser entirely with a complete fix on the monitor side. |
After having a look at the code and speaking to @wpaulino offline I was under the impression that our current rebroadcasting logic in |
Hmm, we have a bunch of logic under |
When generating the claim for an untractable package, we just broadcast the transaction as shown below:
|
Ah, okay, sorry, I had missed where we do |
The channel's already closed at this point though, so hasn't one already been generated? |
Nvm, checking that it's not redundant would happen anyways in this case. So question would indeed be if we really need to regenerate the update step at all? |
I'm not sure? The point of this check is to be a belt-and-suspenders check that the monitor knows the channel is closed if the manager thinks it is. I'm not at all confident there isn't some race case on write order that would break that. |
After reviewing #1897, I see there's a chance of this happening if the |
I don't think so? We could have a channel be created, persist the monitor, update the channel once or twice, force-close the channel, fail to update the monitor, and crash, all without having persisted the |
Closing this as superseded by #2059. |
As of #1922, we don't rebroadcast the latest holder commitment transactions in
ChannelMonitor::update_monitor()
anymore if we had previously seen a closing tx on-chain. However, we still do so upon restarting / deserialization ofChannelManager
.With this change, we now also refrain from rebroadcasting upon restarting.
Let me know if there is a reason we always need to rebroadcast immediately.