diff --git a/Cargo.lock b/Cargo.lock index 142ba4f1d0..ebb74ae766 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -232,6 +232,19 @@ dependencies = [ "syn 2.0.16", ] +[[package]] +name = "asynchronous-codec" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" +dependencies = [ + "bytes", + "futures-sink", + "futures-util", + "memchr", + "pin-project-lite", +] + [[package]] name = "atomic" version = "0.5.3" @@ -270,6 +283,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base-x" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" + [[package]] name = "base58" version = "0.2.0" @@ -706,6 +725,15 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + [[package]] name = "cpp_demangle" version = "0.3.5" @@ -886,6 +914,17 @@ dependencies = [ "cipher", ] +[[package]] +name = "cuckoofilter" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b810a8449931679f64cd7eef1bbd0fa315801b6d5d9cdc1ace2804d6529eee18" +dependencies = [ + "byteorder", + "fnv", + "rand 0.7.3", +] + [[package]] name = "curve25519-dalek" version = "2.1.3" @@ -1009,6 +1048,32 @@ dependencies = [ "syn 2.0.16", ] +[[package]] +name = "data-encoding" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" + +[[package]] +name = "data-encoding-macro" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" +dependencies = [ + "data-encoding", + "data-encoding-macro-internal", +] + +[[package]] +name = "data-encoding-macro-internal" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" +dependencies = [ + "data-encoding", + "syn 1.0.109", +] + [[package]] name = "derivative" version = "2.2.0" @@ -1118,6 +1183,8 @@ checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek 3.2.0", "ed25519", + "rand 0.7.3", + "serde", "sha2 0.9.9", "zeroize", ] @@ -1991,6 +2058,211 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +[[package]] +name = "libp2p" +version = "0.51.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" +dependencies = [ + "bytes", + "futures", + "futures-timer", + "getrandom 0.2.9", + "instant", + "libp2p-allow-block-list", + "libp2p-connection-limits", + "libp2p-core", + "libp2p-floodsub", + "libp2p-identity", + "libp2p-mplex", + "libp2p-noise", + "libp2p-swarm", + "multiaddr", + "pin-project", +] + +[[package]] +name = "libp2p-allow-block-list" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-core" +version = "0.39.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-identity", + "log", + "multiaddr", + "multihash", + "multistream-select", + "once_cell", + "parking_lot", + "pin-project", + "quick-protobuf", + "rand 0.8.5", + "rw-stream-sink", + "smallvec", + "thiserror", + "unsigned-varint", + "void", +] + +[[package]] +name = "libp2p-floodsub" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "089336308101c0f5507e2aae8a693b0997bd3b31d88564530de1596d31a9b87a" +dependencies = [ + "asynchronous-codec", + "cuckoofilter", + "fnv", + "futures", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "log", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "smallvec", + "thiserror", +] + +[[package]] +name = "libp2p-identity" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +dependencies = [ + "bs58", + "ed25519-dalek", + "log", + "multiaddr", + "multihash", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.6", + "thiserror", + "zeroize", +] + +[[package]] +name = "libp2p-mplex" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d34780b514b159e6f3fd70ba3e72664ec89da28dca2d1e7856ee55e2c7031ba" +dependencies = [ + "asynchronous-codec", + "bytes", + "futures", + "libp2p-core", + "log", + "nohash-hasher", + "parking_lot", + "rand 0.8.5", + "smallvec", + "unsigned-varint", +] + +[[package]] +name = "libp2p-noise" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" +dependencies = [ + "bytes", + "curve25519-dalek 3.2.0", + "futures", + "libp2p-core", + "libp2p-identity", + "log", + "once_cell", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.6", + "snow", + "static_assertions", + "thiserror", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "libp2p-swarm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "getrandom 0.2.9", + "instant", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm-derive", + "log", + "rand 0.8.5", + "smallvec", + "void", + "wasm-bindgen-futures", +] + +[[package]] +name = "libp2p-swarm-derive" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +dependencies = [ + "heck", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "libp2p-websys-transport" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "367e21d4fcceffea03382eb77337812312f1a34f75972d6fb473fa68e91443fc" +dependencies = [ + "futures", + "getrandom 0.2.9", + "js-sys", + "libp2p-core", + "parking_lot", + "send_wrapper 0.6.0", + "thiserror", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "libsecp256k1" version = "0.7.1" @@ -2175,6 +2447,75 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "multiaddr" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" +dependencies = [ + "arrayref", + "byteorder", + "data-encoding", + "log", + "multibase", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", + "url", +] + +[[package]] +name = "multibase" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" +dependencies = [ + "base-x", + "data-encoding", + "data-encoding-macro", +] + +[[package]] +name = "multihash" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" +dependencies = [ + "core2", + "multihash-derive", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "multistream-select" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project", + "smallvec", + "unsigned-varint", +] + [[package]] name = "no-std-net" version = "0.6.0" @@ -2621,6 +2962,28 @@ dependencies = [ "cc", ] +[[package]] +name = "quick-protobuf" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" +dependencies = [ + "byteorder", +] + +[[package]] +name = "quick-protobuf-codec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +dependencies = [ + "asynchronous-codec", + "bytes", + "quick-protobuf", + "thiserror", + "unsigned-varint", +] + [[package]] name = "quote" version = "1.0.28" @@ -2910,6 +3273,17 @@ dependencies = [ "twox-hash", ] +[[package]] +name = "rw-stream-sink" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" +dependencies = [ + "futures", + "pin-project", + "static_assertions", +] + [[package]] name = "ryu" version = "1.0.13" @@ -3301,6 +3675,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "smoldot" version = "0.6.0" +source = "git+https://github.com/smol-dot/smoldot.git?rev=a5306ecd#a5306ecdb6955bf4422b703fe5772b064c4e6a20" dependencies = [ "arrayvec 0.7.2", "async-lock", @@ -3349,6 +3724,7 @@ dependencies = [ [[package]] name = "smoldot-light" version = "0.4.0" +source = "git+https://github.com/smol-dot/smoldot.git?rev=a5306ecd#a5306ecdb6955bf4422b703fe5772b064c4e6a20" dependencies = [ "async-lock", "blake2-rfc", @@ -3381,6 +3757,7 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek 4.0.0-rc.1", "rand_core 0.6.4", + "ring", "rustc_version", "sha2 0.10.6", "subtle", @@ -3910,6 +4287,8 @@ dependencies = [ "instant", "js-sys", "jsonrpsee", + "libp2p", + "libp2p-websys-transport", "parity-scale-codec", "primitive-types", "scale-bits", @@ -4050,6 +4429,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-xid", +] + [[package]] name = "tap" version = "1.0.1" @@ -4487,6 +4878,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "unsigned-varint" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" +dependencies = [ + "asynchronous-codec", + "bytes", +] + [[package]] name = "untrusted" version = "0.7.1" @@ -4522,6 +4923,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + [[package]] name = "wabt" version = "0.10.0" @@ -5061,6 +5468,17 @@ dependencies = [ "tap", ] +[[package]] +name = "x25519-dalek" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +dependencies = [ + "curve25519-dalek 3.2.0", + "rand_core 0.5.1", + "zeroize", +] + [[package]] name = "yansi" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 2b7455125a..c415534c1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,9 +74,13 @@ wasm-bindgen-test = "0.3.24" which = "4.4.0" # Light client support: -smoldot = { path = "/home/lexnv/workspace/smoldot/lib", default-features = false } -smoldot-light = { path = "/home/lexnv/workspace/smoldot/light-base", default-features = false } -smoldot-light-wasm = { path = "/home/lexnv/workspace/smoldot/wasm-node/rust", default-features = false } +# smoldot = { path = "/home/lexnv/workspace/smoldot/lib", rev = "a5306ecd", default-features = false } +# smoldot-light = { path = "/home/lexnv/workspace/smoldot/light-base", rev = "a5306ecd", default-features = false } +# smoldot-light-wasm = { path = "/home/lexnv/workspace/smoldot/wasm-node/rust", rev = "a5306ecd",default-features = false } +smoldot = { git = "https://github.com/smol-dot/smoldot.git", rev = "a5306ecd", default-features = false } +smoldot-light = { git = "https://github.com/smol-dot/smoldot.git", rev = "a5306ecd", default-features = false } +smoldot-light-wasm = { git = "https://github.com/smol-dot/smoldot.git", rev = "a5306ecd",default-features = false } + wasm-bindgen-futures = { version = "0.4.19" } futures-timer = { version = "3" } gloo-net = { version = "0.2.6", default-features = false, features = ["json", "websocket"] } @@ -90,6 +94,8 @@ wasm-bindgen = "0.2.84" # TODO: Could this be replaced? send_wrapper = "0.6.0" js-sys = "0.3.61" +libp2p-websys-transport = "0.1.3" +libp2p = { version = "0.51", features = ["floodsub", "macros", "mplex", "noise", "wasm-bindgen"] } tokio-stream = "0.1.14" futures-util = "0.3.28" diff --git a/subxt/Cargo.toml b/subxt/Cargo.toml index b26b4ae82a..631c7c485a 100644 --- a/subxt/Cargo.toml +++ b/subxt/Cargo.toml @@ -62,6 +62,8 @@ unstable-light-client = [ "wasm-bindgen", "send_wrapper", "js-sys", + "libp2p-websys-transport", + "libp2p", # "subxt-light-client", ] @@ -116,7 +118,8 @@ wasm-bindgen= { workspace = true, optional = true } # TODO: Could this be replaced? send_wrapper = { workspace = true, optional = true } js-sys = { workspace = true, optional = true } - +libp2p-websys-transport = { workspace = true, optional = true } +libp2p = { workspace = true, optional = true } tokio = { workspace = true, optional = true } tokio-stream = { workspace = true, optional = true } diff --git a/subxt/src/rpc/lightclient/client.rs b/subxt/src/rpc/lightclient/client.rs index 782e2535c7..f8ebbb6aff 100644 --- a/subxt/src/rpc/lightclient/client.rs +++ b/subxt/src/rpc/lightclient/client.rs @@ -434,6 +434,63 @@ impl LightClient { LightClient::new(&result.to_string()) } + /// Test websocket substrate connection. + pub async fn dial_substrate() { + use libp2p::{ + core::{upgrade::Version, Transport}, + floodsub::{self, Floodsub, FloodsubEvent}, + identity, mplex, + multiaddr::Multiaddr, + noise, + swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmEvent}, + PeerId, + }; + use libp2p_websys_transport::WebsocketTransport; + + // Create the websocket transport. + let local_key = identity::Keypair::generate_ed25519(); + let transport = WebsocketTransport::default() + .upgrade(Version::V1) + .authenticate(noise::NoiseAuthenticated::xx(&local_key).unwrap()) + .multiplex(mplex::MplexConfig::default()) + .boxed(); + + // Create a behaviour to receive Floodsub messages and keep alive connection. + #[derive(NetworkBehaviour)] + struct Behaviour { + keep_alive: keep_alive::Behaviour, + floodsub: Floodsub, + } + + let floodsub_topic = floodsub::Topic::new("chat"); + + // Create a Swarm to manage peers and events + let mut swarm = { + let local_peer_id = PeerId::from(local_key.public()); + let mut behaviour = Behaviour { + floodsub: Floodsub::new(local_peer_id), + keep_alive: keep_alive::Behaviour::default(), + }; + + behaviour.floodsub.subscribe(floodsub_topic.clone()); + + Swarm::with_wasm_executor(transport, behaviour, local_peer_id) + }; + + // hardcode connection check. + let addr = "/ip4/127.0.0.1/tcp/30334/ws"; + let addr = addr.parse::().unwrap(); + + tracing::trace!("SWARM dial"); + let res = swarm.dial(addr); + tracing::trace!("SWARM dial done"); + + loop { + let event = swarm.select_next_some().await; + tracing::trace!("SWARM event {:?}", event); + } + } + /// Constructs a new [`LightClient`], providing the chain specification. /// /// The chain specification can be downloaded from a trusted network via diff --git a/subxt/src/rpc/lightclient/platform.rs b/subxt/src/rpc/lightclient/platform.rs index f7ecdd5316..19657cb786 100644 --- a/subxt/src/rpc/lightclient/platform.rs +++ b/subxt/src/rpc/lightclient/platform.rs @@ -66,6 +66,7 @@ impl Platform { let (send_tx, send_rx) = mpsc::channel(128); let (send_ack_tx, send_ack_rx) = mpsc::channel(128); + // NOTE: This may be avoided when we get a working socket (maybe a variation on web_connection.rs file). wasm_bindgen_futures::spawn_local(async move { tracing::trace!("[background] Start task"); let mut new_connection_rx = new_connection_rx; @@ -74,6 +75,7 @@ impl Platform { while let Some(addr) = new_connection_rx.recv().await { tracing::trace!("[background] Received url={:?}", addr); + // NOTE: `web_sys::Websocket` has the same behavior: // use web_sys::{MessageEvent, WebSocket as WebSysWebsocket}; // // new code to use web_connection: // let mut websocket = match WebSysWebsocket::new(&addr) { @@ -218,7 +220,6 @@ impl smoldot_light::platform::PlatformRef for Platform { fn now(&self) -> Self::Instant { // tracing::trace!("[now]"); - instant::Instant::now() } @@ -317,6 +318,7 @@ impl smoldot_light::platform::PlatformRef for Platform { }; let addr = format!("ws://{}", addr.to_string()); + // NOTE: When using the normal RPC WS address the connection is successful. // let addr = format!("ws://127.0.0.1:9944"); tracing::trace!("[connect] Connecting to addr={:?}", addr); @@ -332,14 +334,6 @@ impl smoldot_light::platform::PlatformRef for Platform { return Err(err); } - // // TODO: use `addr` instead. - // let websocket = WebSocket::open(addr.as_ref()).map_err(|err| { - // tracing::trace!("[connect] Cannot connect to add {:?}", err); - // ConnectError { - // is_bad_addr: false, - // message: "Cannot stablish WebSocket connection".to_string(), - // } - // })?; tracing::trace!("[connect] Connection established"); // let (sender, receiver) = websocket.split(); @@ -367,7 +361,6 @@ impl smoldot_light::platform::PlatformRef for Platform { fn open_out_substream(&self, _connection: &mut Self::Connection) { tracing::trace!("[call] open_out_substream"); - // Called from MultiStream connections that are never opened for this implementation. } @@ -391,13 +384,16 @@ impl smoldot_light::platform::PlatformRef for Platform { Box::pin(async move { tracing::trace!("[update_stream] NEW function"); if stream.buffers.as_mut().is_none() { + // Ignore buffers just to send a raw message tracing::trace!("[update_stream] Buffers are empty"); } let mut plat = inner.lock().await; + // Smoldot submits this as first message: // [19, 47, 109, 117, 108, 116, 105, 115, 116, 114, 101, 97, 109, 47, 49, 46, 48, 46, 48, 10, 7, 47, 110, 111, 105, 115, 101, 10] message=Ok("\u{13}/multistream/1.0.0\n\u{7}/noise\n") + // Send it manually to verify everything is working. let bytes = [ 19, 47, 109, 117, 108, 116, 105, 115, 116, 114, 101, 97, 109, 47, 49, 46, 48, 46, 48, 10, 7, 47, 110, 111, 105, 115, 101, 10, @@ -410,15 +406,15 @@ impl smoldot_light::platform::PlatformRef for Platform { tracing::trace!("[update_stream] Failed to recv ACK for sent bytes"); } + // NOTE: uncomment when the socket can connect to substrate. // { // let mut locked = inner.lock().unwrap(); // let response = locked.sender.send(Message::Bytes(bytes.into())).await; // tracing::trace!("[update_stream] Response is response {:?}", response); // } - - // Ignore buffers just to send a message }) + // NOTE: implementation with poll_fn, similar to smoldot without `flush` and `close` ops. // Box::pin(future::poll_fn(|cx| { // let Some((read_buffer, write_buffer)) = stream.buffers.as_mut() else { // tracing::trace!("[update_stream] Buffers are empty"); @@ -607,67 +603,6 @@ impl smoldot_light::platform::PlatformRef for Platform { ReadBuffer::Open(&buffer[cursor.clone()]) } } - - // let mut locked = stream - // .inner - // .lock() - // .expect("Mutex should not be poised; qed"); - - // // let recv_future = Box::pin(locked.receiver.next()); - - // let mut future = locked.receiver.next(); - - // match future.poll_unpin(&mut Context::from_waker( - // futures_util::task::noop_waker_ref(), - // )) { - // task::Poll::Ready(result) => { - // tracing::warn!("Got result {:?}", result); - - // panic!("OPS with result {:?}", result); - // } - // task::Poll::Pending => { - // // panic!("OPS pending"); - - // smoldot_light::platform::ReadBuffer::Closed - // // tracing::warn!("Got pending..."); - // } - // } - - // match future::Future::poll( - // locked.receiver.next().fuse(), - // &mut Context::from_waker(futures_util::task::noop_waker_ref()), - // ) { - // task::Poll::Ready(result) => { - // tracing::warn!("Got result {:?}", result); - // } - // task::Poll::Pending => { - // tracing::warn!("Got pending..."); - // } - // }; - - // panic!("OPS - from reading"); - - // // let msg = futures_executor::block_on(async { - // let msg = futures::executor::block_on(async { - // match locked.receiver.next().await { - // Some(Ok(msg)) => Some(msg), - // _ => None, - // } - // }); - - // match msg { - // Some(msg) => { - // let msg = Box::leak(Box::new(msg)); - - // match msg { - // Message::Text(text) => { - // smoldot_light::platform::ReadBuffer::Open(text.as_bytes()) - // } - // Message::Bytes(bytes) => smoldot_light::platform::ReadBuffer::Open(bytes), - // } - // } - // None => smoldot_light::platform::ReadBuffer::Closed, - // } } fn advance_read_cursor(&self, stream: &mut Self::Stream, bytes: usize) { @@ -707,15 +642,6 @@ impl smoldot_light::platform::PlatformRef for Platform { stream.buffers.as_mut().map(|(_, w)| w) else { panic!() }; buffer.reserve(data.len()); buffer.extend(data.iter().copied()); - - // let mut locked = stream - // .inner - // .lock() - // .expect("Mutex should not be poised; qed"); - - // if let Ok(message) = String::from_utf8(data.into()) { - // let _ = locked.sender.send(Message::Text(message)); - // } } fn close_send(&self, stream: &mut Self::Stream) { @@ -773,7 +699,3 @@ enum StreamWriteBuffer { }, Closed, } - -// pub struct TcpStream { -// socket: Rc>, -// } diff --git a/subxt/src/rpc/lightclient/web_connection.rs b/subxt/src/rpc/lightclient/web_connection.rs index 554b3e9382..ca601acb61 100644 --- a/subxt/src/rpc/lightclient/web_connection.rs +++ b/subxt/src/rpc/lightclient/web_connection.rs @@ -20,6 +20,12 @@ // SOFTWARE. //! Libp2p transports built on [Websys](https://rustwasm.github.io/wasm-bindgen/web-sys/index.html). +//! +//! TODO: Take from libp2p-websys-transport, but just the socket, without Libp2p transport. +//! - For more context: https://github.com/libp2p/rust-libp2p/issues/3611 +//! +//! Needs some adjusting, gloo-net::Websocket/web-sys may work just as well + #![warn(clippy::all, rust_2018_idioms)] use futures::{future::Ready, io, prelude::*}; diff --git a/testing/wasm-tests/Cargo.lock b/testing/wasm-tests/Cargo.lock index 19a883c07e..d4af6f8017 100644 --- a/testing/wasm-tests/Cargo.lock +++ b/testing/wasm-tests/Cargo.lock @@ -43,7 +43,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom", + "getrandom 0.2.9", "once_cell", "version_check", ] @@ -95,6 +95,19 @@ dependencies = [ "syn 2.0.16", ] +[[package]] +name = "asynchronous-codec" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" +dependencies = [ + "bytes", + "futures-sink", + "futures-util", + "memchr", + "pin-project-lite", +] + [[package]] name = "atomic" version = "0.5.3" @@ -107,6 +120,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "base-x" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" + [[package]] name = "base58" version = "0.2.0" @@ -335,6 +354,15 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + [[package]] name = "cpufeatures" version = "0.2.7" @@ -398,6 +426,17 @@ dependencies = [ "cipher", ] +[[package]] +name = "cuckoofilter" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b810a8449931679f64cd7eef1bbd0fa315801b6d5d9cdc1ace2804d6529eee18" +dependencies = [ + "byteorder", + "fnv", + "rand 0.7.3", +] + [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -508,6 +547,32 @@ dependencies = [ "syn 2.0.16", ] +[[package]] +name = "data-encoding" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" + +[[package]] +name = "data-encoding-macro" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" +dependencies = [ + "data-encoding", + "data-encoding-macro-internal", +] + +[[package]] +name = "data-encoding-macro-internal" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" +dependencies = [ + "data-encoding", + "syn 1.0.109", +] + [[package]] name = "derivative" version = "2.2.0" @@ -558,6 +623,29 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "ed25519" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek 3.2.0", + "ed25519", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "zeroize", +] + [[package]] name = "ed25519-zebra" version = "3.1.0" @@ -597,7 +685,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", - "rand", + "rand 0.8.5", "rustc-hex", "static_assertions", ] @@ -608,6 +696,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + [[package]] name = "frame-metadata" version = "15.1.0" @@ -666,6 +763,7 @@ dependencies = [ "futures-core", "futures-task", "futures-util", + "num_cpus", ] [[package]] @@ -735,6 +833,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.9" @@ -744,7 +853,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] @@ -846,6 +955,15 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hex" version = "0.4.3" @@ -962,6 +1080,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "impl-codec" version = "0.6.0" @@ -1170,6 +1298,211 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +[[package]] +name = "libp2p" +version = "0.51.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" +dependencies = [ + "bytes", + "futures", + "futures-timer", + "getrandom 0.2.9", + "instant", + "libp2p-allow-block-list", + "libp2p-connection-limits", + "libp2p-core", + "libp2p-floodsub", + "libp2p-identity", + "libp2p-mplex", + "libp2p-noise", + "libp2p-swarm", + "multiaddr", + "pin-project", +] + +[[package]] +name = "libp2p-allow-block-list" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-core" +version = "0.39.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-identity", + "log", + "multiaddr", + "multihash", + "multistream-select", + "once_cell", + "parking_lot", + "pin-project", + "quick-protobuf", + "rand 0.8.5", + "rw-stream-sink", + "smallvec", + "thiserror", + "unsigned-varint", + "void", +] + +[[package]] +name = "libp2p-floodsub" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "089336308101c0f5507e2aae8a693b0997bd3b31d88564530de1596d31a9b87a" +dependencies = [ + "asynchronous-codec", + "cuckoofilter", + "fnv", + "futures", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "log", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "smallvec", + "thiserror", +] + +[[package]] +name = "libp2p-identity" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +dependencies = [ + "bs58", + "ed25519-dalek", + "log", + "multiaddr", + "multihash", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.6", + "thiserror", + "zeroize", +] + +[[package]] +name = "libp2p-mplex" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d34780b514b159e6f3fd70ba3e72664ec89da28dca2d1e7856ee55e2c7031ba" +dependencies = [ + "asynchronous-codec", + "bytes", + "futures", + "libp2p-core", + "log", + "nohash-hasher", + "parking_lot", + "rand 0.8.5", + "smallvec", + "unsigned-varint", +] + +[[package]] +name = "libp2p-noise" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" +dependencies = [ + "bytes", + "curve25519-dalek 3.2.0", + "futures", + "libp2p-core", + "libp2p-identity", + "log", + "once_cell", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.6", + "snow", + "static_assertions", + "thiserror", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "libp2p-swarm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "getrandom 0.2.9", + "instant", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm-derive", + "log", + "rand 0.8.5", + "smallvec", + "void", + "wasm-bindgen-futures", +] + +[[package]] +name = "libp2p-swarm-derive" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +dependencies = [ + "heck", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "libp2p-websys-transport" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "367e21d4fcceffea03382eb77337812312f1a34f75972d6fb473fa68e91443fc" +dependencies = [ + "futures", + "getrandom 0.2.9", + "js-sys", + "libp2p-core", + "parking_lot", + "send_wrapper 0.6.0", + "thiserror", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "libsecp256k1" version = "0.7.1" @@ -1183,7 +1516,7 @@ dependencies = [ "libsecp256k1-core", "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", - "rand", + "rand 0.8.5", "serde", "sha2 0.9.9", "typenum", @@ -1218,6 +1551,16 @@ dependencies = [ "libsecp256k1-core", ] +[[package]] +name = "lock_api" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.17" @@ -1265,10 +1608,79 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.45.0", ] +[[package]] +name = "multiaddr" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" +dependencies = [ + "arrayref", + "byteorder", + "data-encoding", + "log", + "multibase", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", + "url", +] + +[[package]] +name = "multibase" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" +dependencies = [ + "base-x", + "data-encoding", + "data-encoding-macro", +] + +[[package]] +name = "multihash" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" +dependencies = [ + "core2", + "multihash-derive", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "multistream-select" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project", + "smallvec", + "unsigned-varint", +] + [[package]] name = "no-std-net" version = "0.6.0" @@ -1281,6 +1693,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + [[package]] name = "nom" version = "7.1.3" @@ -1333,6 +1751,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "once_cell" version = "1.17.1" @@ -1387,6 +1815,29 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.0", +] + [[package]] name = "paste" version = "1.0.12" @@ -1402,6 +1853,12 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + [[package]] name = "pin-project" version = "1.1.0" @@ -1525,6 +1982,28 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-protobuf" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" +dependencies = [ + "byteorder", +] + +[[package]] +name = "quick-protobuf-codec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +dependencies = [ + "asynchronous-codec", + "bytes", + "quick-protobuf", + "thiserror", + "unsigned-varint", +] + [[package]] name = "quote" version = "1.0.28" @@ -1540,6 +2019,19 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -1547,10 +2039,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", + "rand_chacha 0.3.1", "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + [[package]] name = "rand_chacha" version = "0.3.1" @@ -1566,6 +2068,9 @@ name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] [[package]] name = "rand_core" @@ -1573,7 +2078,25 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.9", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", ] [[package]] @@ -1656,6 +2179,17 @@ dependencies = [ "twox-hash", ] +[[package]] +name = "rw-stream-sink" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" +dependencies = [ + "futures", + "pin-project", + "static_assertions", +] + [[package]] name = "ryu" version = "1.0.13" @@ -1802,6 +2336,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "sct" version = "0.7.0" @@ -1940,6 +2480,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" + [[package]] name = "siphasher" version = "0.3.10" @@ -1964,6 +2510,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "smoldot" version = "0.6.0" +source = "git+https://github.com/smol-dot/smoldot.git?rev=a5306ecd#a5306ecdb6955bf4422b703fe5772b064c4e6a20" dependencies = [ "arrayvec 0.7.2", "async-lock", @@ -1993,8 +2540,8 @@ dependencies = [ "num-traits", "parity-scale-codec", "pbkdf2", - "rand", - "rand_chacha", + "rand 0.8.5", + "rand_chacha 0.3.1", "ruzstd", "schnorrkel", "serde", @@ -2012,6 +2559,7 @@ dependencies = [ [[package]] name = "smoldot-light" version = "0.4.0" +source = "git+https://github.com/smol-dot/smoldot.git?rev=a5306ecd#a5306ecdb6955bf4422b703fe5772b064c4e6a20" dependencies = [ "async-lock", "blake2-rfc", @@ -2026,7 +2574,7 @@ dependencies = [ "itertools", "log", "lru", - "rand", + "rand 0.8.5", "serde", "serde_json", "slab", @@ -2044,6 +2592,7 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek 4.0.0-rc.1", "rand_core 0.6.4", + "ring", "rustc_version", "sha2 0.10.6", "subtle", @@ -2070,7 +2619,7 @@ dependencies = [ "futures", "httparse", "log", - "rand", + "rand 0.8.5", "sha-1", ] @@ -2143,13 +2692,15 @@ dependencies = [ "futures", "futures-timer", "futures-util", - "getrandom", + "getrandom 0.2.9", "gloo-net", "hex", "impl-serde", "instant", "js-sys", "jsonrpsee", + "libp2p", + "libp2p-websys-transport", "parity-scale-codec", "primitive-types", "scale-bits", @@ -2235,6 +2786,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-xid", +] + [[package]] name = "tap" version = "1.0.1" @@ -2280,6 +2843,21 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.28.1" @@ -2435,7 +3013,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand", + "rand 0.8.5", "static_assertions", ] @@ -2457,12 +3035,33 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + [[package]] name = "unicode-ident" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "universal-hash" version = "0.4.0" @@ -2473,18 +3072,45 @@ dependencies = [ "subtle", ] +[[package]] +name = "unsigned-varint" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" +dependencies = [ + "asynchronous-codec", + "bytes", +] + [[package]] name = "untrusted" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "url" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + [[package]] name = "want" version = "0.3.0" @@ -2495,6 +3121,12 @@ dependencies = [ "try-lock", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2859,6 +3491,17 @@ dependencies = [ "tap", ] +[[package]] +name = "x25519-dalek" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +dependencies = [ + "curve25519-dalek 3.2.0", + "rand_core 0.5.1", + "zeroize", +] + [[package]] name = "yap" version = "0.10.0" diff --git a/testing/wasm-tests/tests/wasm.rs b/testing/wasm-tests/tests/wasm.rs index f96c832c41..26d05ab8a7 100644 --- a/testing/wasm-tests/tests/wasm.rs +++ b/testing/wasm-tests/tests/wasm.rs @@ -17,6 +17,13 @@ fn init_tracing() { tracing_wasm::set_as_global_default(); } +// NOTE +// run as: ` WASM_BINDGEN_TEST_TIMEOUT=40 wasm-pack test --firefox --headless` +// run as: ` WASM_BINDGEN_TEST_TIMEOUT=40 wasm-pack test --firefox --headless` +// run as: ` WASM_BINDGEN_TEST_TIMEOUT=40 wasm-pack test --firefox --headless` + + +// NOTE: This is basic subxt: // #[wasm_bindgen_test] // async fn wasm_ws_transport_works() { // let client = subxt::client::OnlineClient::::from_url("ws://127.0.0.1:9944") @@ -27,6 +34,16 @@ fn init_tracing() { // assert_eq!(&chain, "Development"); // } + +// // NOTE: Uncomment this to check that WebSocket +// // is failing to connect to substrate. +// #[wasm_bindgen_test] +// async fn light_client_transport_works() { +// init_tracing(); +// tracing::warn!("Starting test"); +// let light_client = LightClient::dial_substrate().await; +// } + #[wasm_bindgen_test] async fn light_client_transport_works() { init_tracing();