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(noise): modify message framing #4548

Merged
merged 26 commits into from
Oct 26, 2023
Merged

Conversation

0xcrust
Copy link
Contributor

@0xcrust 0xcrust commented Sep 24, 2023

Description

Resolves #4488.

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

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! That is great progress and one can already see that the implementation will become much simpler with this.

I've left some comments with a few ideas! :)

transports/noise/src/io/framed.rs Outdated Show resolved Hide resolved
transports/noise/src/io/framed.rs Outdated Show resolved Hide resolved
transports/noise/src/io/framed.rs Outdated Show resolved Hide resolved
transports/noise/CHANGELOG.md Outdated Show resolved Hide resolved
transports/noise/CHANGELOG.md Outdated Show resolved Hide resolved
transports/noise/src/io.rs Outdated Show resolved Hide resolved
@0xcrust
Copy link
Contributor Author

0xcrust commented Sep 26, 2023

Want to take a look at this? @thomaseizinger . I made the changes we discussed

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.

Nice work! Despite the large changes, the diff is really clean and easy to read, well done.

I think the stats also speak for itself that this is a nice improvement :)

image

transports/noise/src/io.rs Outdated Show resolved Hide resolved
transports/noise/src/io/handshake.rs Outdated Show resolved Hide resolved
transports/noise/src/io/framed.rs Show resolved Hide resolved
transports/noise/src/io/framed.rs Outdated Show resolved Hide resolved
transports/noise/src/io/framed.rs Outdated Show resolved Hide resolved
transports/noise/src/io/framed.rs Outdated Show resolved Hide resolved
transports/noise/src/io/framed.rs Outdated Show resolved Hide resolved
transports/noise/src/io/framed.rs Outdated Show resolved Hide resolved
transports/noise/src/io/framed.rs Outdated Show resolved Hide resolved
0xcrust and others added 3 commits September 27, 2023 12:24
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
@thomaseizinger
Copy link
Contributor

The interoperability tests seem to be failing repeatedly with our previously released version. I'll look into that!

thomaseizinger
thomaseizinger previously approved these changes Sep 28, 2023
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 this, very clean PR :)

Mind fixing up the remaining CI failures regarding the docs? I've restarted the interop tests to see whether they pass this time. They've been very stable recently though so I'd be surprised if that is just a flake this time.

Weirdly, interop seems to be fine with all the other versions, it is just our previously release that is acting up!

transports/noise/src/io/handshake.rs Outdated Show resolved Hide resolved
@thomaseizinger
Copy link
Contributor

I looked into the incompatibility issues and it turns out the problem was that the LengthCodec I pointed you to was using u64 but we need to use a u16. Sorry for sending you down that path.

That fixed some of the errors but there seem to be more problems ...

@thomaseizinger
Copy link
Contributor

thomaseizinger commented Sep 29, 2023

I noticed that with the structure of nesting codec's, we can reuse buffers properly because Rust can't detect that we don't have overlapping mutable borrows. So out of interest, I tried to refactor this to use free functions instead and pass the buffers in which does work!

I also investigated the incompatibility issues locally and thought I had fixed them too because they pass locally but now they are failing again in CI 🙄

These aren't normally flaky so there must be something wrong still.

@thomaseizinger
Copy link
Contributor

Okay, tiny progress: The error happens when this PR is the listener in the ping interop test.

@thomaseizinger
Copy link
Contributor

Found the issue! We were dropping the read and write buffers when mapping the codec and thus threw away data the remote had already sent us as part of being in TransportMode.

@thomaseizinger
Copy link
Contributor

Found the issue! We were dropping the read and write buffers when mapping the codec and thus threw away data the remote had already sent us as part of being in TransportMode.

I had to change another thing in asynchronous-codec to make this work: mxinden/asynchronous-codec#11

@0xcrust
Copy link
Contributor Author

0xcrust commented Sep 29, 2023

Thanks for engaging with this @thomaseizinger. Much appreciated!

@thomaseizinger
Copy link
Contributor

thomaseizinger commented Oct 11, 2023

@0xcrust We have a new release of asynchronous-codec. Can you update this PR to move away from the git dependency?

See mxinden/asynchronous-codec#9 (comment).

@0xcrust
Copy link
Contributor Author

0xcrust commented Oct 14, 2023

@0xcrust We have a new release of asynchronous-codec. Can you update this PR to move away from the git dependency?

Sure! Will do in a bit

@thomaseizinger
Copy link
Contributor

Friendly ping @mxinden. This is ready for review!

@mergify

This comment was marked as resolved.

@thomaseizinger
Copy link
Contributor

thomaseizinger commented Oct 26, 2023

Merging here because it is passing tests and it will otherwise go stale again. Obviously still feel free to review this post-merge @mxinden.

@mergify mergify bot dismissed thomaseizinger’s stale review October 26, 2023 22:23

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

@mergify mergify bot merged commit 4d2983b into libp2p:master Oct 26, 2023
70 of 71 checks passed
@0xcrust 0xcrust deleted the noise-framing branch October 29, 2023 20:05
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.

Thank you for the work here. Great to see these manually implemented state machines removed.

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.

noise: migrate to quick-protobuf-codec
3 participants