-
Notifications
You must be signed in to change notification settings - Fork 423
Consistently use wire::Message for encoding
#4244
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?
Consistently use wire::Message for encoding
#4244
Conversation
|
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
bea6480 to
3c0a1d7
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4244 +/- ##
==========================================
+ Coverage 89.33% 89.34% +0.01%
==========================================
Files 180 180
Lines 138680 139092 +412
Branches 138680 139092 +412
==========================================
+ Hits 123888 124272 +384
- Misses 12172 12192 +20
- Partials 2620 2628 +8
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:
|
|
🔔 1st Reminder Hey @TheBlueMatt! This PR has been waiting for your review. |
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.
It seems weird to replace a correct but unused implementation with an incorrect/panicing one? Can we remove the bound instead?
|
👋 The first review has been submitted! Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer. |
Previously, `enqueue_message` took an `M: Type + Writeable` reference, which didn't make use of our `wire::Message` type, which turned out to be rather confusing. Here, we use `Message` consistently in `PeerManager`'s `enqueue_message`, but also in `encrypt_message`, etc. While at it we also switch to move semantics, which is a nice cleanup.
734b4e2 to
c7a57c8
Compare
wire::Message's Writeable implementation with unreachable!wire::Message for encoding
Hmm, turns out I had overlooked a single case where it was used (only when writing out messages on shutdown via a) always consistently use |
|
🔔 1st Reminder Hey @TheBlueMatt! This PR has been waiting for your review. |
| &MessageSendEvent::UpdateHTLCs { .. } => false, | ||
| &MessageSendEvent::SendRevokeAndACK { .. } => false, | ||
| &MessageSendEvent::SendClosingSigned { .. } => false, | ||
| #[cfg(simple_close)] |
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've historically not cfg-flagged messages even if the implementation in LDK isn't complete. There doesn't really seem any reason to imo.
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've historically not cfg-flagged messages even if the implementation in LDK isn't complete. There doesn't really seem any reason to imo.
Hmm, yeah, debatable. But this PR seems the wrong place to drop the cfg(simple_close). I only added the instances that became necessary by the new approach.
lightning/src/ln/peer_handler.rs
Outdated
|
|
||
| /// Append a message to a peer's pending outbound/write buffer | ||
| fn enqueue_message<M: wire::Type>(&self, peer: &mut Peer, message: &M) { | ||
| fn enqueue_message<T: wire::Type>(&self, peer: &mut Peer, message: Message<T>) { |
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.
Oh nice, this should reduce codegen somewhat, though you should be able to remove lots of : Message<<CMH::Target as CustomMessageReader>::CustomMessage> across the file if you make this non-generic:
| fn enqueue_message<T: wire::Type>(&self, peer: &mut Peer, message: Message<T>) { | |
| fn enqueue_message(&self, peer: &mut Peer, message: Message<<CMH::Target as CustomMessageReader>::CustomMessage>>) { |
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, indeed, now added a fixup.
Now that we consistently use `wire::Message` everywhere, it's easier to simply use `Message::write`/`Type::write` instead of heaving yet another `wire::write` around. Here we drop `wire::write`, replace the `encode_msg` macro with a method that takes `wire::Message`, and convert a bunch of additional places to move semantics.
c7a57c8 to
3b186c2
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.
Feel free to squash
Uh oh!
There was an error while loading. Please reload this page.