Repository navigation
Conversation
`compute_new_protocol_status` returned `reported: true` whenever kademlia support did not change, even if the current status had never been reported. A second protocol report arriving before the handler was polled therefore swallowed `ProtocolConfirmed`, and the peer was never added to the routing table on that connection. Return the current status unchanged instead.
Contributor
|
This pull request has merge conflicts. Could you please resolve them @0xShadowX? 🙏 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A remote that speaks kademlia can end up never being added to the routing table when another behaviour polled before
kadin a#[derive(NetworkBehaviour)]reports several protocol changes back to back (identify does this when it emitsAddedandRemovedtogether).The kad handler keeps a
ProtocolStatus { supported, reported }and only emitsProtocolConfirmedfrompollwhilereportedis false.compute_new_protocol_statusreturnsreported: truewhen support did not change, without looking at whether the current status was already reported. So if the status is{ supported: true, reported: false }(first report or first negotiated stream) and another report that doesn't touch kademlia comes in before the handler is polled, the confirmation is dropped.on_connection_handler_eventnever seesProtocolConfirmed, so the peer is not inserted and the connection is not marked as connected.The fix returns
current_statuswhen nothing changed. The quickcheck property asserted the old behaviour, so it now checks thatreportedis carried over.Tests:
The integration test uses a small behaviour polled before kad that reports kademlia and then an unrelated protocol. On master it times out waiting for
RoutingUpdated.kad 0.49.0 is released, so this bumps it to 0.49.1.
cargo clippy -p libp2p-kad --all-targets --all-featuresclean