diff --git a/Cargo.lock b/Cargo.lock index ec16d733bc6..f22a4c71355 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2422,7 +2422,7 @@ checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "libp2p" -version = "0.56.0" +version = "0.57.0" dependencies = [ "bytes", "either", @@ -3076,7 +3076,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.47.0" +version = "0.48.0" dependencies = [ "criterion", "either", @@ -3240,7 +3240,7 @@ dependencies = [ [[package]] name = "libp2p-webrtc-websys" -version = "0.4.0" +version = "0.4.1" dependencies = [ "bytes", "futures", diff --git a/Cargo.toml b/Cargo.toml index e5bfab59b58..c810b0924f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,7 +74,7 @@ rust-version = "1.83.0" edition = "2021" [workspace.dependencies] -libp2p = { version = "0.56.0", path = "libp2p" } +libp2p = { version = "0.57.0", path = "libp2p" } libp2p-allow-block-list = { version = "0.6.0", path = "misc/allow-block-list" } libp2p-autonat = { version = "0.15.0", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.6.0", path = "misc/connection-limits" } @@ -102,7 +102,7 @@ libp2p-rendezvous = { version = "0.17.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.29.0", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.4.0-alpha", path = "protocols/stream" } -libp2p-swarm = { version = "0.47.0", path = "swarm" } +libp2p-swarm = { version = "0.48.0", path = "swarm" } libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.6.0", path = "swarm-test" } libp2p-tcp = { version = "0.44.0", path = "transports/tcp" } @@ -111,7 +111,7 @@ libp2p-uds = { version = "0.43.0", path = "transports/uds" } libp2p-upnp = { version = "0.5.0", path = "protocols/upnp" } libp2p-webrtc = { version = "0.9.0-alpha.1", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.4.0", path = "misc/webrtc-utils" } -libp2p-webrtc-websys = { version = "0.4.0", path = "transports/webrtc-websys" } +libp2p-webrtc-websys = { version = "0.4.1", path = "transports/webrtc-websys" } libp2p-websocket = { version = "0.45.2", path = "transports/websocket" } libp2p-websocket-websys = { version = "0.5.0", path = "transports/websocket-websys" } libp2p-webtransport-websys = { version = "0.5.1", path = "transports/webtransport-websys" } @@ -123,10 +123,12 @@ env_logger = "0.11" futures = "0.3.30" futures-bounded = { version = "0.2.4" } futures-rustls = { version = "0.26.0", default-features = false } -getrandom = "0.2" -if-watch = "3.2.1" +futures-timer = { version = "3" } +getrandom = { version = "0.2", features = ["js"] } +hashlink = "0.10.0" hickory-proto = { version = "0.25.2", default-features = false } hickory-resolver = { version = "0.25.2", default-features = false } +if-watch = "3.2.1" multiaddr = "0.18.1" multihash = "0.19.1" multistream-select = { version = "0.13.0", path = "misc/multistream-select" } @@ -141,8 +143,8 @@ tokio = { version = "1.38", default-features = false } tracing = "0.1.41" tracing-subscriber = "0.3.19" unsigned-varint = { version = "0.8.0" } +wasm-bindgen-futures = "0.4" web-time = "1.1.0" -hashlink = "0.10.0" [patch.crates-io] diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index 1b838bb1b42..eec30fa1d47 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -35,11 +35,11 @@ mime_guess = "2.0.4" [target.'cfg(target_arch = "wasm32")'.dependencies] js-sys = "0.3.69" -libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "wasm-bindgen"] } +libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping"] } libp2p-webrtc-websys = { workspace = true } tracing-wasm = "0.2.1" wasm-bindgen = "0.2.90" -wasm-bindgen-futures = "0.4.42" +wasm-bindgen-futures = { workspace = true} web-sys = { version = "0.3", features = ['Document', 'Element', 'HtmlElement', 'Node', 'Response', 'Window'] } [lints] diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index ca0eb221bd3..994be4a01be 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -39,11 +39,11 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } [target.'cfg(target_arch = "wasm32")'.dependencies] -libp2p = { path = "../libp2p", features = [ "ping", "macros", "webtransport-websys", "wasm-bindgen", "identify", "websocket-websys", "yamux", "noise"] } +libp2p = { path = "../libp2p", features = [ "ping", "macros", "webtransport-websys", "identify", "websocket-websys", "yamux", "noise"] } libp2p-mplex = { path = "../muxers/mplex" } libp2p-webrtc-websys = { workspace = true } wasm-bindgen = { version = "0.2" } -wasm-bindgen-futures = { version = "0.4" } +wasm-bindgen-futures = { workspace = true} wasm-logger = { version = "0.2.0" } web-time = { workspace = true } reqwest = { version = "0.12", features = ["json"] } diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index cb27ebe68e5..fc801f5de21 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.57.0 + +- Remove `wasm-bindgen` feature and make `wasm` support implicit. + See [PR 6102](https://github.com/libp2p/rust-libp2p/pull/6102) + ## 0.56.0 - Remove `async-std` support. diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index 48f4c9477bd..4faa8e7f881 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p" edition.workspace = true rust-version = { workspace = true } description = "Peer-to-peer networking library" -version = "0.56.0" +version = "0.57.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -42,7 +42,6 @@ full = [ "tls", "tokio", "uds", - "wasm-bindgen", "webrtc-websys", "websocket-websys", "websocket", @@ -81,7 +80,6 @@ tcp = ["dep:libp2p-tcp"] tls = ["dep:libp2p-tls"] tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-upnp?/tokio"] uds = ["dep:libp2p-uds"] -wasm-bindgen = ["futures-timer/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"] webrtc-websys = ['dep:libp2p-webrtc-websys'] websocket-websys = ["dep:libp2p-websocket-websys"] websocket = ["dep:libp2p-websocket"] @@ -93,8 +91,6 @@ upnp = ["dep:libp2p-upnp"] bytes = "1" either = "1.9.0" futures = { workspace = true } -futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` feature -getrandom = { workspace = true } # Explicit dependency to be used in `wasm-bindgen` feature # TODO feature flag? rw-stream-sink = { workspace = true } libp2p-allow-block-list = { workspace = true } @@ -144,6 +140,10 @@ libp2p-mplex = { workspace = true } libp2p-tcp = { workspace = true, features = ["tokio"] } tracing-subscriber = { workspace = true, features = ["env-filter"] } +[target.'cfg(target_family="wasm")'.dependencies] +futures-timer = { workspace = true, features = ["wasm-bindgen"] } +getrandom = { workspace = true} + # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] diff --git a/libp2p/src/builder/phase/provider.rs b/libp2p/src/builder/phase/provider.rs index aa99d5518ce..60dce1501b0 100644 --- a/libp2p/src/builder/phase/provider.rs +++ b/libp2p/src/builder/phase/provider.rs @@ -15,7 +15,7 @@ pub enum NoProviderSpecified {} /// Represents the Tokio runtime environment. pub enum Tokio {} -#[cfg(feature = "wasm-bindgen")] +#[cfg(target_arch = "wasm32")] /// Represents the WasmBindgen environment for WebAssembly. pub enum WasmBindgen {} @@ -37,7 +37,7 @@ impl SwarmBuilder { /// Configures the SwarmBuilder for WebAssembly using WasmBindgen. /// This method is available when the `wasm-bindgen` feature is enabled. - #[cfg(feature = "wasm-bindgen")] + #[cfg(target_arch = "wasm32")] pub fn with_wasm_bindgen(self) -> SwarmBuilder { SwarmBuilder { keypair: self.keypair, diff --git a/libp2p/src/builder/phase/swarm.rs b/libp2p/src/builder/phase/swarm.rs index 79b512a38af..ca8ba38a12d 100644 --- a/libp2p/src/builder/phase/swarm.rs +++ b/libp2p/src/builder/phase/swarm.rs @@ -10,9 +10,9 @@ pub struct SwarmPhase { pub(crate) transport: T, } +#[cfg(any(target_arch = "wasm32", feature = "tokio"))] macro_rules! impl_with_swarm_config { - ($providerKebabCase:literal, $providerPascalCase:ty, $config:expr) => { - #[cfg(feature = $providerKebabCase)] + ($providerPascalCase:ty, $config:expr) => { impl SwarmBuilder<$providerPascalCase, SwarmPhase> { pub fn with_swarm_config( self, @@ -42,16 +42,14 @@ macro_rules! impl_with_swarm_config { }; } -#[cfg(not(target_arch = "wasm32"))] +#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))] impl_with_swarm_config!( - "tokio", super::provider::Tokio, libp2p_swarm::Config::with_tokio_executor() ); #[cfg(target_arch = "wasm32")] impl_with_swarm_config!( - "wasm-bindgen", super::provider::WasmBindgen, libp2p_swarm::Config::with_wasm_executor() ); diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index 8741f8b4cb4..c8183bc1673 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -24,6 +24,9 @@ - Fix mesh not being constructed even when not adding any peer. See [PR 6100](https://github.com/libp2p/rust-libp2p/pull/6100) +- Remove `wasm-bindgen` feature and make `wasm` support implicit. + See [PR 6102](https://github.com/libp2p/rust-libp2p/pull/6102) + ## 0.49.0 - Feature gate metrics related code. This changes some `Behaviour` constructor methods. diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 911b453f477..0d1b40e7f4c 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -11,7 +11,6 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [features] -wasm-bindgen = ["getrandom/js", "futures-timer/wasm-bindgen"] metrics = ["prometheus-client"] [dependencies] @@ -23,8 +22,7 @@ bytes = "1.6" either = "1.11" fnv = "1.0.7" futures = { workspace = true } -futures-timer = "3.0.2" -getrandom = { workspace = true } +futures-timer = { workspace = true} hashlink = { workspace = true } hex_fmt = "0.3.0" web-time = { workspace = true } @@ -49,6 +47,10 @@ quickcheck = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } tokio = { workspace = true, features = ["rt", "rt-multi-thread", "time", "macros"] } +[target.'cfg(target_family="wasm")'.dependencies] +futures-timer = { workspace = true, features = ["wasm-bindgen"] } +getrandom = { workspace = true } + # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 90d104156f6..1860de32acc 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.48.0 + +- Remove `wasm-bindgen` feature and make `wasm` support implicit. + See [PR 6102](https://github.com/libp2p/rust-libp2p/pull/6102) + ## 0.47.0 - Remove `async-std` support. diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 5e42700f92b..7a2af08dc70 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm" edition.workspace = true rust-version = { workspace = true } description = "The libp2p swarm" -version = "0.47.0" +version = "0.48.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -15,7 +15,6 @@ either = "1.11.0" fnv = "1.0" futures = { workspace = true } futures-timer = "3.0.3" -getrandom = { workspace = true, features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature web-time = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } @@ -25,15 +24,17 @@ multistream-select = { workspace = true } rand = "0.8" smallvec = "1.13.2" tracing = { workspace = true } -wasm-bindgen-futures = { version = "0.4.42", optional = true } [target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies] tokio = { workspace = true, features = ["rt"], optional = true } +[target.'cfg(target_family="wasm")'.dependencies] +getrandom = { workspace = true} +wasm-bindgen-futures = { workspace = true} + [features] macros = ["dep:libp2p-swarm-derive"] tokio = ["dep:tokio"] -wasm-bindgen = ["dep:wasm-bindgen-futures", "dep:getrandom"] [dev-dependencies] either = "1.11.0" diff --git a/swarm/src/executor.rs b/swarm/src/executor.rs index 41fb37aaf15..b8181a5d0ce 100644 --- a/swarm/src/executor.rs +++ b/swarm/src/executor.rs @@ -44,10 +44,10 @@ impl Executor for TokioExecutor { } } -#[cfg(feature = "wasm-bindgen")] +#[cfg(target_arch = "wasm32")] #[derive(Default, Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] pub(crate) struct WasmBindgenExecutor; -#[cfg(feature = "wasm-bindgen")] +#[cfg(target_arch = "wasm32")] impl Executor for WasmBindgenExecutor { fn exec(&self, future: Pin + Send>>) { wasm_bindgen_futures::spawn_local(future) diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index d0ae6118190..e0d8a3820cc 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1406,7 +1406,7 @@ impl Config { /// task() /// } /// ``` - #[cfg(feature = "wasm-bindgen")] + #[cfg(target_arch = "wasm32")] pub fn with_wasm_executor() -> Self { Self::with_executor(crate::executor::WasmBindgenExecutor) } diff --git a/transports/webrtc-websys/CHANGELOG.md b/transports/webrtc-websys/CHANGELOG.md index 5a550a5e8b1..ae2beaa0903 100644 --- a/transports/webrtc-websys/CHANGELOG.md +++ b/transports/webrtc-websys/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.1 + +- Require `getrandom/js` feature only under `wasm` target. + See [PR 6102](https://github.com/libp2p/rust-libp2p/pull/6102) + ## 0.4.0 - Cut stable release. diff --git a/transports/webrtc-websys/Cargo.toml b/transports/webrtc-websys/Cargo.toml index e5596da90e4..b53a650c8d5 100644 --- a/transports/webrtc-websys/Cargo.toml +++ b/transports/webrtc-websys/Cargo.toml @@ -8,13 +8,12 @@ license = "MIT" name = "libp2p-webrtc-websys" repository = "https://github.com/libp2p/rust-libp2p" rust-version = { workspace = true } -version = "0.4.0" +version = "0.4.1" publish = true [dependencies] bytes = "1" futures = { workspace = true } -getrandom = { workspace = true, features = ["js"] } hex = "0.4.3" js-sys = { version = "0.3" } libp2p-core = { workspace = true } @@ -24,8 +23,11 @@ send_wrapper = { version = "0.6.0", features = ["futures"] } thiserror = { workspace = true } tracing = { workspace = true } wasm-bindgen = { version = "0.2.90" } -wasm-bindgen-futures = { version = "0.4.42" } +wasm-bindgen-futures = { workspace = true} web-sys = { version = "0.3.70", features = ["Document", "Location", "MessageEvent", "Navigator", "RtcCertificate", "RtcConfiguration", "RtcDataChannel", "RtcDataChannelEvent", "RtcDataChannelInit", "RtcDataChannelState", "RtcDataChannelType", "RtcPeerConnection", "RtcSdpType", "RtcSessionDescription", "RtcSessionDescriptionInit", "Window"] } +[target.'cfg(target_family="wasm")'.dependencies] +getrandom = { workspace = true} + [lints] workspace = true diff --git a/wasm-tests/webtransport-tests/Cargo.toml b/wasm-tests/webtransport-tests/Cargo.toml index cd103b46d05..320b3c89e2c 100644 --- a/wasm-tests/webtransport-tests/Cargo.toml +++ b/wasm-tests/webtransport-tests/Cargo.toml @@ -18,7 +18,7 @@ libp2p-webtransport-websys = { workspace = true } multiaddr = { workspace = true } multihash = { workspace = true } wasm-bindgen = "0.2.93" -wasm-bindgen-futures = "0.4.43" +wasm-bindgen-futures = { workspace = true} wasm-bindgen-test = "0.3.43" web-sys = { version = "0.3.70", features = ["Response", "Window"] }