-
Notifications
You must be signed in to change notification settings - Fork 432
Refactor BroadcasterInterface to include BroadcastType
#4353
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 @TheBlueMatt as a reviewer! |
4f6a8a4 to
be02cec
Compare
TheBlueMatt
left a 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.
docs need a lot of love
| /// A single funding transaction may establish multiple channels when using batch funding. | ||
| channel_ids: Vec<ChannelId>, | ||
| }, | ||
| /// A cooperative close transaction mutually agreed upon by both parties. |
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 mean all transactions are mutually agreed upon by both parties? Maybe describe what a coop close tx means
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.
Hmm, changed it up a bit, but let me know what exactly is missing for you.
be02cec to
4f6a8a4
Compare
| // we derive a channel_id from the funding outpoint if not present. | ||
| let channel_id = channel_id.or_else(|| { | ||
| channel_parameters.funding_outpoint | ||
| .map(|op| ChannelId::v1_from_funding_outpoint(op)) |
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 super excited about the extra persisted field and the fallback here. I explored using ReadableArgs to hand in the ChannelId but that doesn't work with the read order in ChannelMonitor. Any other ideas/preferences? (@TheBlueMatt / @wpaulino)
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 swear I wrote a comment here and github just ate it. We don't need to do any handling in onchaintx.rs - the ChannelMonitor that calls it and deserializes it has the channel id, so we just need to pass it in (either in the deser method and store it or to the methods that need it)
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 swear I wrote a comment here and github just ate it.
Hmm, I had added, then deleted a similar comment before, maybe it was on there?
We don't need to do any handling in
onchaintx.rs- theChannelMonitorthat calls it and deserializes it has the channel id, so we just need to pass it in (either in the deser method and store it or to the methods that need it)
As mentioned above, I explored that briefly (hence why I deleted the original comment, as I briefly thought I found a better solution), but that isn't straightforward as in ChannelMonitor::read we first read the OnchainTxHandler then the channel ID as part of the TLV fields, so we can't pass it via ReadableArgs. We could have the field being an option and add a setter like OnchainTxHandler::set_channel_id to hand it in afterwards, but that is also very ugly, hence why I'm asking for better ideas.
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.
Ah, yea, i think I had the comment on the previous one and it got dropped then I missed your note at the end cause I didn't re-read. Anyway, yea, Option is kinda annoying, we could cheat and just store a [0; 32] and overwrite it after we finish reading the monitor? Given we only need it in a few places we could also pass it in.
4f6a8a4 to
fb8378c
Compare
Add a `BroadcastType` enum to provide context about the type of transaction being broadcast. This information can be useful for logging, filtering, or prioritization purposes. The `BroadcastType` variants are: - `Funding`: A funding transaction establishing a new channel - `CooperativeClose`: A cooperative close transaction - `UnilateralClose`: A force-close transaction - `AnchorBump`: An anchor transaction for CPFP fee-bumping - `Claim`: A transaction claiming outputs from commitment tx - `Sweep`: A transaction sweeping spendable outputs to wallet Co-Authored-By: HAL 9000 Signed-off-by: Elias Rohrer <dev@tnull.de>
We add the `ChannelId` as context to the just-added `BroadcastType` enum. Co-Authored-By: HAL 9000 Signed-off-by: Elias Rohrer <dev@tnull.de>
fb8378c to
54b52f3
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4353 +/- ##
=======================================
Coverage 86.08% 86.09%
=======================================
Files 156 156
Lines 102428 102489 +61
Branches 102428 102489 +61
=======================================
+ Hits 88179 88236 +57
- Misses 11754 11758 +4
Partials 2495 2495
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] | ||
| pub enum BroadcastType { | ||
| /// A funding transaction establishing a new channel. | ||
| Funding, |
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.
Splice transactions should have their own variant, no?
| /// A single funding transaction may establish multiple channels when using batch funding. | ||
| channel_ids: Vec<ChannelId>, | ||
| }, | ||
| /// A transaction cooperatively closing a channel. |
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 the thing missing here and elsewhere is the why - if I'm using this for improving my logging I want to understand what led to this transaction and what the implications of it are. eg this have a link to ChannelManager::close_channel (noting of course that the counterparty could have initiated as well), UnilateralClose should have a link to ChannelManager::force_close_* and note that it could also happen due to other errors.
Fixes #3566.
and: