-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(identify): handle partial push
messages
#4495
Conversation
The protocol isn't too decisive on this but js-libp2p does not send publicKey on `identify/push` messages. This results in rust-libp2p ignoring the messages due to failed publicKey parsing. https://github.com/libp2p/js-libp2p/blob/88c47f51f9d67a6261e4ac65c494cd1e6e4ed8dd/packages/libp2p/src/identify/identify.ts#L205-L210 Note that missing fields should be ignored, as peers may choose to send partial updates containing only the fields whose values have changed. publicKey is this node's public key (which also gives its node.ID) - may not need to be sent, as secure channel implies it has been sent. - then again, if we change / disable secure channel, may still want it.
Is it optional for all usages of identify or only for push? This is a breaking API change so we'll have to hold it until we decide to make another breaking release (or we figure out a way to make it not breaking). |
I had to check myself. According to the specification, only for push. https://github.com/libp2p/specs/tree/master/identify#identifypush Not sending the public key on each push seems like a premature bandwidth optimization to me. Public keys are small, push events should be rare. Am I missing something? I am fine moving forward with the proposal as is with the next breaking change. Alternative approach would be to use the last sent public key in case it is missing in the current message.
This to me implies that the peer must have sent the non-changed fields in previous messages in order to be able to omit them in upcoming ones. |
Nice catch @Marcel-G. Thank you for debugging and reporting! |
Would we be emitting the diff or compute the latest identify info based on the updated data? The latter would be backwards-compatible with our API so we can ship it immediately :) |
8177acd
to
1fab3ff
Compare
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.
Thanks for making the changes!
I have a few more suggestions to make this consistent.
ece63c8
to
88709d6
Compare
identify/push
messages
88709d6
to
5449e3d
Compare
Please avoid force-pushing! :) |
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.
Thanks for making the changes! There a few more minor things to sort out to make this actually a backwards-compatible change from an API PoV but this is close to being ready. Note that we will also need a changelog entry and a patch-version bump for this :)
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.
Cool, almost ready!
As a last thing, we'll need a changelog entry and a version bump by a patch-version in the Cargo.toml
. You'll also have to bump the version of libp2p-identify
in the root Cargo.toml
.
identify/push
messagespush
messages
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.
Awesome! Thank you for being so responsive and incorporating all the feedback. I think we've landed at a pretty decent solution :)
Thank you for the work. I find this a clean fix. |
Description
According to the spec, all fields within push messages are optional. To handle missing fields, we deserialize push messages into a different struct, patch the previously received, full identify message with it and emit this as the new info.
Previously, we failed to parse the message which causes incompatibility with js-libp2p nodes as they don't send the public key in push messages. See https://github.com/libp2p/js-libp2p/blob/88c47f51f9d67a6261e4ac65c494cd1e6e4ed8dd/packages/libp2p/src/identify/identify.ts#L205-L210.
Change checklist