Skip to content
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

refactor(rendezvous): rewrite using libp2p-request-response #4051

Merged
merged 37 commits into from
Jun 14, 2023

Conversation

dgarus
Copy link
Contributor

@dgarus dgarus commented Jun 8, 2023

Description

Fixes #3878.

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@dgarus
Copy link
Contributor Author

dgarus commented Jun 8, 2023

@thomaseizinger
Hello, Thomas!
I did the first version of the PR, could you please take a look?
I have a problem with the can_combine_client_and_server test and while I don't catch why.

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! I'll do an in-depth review early next week!

protocols/rendezvous/src/server.rs Outdated Show resolved Hide resolved
@dgarus dgarus marked this pull request as ready for review June 9, 2023 12:38
@thomaseizinger
Copy link
Contributor

Clippy seems to be unhappy :)

@dgarus
Copy link
Contributor Author

dgarus commented Jun 9, 2023

Clippy seems to be unhappy :)

Clippy is satisfied now

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This is a really high-quality contribution!

A few minor comments but overall this looks really good :)

protocols/rendezvous/Cargo.toml Outdated Show resolved Hide resolved
protocols/rendezvous/src/codec.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/codec.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/codec.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/codec.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
dgarus and others added 3 commits June 12, 2023 22:38
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
@thomaseizinger thomaseizinger changed the title feat: Rendezvous based on libp2p-request-response protocol refactor(rendezvous): rewrite using libp2p-request-response Jun 13, 2023
@dgarus
Copy link
Contributor Author

dgarus commented Jun 13, 2023

Thank you! This is a really high-quality contribution!

A few minor comments but overall this looks really good :)

Thanks for your high estimation of my contribution, it really motivates me!

@dgarus
Copy link
Contributor Author

dgarus commented Jun 13, 2023

@thomaseizinger
I fixed your comments, please, take a look.

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I am looking forward to merging this.

A few more comments.

protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/codec.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/server.rs Outdated Show resolved Hide resolved
@dgarus
Copy link
Contributor Author

dgarus commented Jun 14, 2023

@thomaseizinger
Hello!
Thank you so much for the review.

I fixed your comments, please, take a look.

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow-up commits. A few more things but this is very close to being ready :)

protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/client.rs Outdated Show resolved Hide resolved
}
_ => unreachable!(),
_ => unreachable!("rendezvous clients never receive requests"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't safe. We cannot statically ensure that we don't receive a request, the remote could send us any message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In follow-up work, we could redesign this to have two enums: one for requests and one for responses. Then our codec could ensure that and inbound message on the client is always a response.

protocols/rendezvous/src/codec.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/server.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/server.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/server.rs Outdated Show resolved Hide resolved
protocols/rendezvous/src/server.rs Outdated Show resolved Hide resolved
@dgarus
Copy link
Contributor Author

dgarus commented Jun 14, 2023

@thomaseizinger

I removed RendezvousCodec and implemented Decoder/Encoder for Codec.
Looks good to me )) Could you please review?

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done, just one final comment!

protocols/rendezvous/src/server.rs Outdated Show resolved Hide resolved
@thomaseizinger
Copy link
Contributor

I removed RendezvousCodec and implemented Decoder/Encoder for Codec.

Good idea!!

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for doing this refactoring!

It is one of the main remaining blockers for #3268 which is an improvement I am very much looking forward to!

@thomaseizinger
Copy link
Contributor

We didn't have to touch a single line in the tests! A picture-perfect refactoring!

@dgarus
Copy link
Contributor Author

dgarus commented Jun 14, 2023

Thanks a lot for doing this refactoring!

It is one of the main remaining blockers for #3268 which is an improvement I am very much looking forward to!

Thank you a lot for the review!

@mergify mergify bot merged commit b8ceecc into libp2p:master Jun 14, 2023
@dgarus dgarus deleted the 3878-rendezvous-based-on-req-resp branch June 15, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rendezvous: rewrite using libp2p-request-response
2 participants