-
Notifications
You must be signed in to change notification settings - Fork 999
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
feat(gossipsub): allow compiling for WASM #3973
feat(gossipsub): allow compiling for WASM #3973
Conversation
Agreed! Are you happy to send a PR for the remaining usages? (I haven't checked whether there actually are any.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! One question.
Certainly, I will check/work on that matter during the upcoming weekend. |
1ab42f6
to
9d1a36f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more comments, otherwise LGTM :)
Signed-off-by: ozkanonur <[email protected]>
9d1a36f
to
d72d9a7
Compare
Thanks! I've pushed a few follow-up commits. Most notable, the crate is now included in our WASM build on CI! If we are already working on WASM compatibility, I'd be great if we could also get rid of |
Awesome :) I believed that shipping this would greatly benefit many people, so I directly opened the pull request for it. But I am also completely okay with replacing |
We will make a new release soon but it is likely a week or so away. This PR should easily make it in even if it takes a few more days before we can land it :) |
f8990b3
to
f11f9e4
Compare
I decided to use
Also, it's worth to see this comment about If Let me know if this is acceptable or not :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
I guess this means we can close #2497 with this PR then?
cc @mxinden @AgeManning In #2497, there was talk that the only remaining work would be to (re?) enable WASM support for gossipsub. This PR achieves this by means of https://github.com/antifuchs/futures-ticker. |
I think so. Another way of solving this would be porting |
If the dependencies aren't pinned, cargo should resolve them to the same version if they are semver compatible.#2497 was created because we initially had our own interval implementation and it was buggy. I'd like to not go back to that (even without a buggy implemention 😀 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work here. No objections from my end.
Note that futures-tick
uses a "skip" style strategy, i.e. when one misses e.g. 2 ticks, only one is delivered. See also good documentation in tokio's Interval
implementation.
Looking at futures-tick
, I think there is room for improvement. See antifuchs/futures-ticker#10.
I think that makes sense for us. This is used for heartbeats so I don't see a need for a burst strategy. Rather, performing the next heartbeat as soon as possible is important. Do we agree? |
++ |
Signed-off-by: ozkanonur <[email protected]>
yes |
There was a problem hiding this 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!
If you don't mind sharing, I would like to know what you are building with rust-libp2p and WASM @ozkanonur. |
Sorry for the late input here. As you've all pointed out, we had significant issues because in the past because there was a buggy implementation of interval. It's very important that the heartbeat stays consistent. It appears the ticker approach behaves like what we would need, in that if the software is over-loaded heartbeats are skipped, but should still occur at regular intervals. We (Lighthouse) have no affinity to wasm-timer. So changes look good, provided the heartbeat works as expected :) |
Approvals have been dismissed because the PR was updated after the send-it
label was applied.
We have a dex/swap protocol called https://github.com/KomodoPlatform/atomicDEX-API that utilizes libp2p for the network stack. Initially, it was written in C, but around 2019, we made the decision to rewrite it in Rust. As part of this rewrite, the network stack was migrated from nanomsg to libp2p, which involved creating custom patches for the libp2p library. Today, I am rewriting the network layer of the project(KomodoPlatform/komodo-defi-framework#1756). This involves removing the forks and instead utilizing the original version of libp2p (the upstream). Throughout this process, I will likely come up with several more ideas and proposals to improve the libp2p upstream if I believe they would be beneficial. |
This sounds like we should have a test for that :) I'll create an issue. |
Since #3973, gossipsub now fully supports wasm targets. It functions properly when added as a dependency on its own. However, when trying to use it under libp2p by activating a feature, it's not possible and the compiler will raise an error like `unresolved import libp2p::gossipsub`. This pull request enables the use of gossipsub for wasm targets when it's activated as a feature of the libp2p dependency. Pull-Request: #4217.
Since #3973, gossipsub now fully supports wasm targets. It functions properly when added as a dependency on its own. However, when trying to use it under libp2p by activating a feature, it's not possible and the compiler will raise an error like `unresolved import libp2p::gossipsub`. This pull request enables the use of gossipsub for wasm targets when it's activated as a feature of the libp2p dependency. Pull-Request: #4217.
Description
This modification removes deprecated dependency
wasm_timer
and enables wasm compatibility on the gossibsup protocol by simply substituting thewasm_timer::Instant
withinstant::Instant
(which supportsfn checked_add
) andwasm_timer::Interval
withfutures_ticker::Ticker
.Notes
In my opinion,wasm-timer
should be removed completely from the dependency tree since it's quite bad that relying on the dependency which is deprecated and no longer maintained.instant
is also not so up-to-date dependency, but at very least it works today. But it might be broken someday as well if we make a change on standard library on rustc. Writing simple wrapper in the libp2p tree would be the most stable solution for this project since you can have complete control over it and update it whenever standard library adds or changes something.