-
Notifications
You must be signed in to change notification settings - Fork 404
Remove peers from the node_id_to_descriptor even without init #2060
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
Remove peers from the node_id_to_descriptor even without init #2060
Conversation
When a peer has finished the noise handshake, but has not yet completed the lightning `Init`-based handshake, they will be present in the `node_id_to_descriptor` set, even though `Peer::handshake_complete()` returns false. Thus, when we go to disconnect such a peer, we must ensure that we remove it from the descriptor set as well. Failing to do so caused an `Inconsistent peers set state!` panic in the C bindings network handler.
Codecov ReportPatch coverage:
📣 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 #2060 +/- ##
==========================================
+ Coverage 87.21% 87.30% +0.09%
==========================================
Files 100 100
Lines 44516 45143 +627
Branches 44516 45143 +627
==========================================
+ Hits 38825 39413 +588
- Misses 5691 5730 +39
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 after squash
63bf2f1
63bf2f1
to
8c61106
Compare
Squashed, added one more assertion, and added a race-detection test. |
8c61106
to
157e496
Compare
Oops, set the new test to std-only cause it uses threads. |
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.
ACK with 1 comment
157e496
to
ea88c3c
Compare
Was able to repro locally – LGTM after squash. +1 for adding a comment to the new test. |
This removes two panics from `PeerHandler` which can trivially be `debug_assert!(false); return Err;`s, and adds another `debug_assertion` on internal state consistency during disconnect.
ea88c3c
to
b3dc23a
Compare
Added a comment in the test and squashed: $ git diff-tree -U1 ea88c3cf7 b3dc23aa8
diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs
index e6566cc0d..742bf3fdc 100644
--- a/lightning/src/ln/peer_handler.rs
+++ b/lightning/src/ln/peer_handler.rs
@@ -2309,2 +2309,5 @@ mod tests {
fn fuzz_threaded_connections() {
+ // Spawn two threads which repeatedly connect two peers together, leading to "got second
+ // connection with peer" disconnections and rapid reconnect. This previously found an issue
+ // with our internal map consistency, and is a generally godd smoke test of disconnection.
let cfgs = Arc::new(create_peermgr_cfgs(2)); |
This test fails on the bug fixed two commits ago with the additional assertions in the previous commit.
b3dc23a
to
48946d9
Compare
$ git diff-tree -U0 b3dc23aa 48946d9a
diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs
index 742bf3fdc..41bbf5b49 100644
--- a/lightning/src/ln/peer_handler.rs
+++ b/lightning/src/ln/peer_handler.rs
@@ -2312 +2312 @@ mod tests {
- // with our internal map consistency, and is a generally godd smoke test of disconnection.
+ // with our internal map consistency, and is a generally good smoke test of disconnection. |
CI is being dumb, somehow the job got cancelled, but I'm just gonna merge and fix it later if anything breaks 🚀 |
When a peer has finished the noise handshake, but has not yet
completed the lightning
Init
-based handshake, they will bepresent in the
node_id_to_descriptor
set, even thoughPeer::handshake_complete()
returns false. Thus, when we go todisconnect such a peer, we must ensure that we remove it from the
descriptor set as well.
Failing to do so caused an
Inconsistent peers set state!
panic inthe C bindings network handler.