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(request-response): don't use upgrade infrastructure #3914

Merged
merged 34 commits into from
Oct 26, 2023

Conversation

thomaseizinger
Copy link
Contributor

@thomaseizinger thomaseizinger commented May 11, 2023

Description

This patch refactors libp2p-request-response to not use the "upgrade infrastructure" provided by libp2p-swarm. Instead, we directly convert the negotiated streams into futures that read and write the messages.

Related: #3268.
Related: #2863.

Attributions

Co-authored-by: Yiannis Marangos yiannis@eiger.co

Notes & open questions

I am putting this up as an initial draft. I think some clean-up can be done but overall, I am glad it is working this well.

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

@thomaseizinger thomaseizinger marked this pull request as draft May 11, 2023 21:25
Base automatically changed from refactor/req-res-no-close-connection to master May 15, 2023 02:40
Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Direction looks good to me! Assuming that you don't want a final review yet.

protocols/request-response/src/handler.rs Show resolved Hide resolved
protocols/request-response/src/handler.rs Outdated Show resolved Hide resolved
@thomaseizinger
Copy link
Contributor Author

Direction looks good to me! Assuming that you don't want a final review yet.

A high-level review would be appreciated :)

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Direction looks good to me.

@thomaseizinger thomaseizinger marked this pull request as ready for review July 31, 2023 11:38
@thomaseizinger
Copy link
Contributor Author

@mxinden This is ready for review and is the 2nd last piece towards starting the work around a simpler design of ConnectionHandlers.

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

We need to bound the number of concurrent inbound streams. Otherwise this change looks good to me.

(Surprised that this ends up being 2 lines less instead of many new lines in addition.)

protocols/request-response/src/handler.rs Outdated Show resolved Hide resolved
protocols/request-response/src/handler.rs Show resolved Hide resolved
@mergify

This comment was marked as resolved.

@mergify

This comment was marked as resolved.

@mergify

This comment was marked as resolved.

@thomaseizinger thomaseizinger marked this pull request as ready for review October 20, 2023 01:21
@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2023

This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏

@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2023

This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏

@thomaseizinger
Copy link
Contributor Author

This needs some more thinking on how we want to report errors. Also, I noticed that several of the enum variants are actually unused so we should properly clean this up.

I'll see to look into it next week. Help much appreciated though :)

@mergify

This comment was marked as resolved.

@mxinden
Copy link
Member

mxinden commented Oct 26, 2023

@thomaseizinger let me know once this is ready for another review.

@thomaseizinger
Copy link
Contributor Author

@thomaseizinger let me know once this is ready for another review.

It is! :)

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Great work! Happy for this to land.

@mergify mergify bot merged commit fd7b5ac into master Oct 26, 2023
72 checks passed
@mergify mergify bot deleted the refactor/req-res-on-upgrade branch October 26, 2023 17:10
umgefahren pushed a commit to umgefahren/rust-libp2p that referenced this pull request Mar 8, 2024
This patch refactors `libp2p-request-response` to not use the "upgrade infrastructure" provided by `libp2p-swarm`. Instead, we directly convert the negotiated streams into futures that read and write the messages.

Related: libp2p#3268.
Related: libp2p#2863.

Pull-Request: libp2p#3914.

Co-authored-by: Yiannis Marangos <yiannis@eiger.co>
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.

4 participants