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

fix!: remove localPeer from secureInbound and secureOutbound #2304

Merged
merged 4 commits into from
Aug 14, 2024

Conversation

wemeetagain
Copy link
Member

Description

  • Remove localPeer: PeerId first parameter from secureInbound and secureOutbound in ConnectionEncrypter

Requiring the local peer id in connection encryption appears to be historical cruft. The more current approach would be to have a ConnectionEncrypter be specific to a single peer id, passed in during instantiation in its Components.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

@wemeetagain wemeetagain requested a review from a team as a code owner December 5, 2023 22:04
@achingbrain achingbrain added the version-2.0 PRs that will be released in libp2p v2 label Dec 20, 2023
@dhuseby
Copy link
Contributor

dhuseby commented May 21, 2024

Blocked waiting for the next breaking change milestone

@achingbrain achingbrain mentioned this pull request Jul 18, 2024
27 tasks
@achingbrain achingbrain changed the base branch from main to release-v2.0 August 1, 2024 12:38
@achingbrain
Copy link
Member

achingbrain commented Aug 9, 2024

Depends on:

Copy link
Member

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I added a few questions for the tests. Much nicer to have each encrypter have the peerId within them.

approved, but not approving because tests are failing and I believe we're still waiting on another package

encrypter.secureInbound(remotePeer, inbound),
encrypter.secureOutbound(localPeer, outbound, wrongPeer)
encrypter.secureInbound(inbound, remotePeer),
encrypter.secureOutbound(outbound, wrongPeer)
Copy link
Member

Choose a reason for hiding this comment

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

Curious, do we need an encrypterRemote here like we have in packages/connection-encrypter-plaintext/test/index.spec.ts ?

If we can do either/or, it would be nice to use the same setup to not cause confusion and questions like this one :)

If we can't, maybe a comment explaining why? (maybe only for libp2p noobs like myself)

Copy link
Member

Choose a reason for hiding this comment

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

It would make the test easier to read but this encrypter is stateless which is why it works as-is.

Comment on lines +57 to +58
cryptoRemote.secureInbound(localConn),
crypto.secureOutbound(remoteConn, remotePeer)
Copy link
Member

Choose a reason for hiding this comment

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

similar question about dissimilarities between encrypters we create&call for secureInbound and secureOutbound calls

@achingbrain achingbrain merged commit dc8c1ec into release-v2.0 Aug 14, 2024
24 checks passed
@achingbrain achingbrain deleted the fix/remove-peer-id-encrypter branch August 14, 2024 13:16
achingbrain added a commit that referenced this pull request Sep 6, 2024
Requiring the local peer id in connection encryption appears to be historical cruft. The more current approach would be to have a `ConnectionEncrypter` be specific to a single peer id, passed in during instantiation in its Components.

BREAKING CHANGE: removes `localPeer: PeerId` first parameter from `secureInbound` and `secureOutbound` in `ConnectionEncrypter`

---------

Co-authored-by: Alex Potsides <alex@achingbrain.net>
achingbrain added a commit that referenced this pull request Sep 6, 2024
Requiring the local peer id in connection encryption appears to be historical cruft. The more current approach would be to have a `ConnectionEncrypter` be specific to a single peer id, passed in during instantiation in its Components.

BREAKING CHANGE: removes `localPeer: PeerId` first parameter from `secureInbound` and `secureOutbound` in `ConnectionEncrypter`

---------

Co-authored-by: Alex Potsides <alex@achingbrain.net>
achingbrain added a commit that referenced this pull request Sep 6, 2024
Requiring the local peer id in connection encryption appears to be historical cruft. The more current approach would be to have a `ConnectionEncrypter` be specific to a single peer id, passed in during instantiation in its Components.

BREAKING CHANGE: removes `localPeer: PeerId` first parameter from `secureInbound` and `secureOutbound` in `ConnectionEncrypter`

---------

Co-authored-by: Alex Potsides <alex@achingbrain.net>
@achingbrain achingbrain mentioned this pull request Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version-2.0 PRs that will be released in libp2p v2
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants