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: mark {In, Out}boundOpenInfo as deprecated #5242

Merged
merged 14 commits into from
Jan 9, 2025

Conversation

drHuangMHT
Copy link
Contributor

@drHuangMHT drHuangMHT commented Mar 18, 2024

Description

Mark {In, Out}boundOpenInfo as deprecated.
May close #3268.

Notes & open questions

I'm putting off formatting until the change has been accepted for clearer diff.
I have changed all occurrence of OpenInfo with concrete type wherever possible to avoid excessive use of #[allow(deprecated)]. Is this optimal ?

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

@drHuangMHT drHuangMHT marked this pull request as ready for review December 2, 2024 07:02
@drHuangMHT
Copy link
Contributor Author

drHuangMHT commented Dec 2, 2024

@jxs Got a moment to review this? It seems that I cannot assign a reviewer because I don't have the permission, so I have to do an @ mention.

@elenaf9 elenaf9 requested review from jxs and elenaf9 December 7, 2024 19:04
Copy link
Contributor

@elenaf9 elenaf9 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 @drHuangMHT, for this PR, and all of your recent contributions in general!

I think we might be able to avoid some of the #[allow(deprecated)] if we add defaults to the types that currently include {Inbound, Outbound}Info generics (if they are trailing), e.g. to ConnectionEvent. That way the deprecated types won't need to be mentioned by the handlers anymore. Wdyt?

swarm/src/connection.rs Outdated Show resolved Hide resolved
swarm/src/handler.rs Outdated Show resolved Hide resolved
swarm/tests/connection_close.rs Outdated Show resolved Hide resolved
@drHuangMHT
Copy link
Contributor Author

I think we might be able to avoid some of the #[allow(deprecated)] if we add defaults to the types that currently include {Inbound, Outbound}Info generics (if they are trailing)

What about those that are not(whose OpenInfo generic parameter in the middle)? I gave it a shot and it came out quite terrible because I had to reorder the parameters in every implementation. I think the impact will basically be the same as we outright removed {In,Out}boundOpenInfo without a deprecation warning, or even worse because the error messages are rather confusing.

@elenaf9
Copy link
Contributor

elenaf9 commented Dec 10, 2024

What about those that are not(whose OpenInfo generic parameter in the middle)? I gave it a shot and it came out quite terrible because I had to reorder the parameters in every implementation. I think the impact will basically be the same as we outright removed {In,Out}boundOpenInfo without a deprecation warning, or even worse because the error messages are rather confusing.

Yeah, I'd leave those as they are (=> your current implementation).

Copy link
Contributor

@elenaf9 elenaf9 left a comment

Choose a reason for hiding this comment

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

One more comment about using expect instead of allow in all places, rest lgtm!

swarm/src/handler/map_in.rs Outdated Show resolved Hide resolved
@drHuangMHT
Copy link
Contributor Author

Waiting for #5730 for better handling of deprecation warning bypass?

@elenaf9 elenaf9 mentioned this pull request Dec 11, 2024
@elenaf9
Copy link
Contributor

elenaf9 commented Jan 9, 2025

Clippy failing on beta is unrelated, will be fixed with #5802.

Only thing missing is a CHANGELOG entry. It would be great if the entry could be a bit more verbose, so that users know why it {In, Out}boundOpenInfo was removed, and how to refactor their implementation. Maybe something along the lines of (feel to rephrase):

Deprecate ConnectionHandler::{InboundOpenInfo, OutboundOpenInfo}.
Previously, this allowed to pass along data for a pending inbound or outbound substream. The info was then returned to the ConnectionHandler together with the upgraded substream output.
However, substreams in libp2p are completely interchangeably and thus there is no reason to link data to a specific substream. Instead, if data should be added to a substream after its upgrade, the ConnectionHandler should track it (e.g. in a FIFO queue) and match in to ConnectionEvents.

jxs
jxs previously approved these changes Jan 9, 2025
Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for this @drHuangMHT! And @elenaf9 for the review!

@jxs jxs added the send-it label Jan 9, 2025
Copy link
Contributor

mergify bot commented Jan 9, 2025

This pull request has been removed from the queue for the following reason: pull request branch update failed.

The pull request can't be updated

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

@mergify mergify bot dismissed jxs’s stale review January 9, 2025 12:09

Approvals have been dismissed because the PR was updated after the send-it label was applied.

@mergify mergify bot merged commit 4b4f197 into libp2p:master Jan 9, 2025
71 checks passed
@elenaf9
Copy link
Contributor

elenaf9 commented Jan 9, 2025

Wasn't the CHANGELOG entry still missing? Or did I just not see it?

@dariusc93
Copy link
Member

Wasn't the CHANGELOG entry still missing? Or did I just not see it?

Looks like it is missing (thought the CI would have catched that?)

@elenaf9
Copy link
Contributor

elenaf9 commented Jan 9, 2025

Wasn't the CHANGELOG entry still missing? Or did I just not see it?

Looks like it is missing (thought the CI would have catched that?)

Our CI only checks for a CHANGELOG entry if it's not chore / refactor / deps / docs... This PR probably should have been a feat instead of refactor, since refactor usually describes internal changes that are not visible to the outside and change no logic.
MB, I didn't notice when reviewing.

@drHuangMHT would you mind creating a follow-up PR to amend the CHANGELOGs? I think we might even need a CHANGELOG entry in each crate that was touched in this PR.

@drHuangMHT
Copy link
Contributor Author

changelog is still missing

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.

swarm: Deprecate ConnectionHandler::{In,Out}boundOpenInfo
4 participants