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

protocols/gossipsub: Revert back to wasm_timer for interval #2506

Merged
merged 10 commits into from Feb 14, 2022

Conversation

AgeManning
Copy link
Contributor

As described in #2497 the current implementation for Interval in gossipsub can cause some serious issues with how gossipsub functions.

The heartbeat interval can grow unbounded, which unbounds the memory cache, exploding RAM and causes messages to be gossiped much later than they should be which can lead to very old messages being re-propagated on networks.

This PR reverts the Interval implementation back to wasm_timer. This should be sufficient to get gossipsub to work as expected however it was noted that this is not as performant as a straight tokio::time::Interval. A future PR should be made that ports the interval to be tokio agnostic, yet equally performant and compatible with WASM on NodeJS.

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.

Looks good to me. Thanks for reverting. Could you include a changelog entry as well?

Also I think this needs to use wasm_timer::Instant instead of instant::Instant.

//CC @wngr

@divagant-martian
Copy link
Contributor

Also I think this needs to use wasm_timer::Instant instead of instant::Instant.

#2245 made the ProtocolsHandler trait dependent on instant

@divagant-martian
Copy link
Contributor

I've removed support for gossipsub in the wasm targets. It's sad since before #2245 there was support for the other two targets, but the instant::Instant vs wasm_timer::Instant incompatibility makes this the only reasonable solution that I can see for now.

@divagant-martian
Copy link
Contributor

divagant-martian commented Feb 11, 2022

Following @mxinden suggestion, Gossipsub should now be removed only in the wasm32-unknown-unknown target. I'm using cargo tree to verify this:

> cargo tree -e features --target=wasm32-unknown-unknown | rg gossipsub
# empty
> cargo tree -e features --target=wasm32-wasi | rg gossipsub
#├── libp2p-gossipsub feature "default"
#│   └── libp2p-gossipsub v0.36.0 (/home/me/rust-libp2p/protocols/gossipsub)
#│       ├── libp2p-gossipsub feature "default" (*) # libp2p-metrics dep
> cargo tree -e features --target=wasm32-unknown-emscripten | rg gossipsub
#├── libp2p-gossipsub feature "default"
#│   └── libp2p-gossipsub v0.36.0 (/home/me/rust-libp2p/protocols/gossipsub)
#│       ├── libp2p-gossipsub feature "default" (*) # libp2p-metrics dep

protocols/gossipsub/CHANGELOG.md Outdated Show resolved Hide resolved
@mxinden mxinden merged commit 60666f5 into libp2p:master Feb 14, 2022
@mxinden
Copy link
Member

mxinden commented Feb 14, 2022

Thanks @divagant-martian and @AgeManning!

jsdanielh added a commit to jsdanielh/rust-libp2p that referenced this pull request Jan 13, 2023
jsdanielh added a commit to jsdanielh/rust-libp2p that referenced this pull request Jan 13, 2023
jsdanielh added a commit to jsdanielh/rust-libp2p that referenced this pull request Jan 14, 2023
jsdanielh added a commit to nimiq/core-rs-albatross that referenced this pull request Jan 26, 2023
Move the `libp2p` dependency to a fork to enable compilation for
`wasm` and non-`wasm` targets.
This is due to the fact that the `gossipsub` protocol got the `wasm`
support dropped in this
[PR](libp2p/rust-libp2p#2506).
jsdanielh added a commit to nimiq/core-rs-albatross that referenced this pull request Jan 26, 2023
Move the `libp2p` dependency to a fork to enable compilation for
`wasm` and non-`wasm` targets.
This is due to the fact that the `gossipsub` protocol got the `wasm`
support dropped in this
[PR](libp2p/rust-libp2p#2506).
@AgeManning AgeManning deleted the gossipsub-wasm-timer branch November 29, 2023 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants