Uh oh!
There was an error while loading. Please reload this page.
rustfmt: Run on peer_handler.rs - #3725
Conversation
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
Uh oh!
There was an error while loading. Please reload this page.
martinsaposnic
left a comment
There was a problem hiding this comment.
looks good, no code / behavior changes, just formatting. left a minor question
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| let logger = WithContext::from(&self.logger, peer.their_node_id.map(|p| p.0), None, None); | ||
| let logger = WithContext::from( | ||
| &self.logger, | ||
| peer.their_node_id.map(|p| p.0), |
There was a problem hiding this comment.
Extract into a var of to save some lines, there are others like this in the file
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tnull
left a comment
There was a problem hiding this comment.
Addressed most pending feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| let logger = WithContext::from(&self.logger, peer.their_node_id.map(|p| p.0), None, None); | ||
| let logger = WithContext::from( | ||
| &self.logger, | ||
| peer.their_node_id.map(|p| p.0), |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
5e7f142 to
6403b34CompareCodecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## main #3725 +/- ##
==========================================
+ Coverage 89.11% 89.34% +0.23%
==========================================
Files 156 156 Lines 123435 126684 +3249 Branches 123435 126684 +3249 ==========================================
+ Hits 109995 113191 +3196 - Misses 10758 10828 +70 + Partials 2682 2665 -17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
TheBlueMatt
left a comment
There was a problem hiding this comment.
Highlighted a few patterns that could be used to clean up a number of places across the diff.
| None | ||
| } | ||
| fn handle_reply_channel_range( | ||
| &self, _their_node_id: PublicKey, _msg: msgs::ReplyChannelRange, |
There was a problem hiding this comment.
All the dummy impls can probably get their parameters all replaced with just _, which would make them more dense and no less readable.
There was a problem hiding this comment.
no less readable
Hmm, I tend to disagree on this one. Even if they are not used, its adding context what is not being used.
There was a problem hiding this comment.
I mean sometimes, sure, but when we're implementing a trait with 20 methods where all of the implementations are just "return nothing", I think we probably don't care too much :p
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
6403b34 to
365963cCompare| MessageSendEvent::SendStfu { ref node_id, ref msg} => { | ||
| let logger = WithContext::from(&self.logger, Some(*node_id), Some(msg.channel_id), None); | ||
| MessageSendEvent::SendStfu { ref node_id, ref msg} => { | ||
| let logger = WithContext::from( |
There was a problem hiding this comment.
Not like it has to happen in this PR but this really makes clearer that we need some kind of logger_from_msg utility maybe in wire.rs.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
a96f916 to
56cf495Compare
tnull
left a comment
There was a problem hiding this comment.
Excuse the delay here. Addressed most pending feedback. Let me know if there's something particular left to address.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
wpaulino
commented
Apr 29, 2025
The tests could be cleaned up a bit more #3725 (comment). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
56cf495 to
b7dbd05Comparetnull
commented
Jun 11, 2025
Excuse the delay here once more! Now rebased and addressed this remaining comment by pulling out some more handlers into intermediate variables as a fixup. Let me know if there's something else you'd like to see. |
TheBlueMatt
left a comment
There was a problem hiding this comment.
Basically just #3725 (comment) but a few other nits that look trivial to fix.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
b7dbd05 to
6934b64Compare
TheBlueMatt
left a comment
There was a problem hiding this comment.
Feel free to squash, IMO
6934b64 to
8f3fad6Comparetnull
commented
Jun 12, 2025
Squashed without further changes. |
TheBlueMatt
left a comment
There was a problem hiding this comment.
Ugh, looks like feedback was missed
Uh oh!
There was an error while loading. Please reload this page.
8f3fad6 to
8f48f95Comparetnull
commented
Jun 13, 2025
Force-pushed with the following changes: diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs
index bcae7690f..73c831884 100644
--- a/lightning/src/ln/peer_handler.rs+++ b/lightning/src/ln/peer_handler.rs@@ -4420,48 +4420,40 @@ mod tests {
let act_three_with_init_b = fd_b.outbound_data.lock().unwrap().split_off(0);
- assert!(!peer_a- .peers- .read()- .unwrap()- .get(&fd_a)- .unwrap()- .lock()- .unwrap()- .handshake_complete());+ {+ let peer_a_lock = peer_a.peers.read().unwrap();+ let handshake_complete =+ peer_a_lock.get(&fd_a).unwrap().lock().unwrap().handshake_complete();+ assert!(!handshake_complete);+ }+
assert_eq!(peer_a.read_event(&mut fd_a, &act_three_with_init_b).unwrap(), false);
peer_a.process_events();
- assert!(peer_a- .peers- .read()- .unwrap()- .get(&fd_a)- .unwrap()- .lock()- .unwrap()- .handshake_complete());++ {+ let peer_a_lock = peer_a.peers.read().unwrap();+ let handshake_complete =+ peer_a_lock.get(&fd_a).unwrap().lock().unwrap().handshake_complete();+ assert!(handshake_complete);+ }
let init_a = fd_a.outbound_data.lock().unwrap().split_off(0);
assert!(!init_a.is_empty());
- assert!(!peer_b- .peers- .read()- .unwrap()- .get(&fd_b)- .unwrap()- .lock()- .unwrap()- .handshake_complete());+ {+ let peer_b_lock = peer_b.peers.read().unwrap();+ let handshake_complete =+ peer_b_lock.get(&fd_b).unwrap().lock().unwrap().handshake_complete();+ assert!(!handshake_complete);+ }+
assert_eq!(peer_b.read_event(&mut fd_b, &init_a).unwrap(), false);
peer_b.process_events();
- assert!(peer_b- .peers- .read()- .unwrap()- .get(&fd_b)- .unwrap()- .lock()- .unwrap()- .handshake_complete());++ {+ let peer_b_lock = peer_b.peers.read().unwrap();+ let handshake_complete =+ peer_b_lock.get(&fd_b).unwrap().lock().unwrap().handshake_complete();+ assert!(handshake_complete);+ }
// Make sure we're still connected.
@@ -4565,17 +4557,10 @@ mod tests {
}
- assert_eq!(- peers[0]- .peers- .read()- .unwrap()- .get(&fd_a)- .unwrap()- .lock()- .unwrap()- .gossip_broadcast_buffer- .len(),- OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP- );+ {+ let peer_a_lock = peers[0].peers.read().unwrap();+ let buf_len =+ peer_a_lock.get(&fd_a).unwrap().lock().unwrap().gossip_broadcast_buffer.len();+ assert_eq!(buf_len, OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP);+ }
// Check that if a broadcast message comes in from the channel handler (i.e. it is an
@@ -4583,17 +4568,11 @@ mod tests {
cfgs[0].chan_handler.pending_events.lock().unwrap().push(msg_ev);
peers[0].process_events();
- assert_eq!(- peers[0]- .peers- .read()- .unwrap()- .get(&fd_a)- .unwrap()- .lock()- .unwrap()- .gossip_broadcast_buffer- .len(),- OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP + 1- );++ {+ let peer_a_lock = peers[0].peers.read().unwrap();+ let buf_len =+ peer_a_lock.get(&fd_a).unwrap().lock().unwrap().gossip_broadcast_buffer.len();+ assert_eq!(buf_len, OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP + 1);+ }
// Finally, deliver all the messages and make sure we got the right count. Note that there
@@ -4605,14 +4584,11 @@ mod tests {
drain_queues!();
- assert!(peers[0]- .peers- .read()- .unwrap()- .get(&fd_a)- .unwrap()- .lock()- .unwrap()- .gossip_broadcast_buffer- .is_empty());+ {+ let peer_a_lock = peers[0].peers.read().unwrap();+ let empty =+ peer_a_lock.get(&fd_a).unwrap().lock().unwrap().gossip_broadcast_buffer.is_empty();+ assert!(empty);+ }+
assert_eq!(
cfgs[1].routing_handler.chan_anns_recvd.load(Ordering::Relaxed), |
ldk-reviews-bot
commented
Jun 16, 2025
🔔 1st Reminder Hey @TheBlueMatt! This PR has been waiting for your review. |
TheBlueMatt
left a comment
There was a problem hiding this comment.
Landing, but will open a quick PR to address the followups.
Uh oh!
There was an error while loading. Please reload this page.
| // Check that the peers map is consistent with the | ||
| // node_id_to_descriptor map, as this has been broken | ||
| // before. |
There was a problem hiding this comment.
This comment is about the debug_assert so should come after the their_node_id wipe.
| if let Err(()) = self.message_handler.route_handler.peer_connected(their_node_id, &msg, peer_lock.inbound_connection) { | ||
| log_debug!(logger, "Route Handler decided we couldn't communicate with peer {}", log_pubkey!(their_node_id)); | ||
| return Err(PeerHandleError { }.into()); | ||
| let connection = peer_lock.inbound_connection; |
There was a problem hiding this comment.
Ha, inbound may be a more readable name :)
| @@ -2878,18 +3486,20 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM | |||
| debug_assert!(peer.channel_encryptor.is_ready_for_encryption()); | |||
| debug_assert!(peer.their_node_id.is_some()); | |||
| loop { // Used as a `goto` to skip writing a Ping message. | |||
| loop { | |||
| // Used as a `goto` to skip writing a Ping message. | |||
There was a problem hiding this comment.
This is now ambiguous whether its referring to the loop or the following line.
| fn create_network<'a>( | ||
| peer_count: usize, cfgs: &'a Vec<PeerManagerCfg>, | ||
| ) -> Vec< | ||
| PeerManager< |
No description provided.