From 2de7e51c2ad0657c7037e362bcff0bb564ced067 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 17 Aug 2021 20:06:23 +0200 Subject: [PATCH] Remove substrate-in-the-browser (#9541) * Comment out browser stuff * Remove browser stuff * Remove more wasm transport code * Remove ExtTransport and rework how telemetry initialises. * Change (most) wasm-timer using code to use std::time * Rename CI-job * Aura does not compile for wasm * Remove testing in the browser on CI * Update README * Leave `StreamSink` be * fmt --- substrate/.gitlab-ci.yml | 23 +- substrate/Cargo.lock | 103 --------- substrate/Cargo.toml | 2 - substrate/bin/node/browser-testing/Cargo.toml | 23 -- substrate/bin/node/browser-testing/src/lib.rs | 67 ------ .../bin/node/browser-testing/webdriver.json | 7 - substrate/bin/node/cli/Cargo.toml | 14 +- .../bin/node/cli/browser-demo/.gitignore | 1 - substrate/bin/node/cli/browser-demo/README.md | 10 - substrate/bin/node/cli/browser-demo/build.sh | 5 - .../bin/node/cli/browser-demo/favicon.png | Bin 10338 -> 0 bytes .../bin/node/cli/browser-demo/index.html | 39 ---- substrate/bin/node/cli/src/browser.rs | 57 ----- substrate/bin/node/cli/src/lib.rs | 4 - substrate/bin/node/cli/src/service.rs | 7 +- substrate/client/cli/src/config.rs | 15 +- .../client/cli/src/params/network_params.rs | 1 - substrate/client/consensus/common/Cargo.toml | 1 - .../consensus/common/src/import_queue.rs | 2 +- .../common/src/import_queue/basic_queue.rs | 2 +- substrate/client/finality-grandpa/Cargo.toml | 1 - .../src/communication/gossip.rs | 3 +- .../finality-grandpa/src/until_imported.rs | 3 +- substrate/client/informant/Cargo.toml | 1 - substrate/client/informant/src/display.rs | 2 +- substrate/client/network-gossip/Cargo.toml | 1 - .../network-gossip/src/state_machine.rs | 2 +- substrate/client/network/Cargo.toml | 1 - substrate/client/network/src/config.rs | 18 +- substrate/client/network/src/peer_info.rs | 3 +- .../src/protocol/notifications/behaviour.rs | 3 +- .../src/protocol/notifications/handler.rs | 3 +- .../src/protocol/sync/extra_requests.rs | 3 +- .../client/network/src/request_responses.rs | 3 +- substrate/client/network/src/service.rs | 8 +- substrate/client/network/src/transport.rs | 15 +- substrate/client/peerset/src/lib.rs | 4 +- substrate/client/peerset/src/peersstate.rs | 2 +- substrate/client/service/Cargo.toml | 1 - substrate/client/service/src/builder.rs | 3 +- substrate/client/service/src/config.rs | 5 +- substrate/client/service/src/metrics.rs | 6 +- substrate/client/service/test/src/lib.rs | 8 +- substrate/client/telemetry/src/lib.rs | 11 +- substrate/client/telemetry/src/transport.rs | 26 +-- .../tracing/src/logging/layers/console_log.rs | 116 ---------- .../client/tracing/src/logging/layers/mod.rs | 4 - substrate/client/transaction-pool/Cargo.toml | 1 - .../client/transaction-pool/graph/Cargo.toml | 1 - .../transaction-pool/src/graph/future.rs | 2 +- .../client/transaction-pool/src/graph/pool.rs | 8 +- .../transaction-pool/src/graph/rotator.rs | 7 +- .../src/graph/validated_pool.rs | 2 +- substrate/client/transaction-pool/src/lib.rs | 2 +- substrate/docs/Upgrading-2.0-to-3.0.md | 63 ------ substrate/primitives/timestamp/Cargo.toml | 2 - substrate/primitives/timestamp/src/lib.rs | 2 +- substrate/test-utils/test-runner/src/utils.rs | 1 - substrate/utils/browser/Cargo.toml | 35 --- substrate/utils/browser/README.md | 1 - substrate/utils/browser/src/lib.rs | 212 ------------------ 61 files changed, 57 insertions(+), 921 deletions(-) delete mode 100644 substrate/bin/node/browser-testing/Cargo.toml delete mode 100644 substrate/bin/node/browser-testing/src/lib.rs delete mode 100644 substrate/bin/node/browser-testing/webdriver.json delete mode 100644 substrate/bin/node/cli/browser-demo/.gitignore delete mode 100644 substrate/bin/node/cli/browser-demo/README.md delete mode 100755 substrate/bin/node/cli/browser-demo/build.sh delete mode 100644 substrate/bin/node/cli/browser-demo/favicon.png delete mode 100644 substrate/bin/node/cli/browser-demo/index.html delete mode 100644 substrate/bin/node/cli/src/browser.rs delete mode 100644 substrate/client/tracing/src/logging/layers/console_log.rs delete mode 100644 substrate/utils/browser/Cargo.toml delete mode 100644 substrate/utils/browser/README.md delete mode 100644 substrate/utils/browser/src/lib.rs diff --git a/substrate/.gitlab-ci.yml b/substrate/.gitlab-ci.yml index fc5b397af1..d66e3f9a4c 100644 --- a/substrate/.gitlab-ci.yml +++ b/substrate/.gitlab-ci.yml @@ -391,17 +391,11 @@ test-linux-stable-int: paths: - ${CI_COMMIT_SHORT_SHA}_int_failure.log -check-web-wasm: +check-tracing: stage: test <<: *docker-env <<: *test-refs script: - # WASM support is in progress. As more and more crates support WASM, we - # should add entries here. See https://github.com/paritytech/substrate/issues/2416 - # Note: we don't need to test crates imported in `bin/node/cli` - - time cargo build --manifest-path=client/consensus/aura/Cargo.toml --target=wasm32-unknown-unknown --features getrandom - # Note: the command below is a bit weird because several Cargo issues prevent us from compiling the node in a more straight-forward way. - - time cargo +nightly build --manifest-path=bin/node/cli/Cargo.toml --no-default-features --features browser --target=wasm32-unknown-unknown # with-tracing must be explicitly activated, we run a test to ensure this works as expected in both cases - time cargo +nightly test --manifest-path primitives/tracing/Cargo.toml --no-default-features - time cargo +nightly test --manifest-path primitives/tracing/Cargo.toml --no-default-features --features=with-tracing @@ -459,21 +453,6 @@ check-polkadot-companion-build: - cd polkadot && git rev-parse --abbrev-ref HEAD allow_failure: true -test-browser-node: - stage: build - <<: *docker-env - <<: *test-refs - needs: - - job: check-web-wasm - artifacts: false - variables: - <<: *default-vars - CHROMEDRIVER_ARGS: "--log-level=INFO --whitelisted-ips=127.0.0.1" - CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER: "wasm-bindgen-test-runner" - WASM_BINDGEN_TEST_TIMEOUT: 120 - script: - - cargo +nightly test --target wasm32-unknown-unknown -p node-browser-testing - build-linux-substrate: &build-binary stage: build <<: *collect-artifacts diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 59ef261691..08db695b05 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -861,12 +861,10 @@ version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" dependencies = [ - "js-sys", "libc", "num-integer", "num-traits", "time", - "wasm-bindgen", "winapi 0.3.9", ] @@ -943,16 +941,6 @@ dependencies = [ "cache-padded", ] -[[package]] -name = "console_error_panic_hook" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" -dependencies = [ - "cfg-if 0.1.10", - "wasm-bindgen", -] - [[package]] name = "constant_time_eq" version = "0.1.5" @@ -2178,10 +2166,6 @@ name = "futures-timer" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" -dependencies = [ - "gloo-timers", - "send_wrapper", -] [[package]] name = "futures-util" @@ -2237,10 +2221,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -2684,9 +2666,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" dependencies = [ "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", ] [[package]] @@ -4212,20 +4191,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "node-browser-testing" -version = "3.0.0-dev" -dependencies = [ - "jsonrpc-core", - "node-cli", - "parking_lot 0.11.1", - "serde", - "serde_json", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test", -] - [[package]] name = "node-cli" version = "3.0.0-dev" @@ -4236,7 +4201,6 @@ dependencies = [ "frame-system", "futures 0.3.16", "hex-literal", - "libp2p-wasm-ext", "log 0.4.14", "nix", "node-executor", @@ -4288,13 +4252,10 @@ dependencies = [ "sp-transaction-storage-proof", "sp-trie", "structopt", - "substrate-browser-utils", "substrate-build-script-utils", "substrate-frame-cli", "tempfile", "try-runtime-cli", - "wasm-bindgen", - "wasm-bindgen-futures", ] [[package]] @@ -7388,7 +7349,6 @@ dependencies = [ "sp-utils", "substrate-prometheus-endpoint", "thiserror", - "wasm-timer", ] [[package]] @@ -7746,7 +7706,6 @@ dependencies = [ "substrate-test-runtime-client", "tempfile", "tokio 0.2.25", - "wasm-timer", ] [[package]] @@ -7790,7 +7749,6 @@ dependencies = [ "sc-transaction-pool-api", "sp-blockchain", "sp-runtime", - "wasm-timer", ] [[package]] @@ -7879,7 +7837,6 @@ dependencies = [ "thiserror", "unsigned-varint 0.6.0", "void", - "wasm-timer", "zeroize", ] @@ -7899,7 +7856,6 @@ dependencies = [ "substrate-prometheus-endpoint", "substrate-test-runtime-client", "tracing", - "wasm-timer", ] [[package]] @@ -8139,7 +8095,6 @@ dependencies = [ "tokio 0.2.25", "tracing", "tracing-futures", - "wasm-timer", ] [[package]] @@ -8302,7 +8257,6 @@ dependencies = [ "substrate-test-runtime-client", "substrate-test-runtime-transaction-pool", "thiserror", - "wasm-timer", ] [[package]] @@ -8443,12 +8397,6 @@ dependencies = [ "pest", ] -[[package]] -name = "send_wrapper" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" - [[package]] name = "serde" version = "1.0.126" @@ -9400,7 +9348,6 @@ dependencies = [ "sp-runtime", "sp-std", "thiserror", - "wasm-timer", ] [[package]] @@ -9608,30 +9555,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "substrate-browser-utils" -version = "0.10.0-dev" -dependencies = [ - "chrono", - "console_error_panic_hook", - "futures 0.3.16", - "futures-timer 3.0.2", - "getrandom 0.2.3", - "js-sys", - "kvdb-memorydb", - "libp2p-wasm-ext", - "log 0.4.14", - "rand 0.7.3", - "sc-chain-spec", - "sc-informant", - "sc-network", - "sc-service", - "sc-tracing", - "sp-database", - "wasm-bindgen", - "wasm-bindgen-futures", -] - [[package]] name = "substrate-build-script-utils" version = "3.0.0" @@ -10944,8 +10867,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" dependencies = [ "cfg-if 1.0.0", - "serde", - "serde_json", "wasm-bindgen-macro", ] @@ -11005,30 +10926,6 @@ version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" -[[package]] -name = "wasm-bindgen-test" -version = "0.3.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d4da138503a4cf86801b94d95781ee3619faa8feca830569cc6b54997b8b5c" -dependencies = [ - "console_error_panic_hook", - "js-sys", - "scoped-tls", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test-macro", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.3.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3199c33f06500c731d5544664c24d0c2b742b98debc6b1c6f0c6d6e8fb7c19b" -dependencies = [ - "proc-macro2", - "quote", -] - [[package]] name = "wasm-gc-api" version = "0.1.11" diff --git a/substrate/Cargo.toml b/substrate/Cargo.toml index fd4c66e5d4..6a1c26e952 100644 --- a/substrate/Cargo.toml +++ b/substrate/Cargo.toml @@ -6,7 +6,6 @@ members = [ "bin/node-template/pallets/template", "bin/node-template/runtime", "bin/node/bench", - "bin/node/browser-testing", "bin/node/cli", "bin/node/test-runner-example", "bin/node/executor", @@ -192,7 +191,6 @@ members = [ "test-utils/runtime/transaction-pool", "test-utils/test-runner", "test-utils/test-crate", - "utils/browser", "utils/build-script-utils", "utils/fork-tree", "utils/frame/benchmarking-cli", diff --git a/substrate/bin/node/browser-testing/Cargo.toml b/substrate/bin/node/browser-testing/Cargo.toml deleted file mode 100644 index 64c8f47404..0000000000 --- a/substrate/bin/node/browser-testing/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "node-browser-testing" -version = "3.0.0-dev" -authors = ["Parity Technologies "] -description = "Tests for the in-browser light client." -edition = "2018" -license = "Apache-2.0" - -[dependencies] -jsonrpc-core = "18.0.0" -serde = "1.0.126" -serde_json = "1.0.48" -wasm-bindgen = { version = "=0.2.73", features = ["serde-serialize"] } -wasm-bindgen-futures = "0.4.18" -wasm-bindgen-test = "0.3.18" - -node-cli = { path = "../cli", default-features = false, features = [ - "browser", -], version = "3.0.0-dev" } - -# This is a HACK to make browser tests pass. -# enables [`instant/wasm_bindgen`] -parking_lot = { version = "0.11.1", features = ["wasm-bindgen"] } diff --git a/substrate/bin/node/browser-testing/src/lib.rs b/substrate/bin/node/browser-testing/src/lib.rs deleted file mode 100644 index 35804bef21..0000000000 --- a/substrate/bin/node/browser-testing/src/lib.rs +++ /dev/null @@ -1,67 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! # Running -//! Running this test can be done with -//! ```text -//! wasm-pack test --firefox --release --headless bin/node/browser-testing -//! ``` -//! or (without `wasm-pack`) -//! ```text -//! CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner WASM_BINDGEN_TEST_TIMEOUT=60 cargo test --target wasm32-unknown-unknown -//! ``` -//! For debug infomation, such as the informant, run without the `--headless` -//! flag and open a browser to the url that `wasm-pack test` outputs. -//! For more infomation see . - -use jsonrpc_core::types::{Id, MethodCall, Params, Success, Version}; -use serde::de::DeserializeOwned; -use wasm_bindgen::JsValue; -use wasm_bindgen_futures::JsFuture; -use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure}; - -wasm_bindgen_test_configure!(run_in_browser); - -fn rpc_call(method: &str) -> String { - serde_json::to_string(&MethodCall { - jsonrpc: Some(Version::V2), - method: method.into(), - params: Params::None, - id: Id::Num(1), - }) - .unwrap() -} - -fn deserialize_rpc_result(js_value: JsValue) -> T { - let string = js_value.as_string().unwrap(); - let value = serde_json::from_str::(&string).unwrap().result; - // We need to convert a `Value::Object` into a proper type. - let value_string = serde_json::to_string(&value).unwrap(); - serde_json::from_str(&value_string).unwrap() -} - -#[wasm_bindgen_test] -async fn runs() { - let mut client = node_cli::start_client(None, "info".into()).unwrap(); - - // Check that the node handles rpc calls. - // TODO: Re-add the code that checks if the node is syncing. - let chain_name: String = deserialize_rpc_result( - JsFuture::from(client.rpc_send(&rpc_call("system_chain"))).await.unwrap(), - ); - assert_eq!(chain_name, "Development"); -} diff --git a/substrate/bin/node/browser-testing/webdriver.json b/substrate/bin/node/browser-testing/webdriver.json deleted file mode 100644 index 417ac35a7b..0000000000 --- a/substrate/bin/node/browser-testing/webdriver.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "goog:chromeOptions": { - "args": [ - "--whitelisted-ips=127.0.0.1" - ] - } -} diff --git a/substrate/bin/node/cli/Cargo.toml b/substrate/bin/node/cli/Cargo.toml index ae5fd11c91..b595aa4b03 100644 --- a/substrate/bin/node/cli/Cargo.toml +++ b/substrate/bin/node/cli/Cargo.toml @@ -92,12 +92,6 @@ frame-benchmarking-cli = { version = "4.0.0-dev", optional = true, path = "../.. node-inspect = { version = "0.9.0-dev", optional = true, path = "../inspect" } try-runtime-cli = { version = "0.10.0-dev", optional = true, path = "../../../utils/frame/try-runtime/cli" } -# WASM-specific dependencies -wasm-bindgen = { version = "0.2.73", optional = true } -wasm-bindgen-futures = { version = "0.4.18", optional = true } -browser-utils = { package = "substrate-browser-utils", path = "../../../utils/browser", optional = true, version = "0.10.0-dev"} -libp2p-wasm-ext = { version = "0.29", features = ["websocket"], optional = true } - [target.'cfg(target_arch="x86_64")'.dependencies] node-executor = { version = "3.0.0-dev", path = "../executor", features = [ "wasmtime", @@ -143,13 +137,7 @@ path = "../../../client/cli" optional = true [features] -default = ["cli"] -browser = [ - "browser-utils", - "wasm-bindgen", - "wasm-bindgen-futures", - "libp2p-wasm-ext", -] +default = [ "cli" ] cli = [ "node-executor/wasmi-errno", "node-inspect", diff --git a/substrate/bin/node/cli/browser-demo/.gitignore b/substrate/bin/node/cli/browser-demo/.gitignore deleted file mode 100644 index 0c6117d9fb..0000000000 --- a/substrate/bin/node/cli/browser-demo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -pkg \ No newline at end of file diff --git a/substrate/bin/node/cli/browser-demo/README.md b/substrate/bin/node/cli/browser-demo/README.md deleted file mode 100644 index a11b250ba1..0000000000 --- a/substrate/bin/node/cli/browser-demo/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# How to run this demo - -```sh -# If necessary, install wasm-bindgen -# The version must match that used when building the browser demo. -cargo install --version 0.2.67 wasm-bindgen-cli - -# Run the build script -./build.sh -``` diff --git a/substrate/bin/node/cli/browser-demo/build.sh b/substrate/bin/node/cli/browser-demo/build.sh deleted file mode 100755 index 8840106dae..0000000000 --- a/substrate/bin/node/cli/browser-demo/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh -set -e -x -cargo +nightly build --release -p node-cli --target wasm32-unknown-unknown --no-default-features --features browser -Z features=itarget -wasm-bindgen ../../../../target/wasm32-unknown-unknown/release/node_cli.wasm --out-dir pkg --target web -python -m http.server 8000 diff --git a/substrate/bin/node/cli/browser-demo/favicon.png b/substrate/bin/node/cli/browser-demo/favicon.png deleted file mode 100644 index 8a4548ce34dfa220f612080820cfde778a39cb8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 liter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hb3jdR@(!=wy_c35+n#+jzHDU#~B@SG8(m zIqHsHlTp=pNh*J=!I4`heW_`Mf#t*|lSZje!&0PfrM^J<22=3Ub9ueM)Z0O2WjVkv PrbyIPG#^(enFsw3U`DIs diff --git a/substrate/bin/node/cli/browser-demo/index.html b/substrate/bin/node/cli/browser-demo/index.html deleted file mode 100644 index 4a706906ab..0000000000 --- a/substrate/bin/node/cli/browser-demo/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - Substrate node - - - - - diff --git a/substrate/bin/node/cli/src/browser.rs b/substrate/bin/node/cli/src/browser.rs deleted file mode 100644 index dee93180e7..0000000000 --- a/substrate/bin/node/cli/src/browser.rs +++ /dev/null @@ -1,57 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use crate::chain_spec::ChainSpec; -use browser_utils::{browser_configuration, init_logging, set_console_error_panic_hook, Client}; -use log::info; -use wasm_bindgen::prelude::*; - -/// Starts the client. -#[wasm_bindgen] -pub fn start_client(chain_spec: Option, log_level: String) -> Result { - start_inner(chain_spec, log_level).map_err(|err| JsValue::from_str(&err.to_string())) -} - -fn start_inner( - chain_spec: Option, - log_directives: String, -) -> Result> { - set_console_error_panic_hook(); - init_logging(&log_directives)?; - let chain_spec = match chain_spec { - Some(chain_spec) => ChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec()) - .map_err(|e| format!("{:?}", e))?, - None => crate::chain_spec::development_config(), - }; - - let config = browser_configuration(chain_spec)?; - - info!("Substrate browser node"); - info!("✌️ version {}", config.impl_version); - info!("❤️ by Parity Technologies, 2017-2021"); - info!("📋 Chain specification: {}", config.chain_spec.name()); - info!("🏷 Node name: {}", config.network.node_name); - info!("👤 Role: {:?}", config.role); - - // Create the service. This is the most heavy initialization step. - let (task_manager, rpc_handlers) = crate::service::new_light_base(config) - .map(|(components, rpc_handlers, _, _, _)| (components, rpc_handlers)) - .map_err(|e| format!("{:?}", e))?; - - Ok(browser_utils::start_client(task_manager, rpc_handlers)) -} diff --git a/substrate/bin/node/cli/src/lib.rs b/substrate/bin/node/cli/src/lib.rs index d29836c749..1a4c1b0eab 100644 --- a/substrate/bin/node/cli/src/lib.rs +++ b/substrate/bin/node/cli/src/lib.rs @@ -34,15 +34,11 @@ pub mod chain_spec; #[macro_use] mod service; -#[cfg(feature = "browser")] -mod browser; #[cfg(feature = "cli")] mod cli; #[cfg(feature = "cli")] mod command; -#[cfg(feature = "browser")] -pub use browser::*; #[cfg(feature = "cli")] pub use cli::*; #[cfg(feature = "cli")] diff --git a/substrate/bin/node/cli/src/service.rs b/substrate/bin/node/cli/src/service.rs index 938b7e67f3..bd3c92d9aa 100644 --- a/substrate/bin/node/cli/src/service.rs +++ b/substrate/bin/node/cli/src/service.rs @@ -441,12 +441,7 @@ pub fn new_light_base( .clone() .filter(|x| !x.is_empty()) .map(|endpoints| -> Result<_, sc_telemetry::Error> { - #[cfg(feature = "browser")] - let transport = Some(sc_telemetry::ExtTransport::new(libp2p_wasm_ext::ffi::websocket_transport())); - #[cfg(not(feature = "browser"))] - let transport = None; - - let worker = TelemetryWorker::with_transport(16, transport)?; + let worker = TelemetryWorker::new(16)?; let telemetry = worker.handle().new_telemetry(endpoints); Ok((worker, telemetry)) }) diff --git a/substrate/client/cli/src/config.rs b/substrate/client/cli/src/config.rs index d985dce75d..bfc7c6eb7b 100644 --- a/substrate/client/cli/src/config.rs +++ b/substrate/client/cli/src/config.rs @@ -27,10 +27,9 @@ use names::{Generator, Name}; use sc_client_api::execution_extensions::ExecutionStrategies; use sc_service::{ config::{ - BasePath, Configuration, DatabaseSource, ExtTransport, KeystoreConfig, - NetworkConfiguration, NodeKeyConfig, OffchainWorkerConfig, PrometheusConfig, PruningMode, - Role, RpcMethods, TaskExecutor, TelemetryEndpoints, TransactionPoolOptions, - WasmExecutionMethod, + BasePath, Configuration, DatabaseSource, KeystoreConfig, NetworkConfiguration, + NodeKeyConfig, OffchainWorkerConfig, PrometheusConfig, PruningMode, Role, RpcMethods, + TaskExecutor, TelemetryEndpoints, TransactionPoolOptions, WasmExecutionMethod, }, ChainSpec, KeepBlocks, TracingReceiver, TransactionStorageMode, }; @@ -380,13 +379,6 @@ pub trait CliConfiguration: Sized { Ok(chain_spec.telemetry_endpoints().clone()) } - /// Get the telemetry external transport - /// - /// By default this is `None`. - fn telemetry_external_transport(&self) -> Result> { - Ok(None) - } - /// Get the default value for heap pages /// /// By default this is `None`. @@ -526,7 +518,6 @@ pub trait CliConfiguration: Sized { rpc_max_payload: self.rpc_max_payload()?, prometheus_config: self.prometheus_config(DCV::prometheus_listen_port())?, telemetry_endpoints, - telemetry_external_transport: self.telemetry_external_transport()?, default_heap_pages: self.default_heap_pages()?, offchain_worker: self.offchain_worker(&role)?, force_authoring: self.force_authoring()?, diff --git a/substrate/client/cli/src/params/network_params.rs b/substrate/client/cli/src/params/network_params.rs index 676873cfab..6eaf068fda 100644 --- a/substrate/client/cli/src/params/network_params.rs +++ b/substrate/client/cli/src/params/network_params.rs @@ -222,7 +222,6 @@ impl NetworkParams { transport: TransportConfig::Normal { enable_mdns: !is_dev && !self.no_mdns, allow_private_ipv4, - wasm_external_transport: None, }, max_parallel_downloads: self.max_parallel_downloads, enable_dht_random_walk: !self.reserved_only, diff --git a/substrate/client/consensus/common/Cargo.toml b/substrate/client/consensus/common/Cargo.toml index eaf73bb19c..7e47e157b9 100644 --- a/substrate/client/consensus/common/Cargo.toml +++ b/substrate/client/consensus/common/Cargo.toml @@ -29,7 +29,6 @@ sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } parking_lot = "0.11.1" serde = { version = "1.0", features = ["derive"] } prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.9.0" } -wasm-timer = "0.2.5" async-trait = "0.1.42" [dev-dependencies] diff --git a/substrate/client/consensus/common/src/import_queue.rs b/substrate/client/consensus/common/src/import_queue.rs index 57d80cd41c..5117a8fd20 100644 --- a/substrate/client/consensus/common/src/import_queue.rs +++ b/substrate/client/consensus/common/src/import_queue.rs @@ -265,7 +265,7 @@ pub(crate) async fn import_single_block_metered< r => return Ok(r), // Any other successful result means that the block is already imported. } - let started = wasm_timer::Instant::now(); + let started = std::time::Instant::now(); let mut import_block = BlockImportParams::new(block_origin, header); import_block.body = block.body; diff --git a/substrate/client/consensus/common/src/import_queue/basic_queue.rs b/substrate/client/consensus/common/src/import_queue/basic_queue.rs index dbf779c074..a898e268fc 100644 --- a/substrate/client/consensus/common/src/import_queue/basic_queue.rs +++ b/substrate/client/consensus/common/src/import_queue/basic_queue.rs @@ -289,7 +289,7 @@ impl BlockImportWorker { number: NumberFor, justification: Justification, ) { - let started = wasm_timer::Instant::now(); + let started = std::time::Instant::now(); let success = match self.justification_import.as_mut() { Some(justification_import) => justification_import diff --git a/substrate/client/finality-grandpa/Cargo.toml b/substrate/client/finality-grandpa/Cargo.toml index 6fbeeaf1ee..37d07c7919 100644 --- a/substrate/client/finality-grandpa/Cargo.toml +++ b/substrate/client/finality-grandpa/Cargo.toml @@ -45,7 +45,6 @@ prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../.. sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" } finality-grandpa = { version = "0.14.1", features = ["derive-codec"] } async-trait = "0.1.50" -wasm-timer = "0.2" [dev-dependencies] assert_matches = "1.3.0" diff --git a/substrate/client/finality-grandpa/src/communication/gossip.rs b/substrate/client/finality-grandpa/src/communication/gossip.rs index 12d12c9628..bec824bc0b 100644 --- a/substrate/client/finality-grandpa/src/communication/gossip.rs +++ b/substrate/client/finality-grandpa/src/communication/gossip.rs @@ -101,9 +101,8 @@ use crate::{environment, CatchUp, CompactCommit, SignedMessage}; use std::{ collections::{HashMap, HashSet, VecDeque}, - time::Duration, + time::{Duration, Instant}, }; -use wasm_timer::Instant; const REBROADCAST_AFTER: Duration = Duration::from_secs(60 * 5); const CATCH_UP_REQUEST_TIMEOUT: Duration = Duration::from_secs(45); diff --git a/substrate/client/finality-grandpa/src/until_imported.rs b/substrate/client/finality-grandpa/src/until_imported.rs index 4063a3d484..8edf818e0d 100644 --- a/substrate/client/finality-grandpa/src/until_imported.rs +++ b/substrate/client/finality-grandpa/src/until_imported.rs @@ -46,9 +46,8 @@ use std::{ pin::Pin, sync::Arc, task::{Context, Poll}, - time::Duration, + time::{Duration, Instant}, }; -use wasm_timer::Instant; const LOG_PENDING_INTERVAL: Duration = Duration::from_secs(15); diff --git a/substrate/client/informant/Cargo.toml b/substrate/client/informant/Cargo.toml index 73d2a90253..88d02f81ad 100644 --- a/substrate/client/informant/Cargo.toml +++ b/substrate/client/informant/Cargo.toml @@ -23,4 +23,3 @@ sc-network = { version = "0.10.0-dev", path = "../network" } sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } sp-runtime = { version = "4.0.0-dev", path = "../../primitives/runtime" } sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" } -wasm-timer = "0.2" diff --git a/substrate/client/informant/src/display.rs b/substrate/client/informant/src/display.rs index a41cf8e255..1f23856101 100644 --- a/substrate/client/informant/src/display.rs +++ b/substrate/client/informant/src/display.rs @@ -25,8 +25,8 @@ use sp_runtime::traits::{Block as BlockT, CheckedDiv, NumberFor, Saturating, Zer use std::{ convert::{TryFrom, TryInto}, fmt, + time::Instant, }; -use wasm_timer::Instant; /// State of the informant display system. /// diff --git a/substrate/client/network-gossip/Cargo.toml b/substrate/client/network-gossip/Cargo.toml index d06a11c036..06a68a0bda 100644 --- a/substrate/client/network-gossip/Cargo.toml +++ b/substrate/client/network-gossip/Cargo.toml @@ -23,7 +23,6 @@ lru = "0.6.5" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.9.0", path = "../../utils/prometheus" } sc-network = { version = "0.10.0-dev", path = "../network" } sp-runtime = { version = "4.0.0-dev", path = "../../primitives/runtime" } -wasm-timer = "0.2" tracing = "0.1.25" [dev-dependencies] diff --git a/substrate/client/network-gossip/src/state_machine.rs b/substrate/client/network-gossip/src/state_machine.rs index 0fd1e6f6ea..f7851e4974 100644 --- a/substrate/client/network-gossip/src/state_machine.rs +++ b/substrate/client/network-gossip/src/state_machine.rs @@ -29,8 +29,8 @@ use std::{ iter, sync::Arc, time, + time::Instant, }; -use wasm_timer::Instant; // FIXME: Add additional spam/DoS attack protection: https://github.com/paritytech/substrate/issues/1115 // NOTE: The current value is adjusted based on largest production network deployment (Kusama) and diff --git a/substrate/client/network/Cargo.toml b/substrate/client/network/Cargo.toml index a87fb06b82..cef1afc954 100644 --- a/substrate/client/network/Cargo.toml +++ b/substrate/client/network/Cargo.toml @@ -63,7 +63,6 @@ unsigned-varint = { version = "0.6.0", features = [ "asynchronous_codec", ] } void = "1.0.2" -wasm-timer = "0.2" zeroize = "1.2.0" [dependencies.libp2p] diff --git a/substrate/client/network/src/config.rs b/substrate/client/network/src/config.rs index 306a4cfd29..02ee73e8d5 100644 --- a/substrate/client/network/src/config.rs +++ b/substrate/client/network/src/config.rs @@ -29,7 +29,7 @@ pub use crate::{ }, warp_request_handler::WarpSyncProvider, }; -pub use libp2p::{build_multiaddr, core::PublicKey, identity, wasm_ext::ExtTransport}; +pub use libp2p::{build_multiaddr, core::PublicKey, identity}; // Note: this re-export shouldn't be part of the public API of the crate and will be removed in // the future. @@ -42,7 +42,7 @@ use core::{fmt, iter}; use futures::future; use libp2p::{ identity::{ed25519, Keypair}, - multiaddr, wasm_ext, Multiaddr, PeerId, + multiaddr, Multiaddr, PeerId, }; use prometheus_endpoint::Registry; use sc_consensus::ImportQueue; @@ -490,11 +490,7 @@ impl NetworkConfiguration { extra_sets: Vec::new(), client_version: client_version.into(), node_name: node_name.into(), - transport: TransportConfig::Normal { - enable_mdns: false, - allow_private_ipv4: true, - wasm_external_transport: None, - }, + transport: TransportConfig::Normal { enable_mdns: false, allow_private_ipv4: true }, max_parallel_downloads: 5, sync_mode: SyncMode::Full, enable_dht_random_walk: true, @@ -628,14 +624,6 @@ pub enum TransportConfig { /// [RFC1918](https://tools.ietf.org/html/rfc1918)). Irrelevant for addresses that have /// been passed in [`NetworkConfiguration::boot_nodes`]. allow_private_ipv4: bool, - - /// Optional external implementation of a libp2p transport. Used in WASM contexts where we - /// need some binding between the networking provided by the operating system or - /// environment and libp2p. - /// - /// This parameter exists whatever the target platform is, but it is expected to be set to - /// `Some` only when compiling for WASM. - wasm_external_transport: Option, }, /// Only allow connections within the same process. diff --git a/substrate/client/network/src/peer_info.rs b/substrate/client/network/src/peer_info.rs index 13c0917871..ba60c57e8b 100644 --- a/substrate/client/network/src/peer_info.rs +++ b/substrate/client/network/src/peer_info.rs @@ -40,9 +40,8 @@ use std::{ error, io, pin::Pin, task::{Context, Poll}, - time::Duration, + time::{Duration, Instant}, }; -use wasm_timer::Instant; /// Time after we disconnect from a node before we purge its information from the cache. const CACHE_EXPIRE: Duration = Duration::from_secs(10 * 60); diff --git a/substrate/client/network/src/protocol/notifications/behaviour.rs b/substrate/client/network/src/protocol/notifications/behaviour.rs index b618d86b73..1cc6387267 100644 --- a/substrate/client/network/src/protocol/notifications/behaviour.rs +++ b/substrate/client/network/src/protocol/notifications/behaviour.rs @@ -42,9 +42,8 @@ use std::{ str, sync::Arc, task::{Context, Poll}, - time::Duration, + time::{Duration, Instant}, }; -use wasm_timer::Instant; /// Network behaviour that handles opening substreams for custom protocols with other peers. /// diff --git a/substrate/client/network/src/protocol/notifications/handler.rs b/substrate/client/network/src/protocol/notifications/handler.rs index 0a59b2fcf0..9d063eb5b1 100644 --- a/substrate/client/network/src/protocol/notifications/handler.rs +++ b/substrate/client/network/src/protocol/notifications/handler.rs @@ -88,9 +88,8 @@ use std::{ str, sync::Arc, task::{Context, Poll}, - time::Duration, + time::{Duration, Instant}, }; -use wasm_timer::Instant; /// Number of pending notifications in asynchronous contexts. /// See [`NotificationsSink::reserve_notification`] for context. diff --git a/substrate/client/network/src/protocol/sync/extra_requests.rs b/substrate/client/network/src/protocol/sync/extra_requests.rs index 3716384136..f00c416123 100644 --- a/substrate/client/network/src/protocol/sync/extra_requests.rs +++ b/substrate/client/network/src/protocol/sync/extra_requests.rs @@ -24,9 +24,8 @@ use sp_blockchain::Error as ClientError; use sp_runtime::traits::{Block as BlockT, NumberFor, Zero}; use std::{ collections::{HashMap, HashSet, VecDeque}, - time::Duration, + time::{Duration, Instant}, }; -use wasm_timer::Instant; // Time to wait before trying to get the same extra data from the same peer. const EXTRA_RETRY_WAIT: Duration = Duration::from_secs(10); diff --git a/substrate/client/network/src/request_responses.rs b/substrate/client/network/src/request_responses.rs index 2af6e176f6..6e09208dd4 100644 --- a/substrate/client/network/src/request_responses.rs +++ b/substrate/client/network/src/request_responses.rs @@ -60,9 +60,8 @@ use std::{ io, iter, pin::Pin, task::{Context, Poll}, - time::Duration, + time::{Duration, Instant}, }; -use wasm_timer::Instant; pub use libp2p::request_response::{InboundFailure, OutboundFailure, RequestId}; diff --git a/substrate/client/network/src/service.rs b/substrate/client/network/src/service.rs index 92b300fe02..069223c2ff 100644 --- a/substrate/client/network/src/service.rs +++ b/substrate/client/network/src/service.rs @@ -291,10 +291,9 @@ impl NetworkWorker { }; let (transport, bandwidth) = { - let (config_mem, config_wasm) = match params.network_config.transport { - TransportConfig::MemoryOnly => (true, None), - TransportConfig::Normal { wasm_external_transport, .. } => - (false, wasm_external_transport), + let config_mem = match params.network_config.transport { + TransportConfig::MemoryOnly => true, + TransportConfig::Normal { .. } => false, }; // The yamux buffer size limit is configured to be equal to the maximum frame size @@ -337,7 +336,6 @@ impl NetworkWorker { transport::build_transport( local_identity, config_mem, - config_wasm, params.network_config.yamux_window_size, yamux_maximum_buffer_size, ) diff --git a/substrate/client/network/src/transport.rs b/substrate/client/network/src/transport.rs index 710d477599..47382fa3b1 100644 --- a/substrate/client/network/src/transport.rs +++ b/substrate/client/network/src/transport.rs @@ -25,7 +25,7 @@ use libp2p::{ transport::{Boxed, OptionalTransport}, upgrade, }, - identity, mplex, noise, wasm_ext, PeerId, Transport, + identity, mplex, noise, PeerId, Transport, }; #[cfg(not(target_os = "unknown"))] use libp2p::{dns, tcp, websocket}; @@ -51,18 +51,11 @@ pub use self::bandwidth::BandwidthSinks; pub fn build_transport( keypair: identity::Keypair, memory_only: bool, - wasm_external_transport: Option, yamux_window_size: Option, yamux_maximum_buffer_size: usize, ) -> (Boxed<(PeerId, StreamMuxerBox)>, Arc) { // Build the base layer of the transport. - let transport = if let Some(t) = wasm_external_transport { - OptionalTransport::some(t) - } else { - OptionalTransport::none() - }; - #[cfg(not(target_os = "unknown"))] - let transport = transport.or_transport(if !memory_only { + let transport = if !memory_only { let desktop_trans = tcp::TcpConfig::new().nodelay(true); let desktop_trans = websocket::WsConfig::new(desktop_trans.clone()).or_transport(desktop_trans); @@ -73,9 +66,9 @@ pub fn build_transport( EitherTransport::Right(desktop_trans.map_err(dns::DnsErr::Transport)) }) } else { + // For the in-memory case we set up the transport with an `.or_transport` below. OptionalTransport::none() - }); - + }; let transport = transport.or_transport(if memory_only { OptionalTransport::some(libp2p::core::transport::MemoryTransport::default()) } else { diff --git a/substrate/client/peerset/src/lib.rs b/substrate/client/peerset/src/lib.rs index a7b4bdd434..838f4c411c 100644 --- a/substrate/client/peerset/src/lib.rs +++ b/substrate/client/peerset/src/lib.rs @@ -42,9 +42,9 @@ use std::{ collections::{HashMap, HashSet, VecDeque}, pin::Pin, task::{Context, Poll}, - time::Duration, + time::{Duration, Instant}, }; -use wasm_timer::{Delay, Instant}; +use wasm_timer::Delay; pub use libp2p::PeerId; diff --git a/substrate/client/peerset/src/peersstate.rs b/substrate/client/peerset/src/peersstate.rs index e4062bf938..de79ee520f 100644 --- a/substrate/client/peerset/src/peersstate.rs +++ b/substrate/client/peerset/src/peersstate.rs @@ -36,8 +36,8 @@ use std::{ hash_map::{Entry, OccupiedEntry}, HashMap, HashSet, }, + time::Instant, }; -use wasm_timer::Instant; /// State storage behind the peerset. /// diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml index 4f1bffd659..d0d85a5549 100644 --- a/substrate/client/service/Cargo.toml +++ b/substrate/client/service/Cargo.toml @@ -30,7 +30,6 @@ rand = "0.7.3" parking_lot = "0.11.1" log = "0.4.11" futures-timer = "3.0.1" -wasm-timer = "0.2" exit-future = "0.2.0" pin-project = "1.0.4" hash-db = "0.15.2" diff --git a/substrate/client/service/src/builder.rs b/substrate/client/service/src/builder.rs index fc9fbad1ef..9b5390710c 100644 --- a/substrate/client/service/src/builder.rs +++ b/substrate/client/service/src/builder.rs @@ -62,8 +62,7 @@ use sp_runtime::{ BuildStorage, }; use sp_utils::mpsc::{tracing_unbounded, TracingUnboundedSender}; -use std::{str::FromStr, sync::Arc}; -use wasm_timer::SystemTime; +use std::{str::FromStr, sync::Arc, time::SystemTime}; /// A utility trait for building an RPC extension given a `DenyUnsafe` instance. /// This is useful since at service definition time we don't know whether the diff --git a/substrate/client/service/src/config.rs b/substrate/client/service/src/config.rs index 67a4a2acfc..4223a18122 100644 --- a/substrate/client/service/src/config.rs +++ b/substrate/client/service/src/config.rs @@ -23,7 +23,7 @@ pub use sc_client_db::{Database, DatabaseSource, KeepBlocks, PruningMode, Transa pub use sc_executor::WasmExecutionMethod; pub use sc_network::{ config::{ - ExtTransport, IncomingRequest, MultiaddrWithPeerId, NetworkConfiguration, NodeKeyConfig, + IncomingRequest, MultiaddrWithPeerId, NetworkConfiguration, NodeKeyConfig, NonDefaultSetConfig, OutgoingResponse, RequestResponseConfig, Role, SetConfig, TransportConfig, }, @@ -107,9 +107,6 @@ pub struct Configuration { pub prometheus_config: Option, /// Telemetry service URL. `None` if disabled. pub telemetry_endpoints: Option, - /// External WASM transport for the telemetry. If `Some`, when connection to a telemetry - /// endpoint, this transport will be tried in priority before all others. - pub telemetry_external_transport: Option, /// The default number of 64KB pages to allocate for Wasm execution pub default_heap_pages: Option, /// Should offchain workers be executed. diff --git a/substrate/client/service/src/metrics.rs b/substrate/client/service/src/metrics.rs index cd03916c92..e3ad9e9cce 100644 --- a/substrate/client/service/src/metrics.rs +++ b/substrate/client/service/src/metrics.rs @@ -28,8 +28,10 @@ use sc_transaction_pool_api::{MaintainedTransactionPool, PoolStatus}; use sp_api::ProvideRuntimeApi; use sp_runtime::traits::{Block, NumberFor, SaturatedConversion, UniqueSaturatedInto}; use sp_utils::metrics::register_globals; -use std::{sync::Arc, time::Duration}; -use wasm_timer::Instant; +use std::{ + sync::Arc, + time::{Duration, Instant}, +}; struct PrometheusMetrics { // generic info diff --git a/substrate/client/service/test/src/lib.rs b/substrate/client/service/test/src/lib.rs index 87153c2736..6e86b9fcfd 100644 --- a/substrate/client/service/test/src/lib.rs +++ b/substrate/client/service/test/src/lib.rs @@ -221,11 +221,8 @@ fn node_config< .collect(), ); - network_config.transport = TransportConfig::Normal { - enable_mdns: false, - allow_private_ipv4: true, - wasm_external_transport: None, - }; + network_config.transport = + TransportConfig::Normal { enable_mdns: false, allow_private_ipv4: true }; Configuration { impl_name: String::from("network-test-impl"), @@ -256,7 +253,6 @@ fn node_config< rpc_max_payload: None, prometheus_config: None, telemetry_endpoints: None, - telemetry_external_transport: None, default_heap_pages: None, offchain_worker: Default::default(), force_authoring: false, diff --git a/substrate/client/telemetry/src/lib.rs b/substrate/client/telemetry/src/lib.rs index 929931e3b6..9fb86f57d8 100644 --- a/substrate/client/telemetry/src/lib.rs +++ b/substrate/client/telemetry/src/lib.rs @@ -46,7 +46,6 @@ use std::{ sync::{atomic, Arc}, }; -pub use libp2p::wasm_ext::ExtTransport; pub use log; pub use serde_json; @@ -124,15 +123,7 @@ impl TelemetryWorker { /// /// Only one is needed per process. pub fn new(buffer_size: usize) -> Result { - Self::with_transport(buffer_size, None) - } - - /// Instantiate a new [`TelemetryWorker`] with the given [`ExtTransport`] - /// which can run in background. - /// - /// Only one is needed per process. - pub fn with_transport(buffer_size: usize, transport: Option) -> Result { - let transport = initialize_transport(transport)?; + let transport = initialize_transport()?; let (message_sender, message_receiver) = mpsc::channel(buffer_size); let (register_sender, register_receiver) = mpsc::unbounded(); diff --git a/substrate/client/telemetry/src/transport.rs b/substrate/client/telemetry/src/transport.rs index 2c309be0ff..04ec79ebf5 100644 --- a/substrate/client/telemetry/src/transport.rs +++ b/substrate/client/telemetry/src/transport.rs @@ -22,30 +22,15 @@ use futures::{ ready, task::{Context, Poll}, }; -use libp2p::{ - core::transport::{timeout::TransportTimeout, OptionalTransport}, - wasm_ext, Transport, -}; +use libp2p::{core::transport::timeout::TransportTimeout, Transport}; use std::{io, pin::Pin, time::Duration}; /// Timeout after which a connection attempt is considered failed. Includes the WebSocket HTTP /// upgrading. const CONNECT_TIMEOUT: Duration = Duration::from_secs(20); -pub(crate) fn initialize_transport( - wasm_external_transport: Option, -) -> Result { - let transport = match wasm_external_transport.clone() { - Some(t) => OptionalTransport::some(t), - None => OptionalTransport::none(), - } - .map((|inner, _| StreamSink::from(inner)) as fn(_, _) -> _); - - // The main transport is the `wasm_external_transport`, but if we're on desktop we add - // support for TCP+WebSocket+DNS as a fallback. In practice, you're not expected to pass - // an external transport on desktop and the fallback is used all the time. - #[cfg(not(target_os = "unknown"))] - let transport = transport.or_transport({ +pub(crate) fn initialize_transport() -> Result { + let transport = { let inner = block_on(libp2p::dns::DnsConfig::system(libp2p::tcp::TcpConfig::new()))?; libp2p::websocket::framed::WsConfig::new(inner).and_then(|connec, _| { let connec = connec @@ -57,7 +42,7 @@ pub(crate) fn initialize_transport( .map_ok(|data| data.into_bytes()); future::ready(Ok::<_, io::Error>(connec)) }) - }); + }; Ok(TransportTimeout::new( transport.map(|out, _| { @@ -86,9 +71,6 @@ pub(crate) type WsTrans = libp2p::core::transport::Boxed< /// Wraps around an `AsyncWrite` and implements `Sink`. Guarantees that each item being sent maps /// to one call of `write`. -/// -/// For some context, we put this object around the `wasm_ext::ExtTransport` in order to make sure -/// that each telemetry message maps to one single call to `write` in the WASM FFI. #[pin_project::pin_project] pub(crate) struct StreamSink(#[pin] T, Option>); diff --git a/substrate/client/tracing/src/logging/layers/console_log.rs b/substrate/client/tracing/src/logging/layers/console_log.rs deleted file mode 100644 index 77295110c8..0000000000 --- a/substrate/client/tracing/src/logging/layers/console_log.rs +++ /dev/null @@ -1,116 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use crate::logging::event_format::{CustomFmtContext, EventFormat}; -use std::fmt; -use tracing::{Event, Level, Subscriber}; -use tracing_subscriber::{ - fmt::{ - time::{FormatTime, SystemTime}, - FormatFields, - }, - layer::Context, - registry::LookupSpan, - Layer, -}; -use wasm_bindgen::prelude::*; - -/// A `Layer` that display logs in the browser's console. -pub struct ConsoleLogLayer { - event_format: EventFormat, - fmt_fields: N, - _inner: std::marker::PhantomData, -} - -impl ConsoleLogLayer { - /// Create a new [`ConsoleLogLayer`] using the `EventFormat` provided in argument. - pub fn new(event_format: EventFormat) -> Self { - Self { event_format, fmt_fields: Default::default(), _inner: std::marker::PhantomData } - } -} - -// NOTE: the following code took inspiration from `EventFormat` (in this file) -impl ConsoleLogLayer -where - S: Subscriber + for<'a> LookupSpan<'a>, - N: for<'writer> FormatFields<'writer> + 'static, -{ - fn format_event( - &self, - ctx: &Context<'_, S>, - writer: &mut dyn fmt::Write, - event: &Event, - ) -> fmt::Result { - self.event_format.format_event_custom( - CustomFmtContext::ContextWithFormatFields(ctx, &self.fmt_fields), - writer, - event, - ) - } -} - -// NOTE: the following code took inspiration from tracing-subscriber -// -// https://github.com/tokio-rs/tracing/blob/2f59b32/tracing-subscriber/src/fmt/fmt_layer.rs#L717 -impl Layer for ConsoleLogLayer -where - S: Subscriber + for<'a> LookupSpan<'a>, - N: for<'writer> FormatFields<'writer> + 'static, - T: FormatTime + 'static, -{ - fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>) { - thread_local! { - static BUF: std::cell::RefCell = std::cell::RefCell::new(String::new()); - } - - BUF.with(|buf| { - let borrow = buf.try_borrow_mut(); - let mut a; - let mut b; - let mut buf = match borrow { - Ok(buf) => { - a = buf; - &mut *a - }, - _ => { - b = String::new(); - &mut b - }, - }; - - if self.format_event(&ctx, &mut buf, event).is_ok() { - if !buf.is_empty() { - let meta = event.metadata(); - let level = meta.level(); - // NOTE: the following code took inspiration from tracing-subscriber - // - // https://github.com/iamcodemaker/console_log/blob/f13b5d6755/src/lib.rs#L149 - match *level { - Level::ERROR => web_sys::console::error_1(&JsValue::from(buf.as_str())), - Level::WARN => web_sys::console::warn_1(&JsValue::from(buf.as_str())), - Level::INFO => web_sys::console::info_1(&JsValue::from(buf.as_str())), - Level::DEBUG => web_sys::console::log_1(&JsValue::from(buf.as_str())), - Level::TRACE => web_sys::console::debug_1(&JsValue::from(buf.as_str())), - } - } - } - - buf.clear(); - }); - } -} diff --git a/substrate/client/tracing/src/logging/layers/mod.rs b/substrate/client/tracing/src/logging/layers/mod.rs index 8bda65f4c9..7dd0c4d120 100644 --- a/substrate/client/tracing/src/logging/layers/mod.rs +++ b/substrate/client/tracing/src/logging/layers/mod.rs @@ -16,10 +16,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#[cfg(target_os = "unknown")] -mod console_log; mod prefix_layer; -#[cfg(target_os = "unknown")] -pub use console_log::*; pub use prefix_layer::*; diff --git a/substrate/client/transaction-pool/Cargo.toml b/substrate/client/transaction-pool/Cargo.toml index 12b0646983..e2858a41d5 100644 --- a/substrate/client/transaction-pool/Cargo.toml +++ b/substrate/client/transaction-pool/Cargo.toml @@ -30,7 +30,6 @@ sp-transaction-pool = { version = "4.0.0-dev", path = "../../primitives/transact sc-transaction-pool-api = { version = "4.0.0-dev", path = "./api" } sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } sp-utils = { version = "4.0.0-dev", path = "../../primitives/utils" } -wasm-timer = "0.2" serde = { version = "1.0.126", features = ["derive"] } linked-hash-map = "0.5.4" retain_mut = "0.1.3" diff --git a/substrate/client/transaction-pool/graph/Cargo.toml b/substrate/client/transaction-pool/graph/Cargo.toml index 162829e1dd..aa4000f7c0 100644 --- a/substrate/client/transaction-pool/graph/Cargo.toml +++ b/substrate/client/transaction-pool/graph/Cargo.toml @@ -19,7 +19,6 @@ futures = "0.3.9" log = "0.4.8" parking_lot = "0.11.1" serde = { version = "1.0.101", features = ["derive"] } -wasm-timer = "0.2" sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } sp-utils = { version = "4.0.0-dev", path = "../../../primitives/utils" } sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" } diff --git a/substrate/client/transaction-pool/src/graph/future.rs b/substrate/client/transaction-pool/src/graph/future.rs index b0e70698f3..201d6f40e8 100644 --- a/substrate/client/transaction-pool/src/graph/future.rs +++ b/substrate/client/transaction-pool/src/graph/future.rs @@ -24,7 +24,7 @@ use std::{ use sp_core::hexdisplay::HexDisplay; use sp_runtime::transaction_validity::TransactionTag as Tag; -use wasm_timer::Instant; +use std::time::Instant; use super::base_pool::Transaction; diff --git a/substrate/client/transaction-pool/src/graph/pool.rs b/substrate/client/transaction-pool/src/graph/pool.rs index 21ce46785f..70de9b2356 100644 --- a/substrate/client/transaction-pool/src/graph/pool.rs +++ b/substrate/client/transaction-pool/src/graph/pool.rs @@ -27,7 +27,7 @@ use sp_runtime::{ TransactionSource, TransactionTag as Tag, TransactionValidity, TransactionValidityError, }, }; -use wasm_timer::Instant; +use std::time::Instant; use super::{ base_pool as base, @@ -454,9 +454,11 @@ mod tests { traits::Hash, transaction_validity::{InvalidTransaction, TransactionSource, ValidTransaction}, }; - use std::collections::{HashMap, HashSet}; + use std::{ + collections::{HashMap, HashSet}, + time::Instant, + }; use substrate_test_runtime::{AccountId, Block, Extrinsic, Hashing, Transfer, H256}; - use wasm_timer::Instant; const INVALID_NONCE: u64 = 254; const SOURCE: TransactionSource = TransactionSource::External; diff --git a/substrate/client/transaction-pool/src/graph/rotator.rs b/substrate/client/transaction-pool/src/graph/rotator.rs index 820fde35da..910f86b5ed 100644 --- a/substrate/client/transaction-pool/src/graph/rotator.rs +++ b/substrate/client/transaction-pool/src/graph/rotator.rs @@ -22,8 +22,11 @@ //! Discarded extrinsics are banned so that they don't get re-imported again. use parking_lot::RwLock; -use std::{collections::HashMap, hash, iter, time::Duration}; -use wasm_timer::Instant; +use std::{ + collections::HashMap, + hash, iter, + time::{Duration, Instant}, +}; use super::base_pool::Transaction; diff --git a/substrate/client/transaction-pool/src/graph/validated_pool.rs b/substrate/client/transaction-pool/src/graph/validated_pool.rs index a0adeef683..4dd5ea3b67 100644 --- a/substrate/client/transaction-pool/src/graph/validated_pool.rs +++ b/substrate/client/transaction-pool/src/graph/validated_pool.rs @@ -32,7 +32,7 @@ use sp_runtime::{ traits::{self, SaturatedConversion}, transaction_validity::{TransactionSource, TransactionTag as Tag, ValidTransaction}, }; -use wasm_timer::Instant; +use std::time::Instant; use super::{ base_pool::{self as base, PruneStatus}, diff --git a/substrate/client/transaction-pool/src/lib.rs b/substrate/client/transaction-pool/src/lib.rs index c35bba8d2a..cd97abab93 100644 --- a/substrate/client/transaction-pool/src/lib.rs +++ b/substrate/client/transaction-pool/src/lib.rs @@ -63,7 +63,7 @@ use sp_runtime::{ generic::BlockId, traits::{AtLeast32Bit, Block as BlockT, Extrinsic, Header as HeaderT, NumberFor, Zero}, }; -use wasm_timer::Instant; +use std::time::Instant; use crate::metrics::MetricsLink as PrometheusMetrics; use prometheus_endpoint::Registry as PrometheusRegistry; diff --git a/substrate/docs/Upgrading-2.0-to-3.0.md b/substrate/docs/Upgrading-2.0-to-3.0.md index 914b7b788d..45da381122 100644 --- a/substrate/docs/Upgrading-2.0-to-3.0.md +++ b/substrate/docs/Upgrading-2.0-to-3.0.md @@ -439,69 +439,6 @@ and add the new service: The telemetry subsystem has seen a few fixes and refactorings to allow for a more flexible handling, in particular in regards to parachains. Most notably `sc_service::spawn_tasks` now returns the `telemetry_connection_notifier` as the second member of the tuple, (`let (_rpc_handlers, telemetry_connection_notifier) = sc_service::spawn_tasks(`), which should be passed to `telemetry_on_connect` of `new_full_base` now: `telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()),` (see the service-section below for a full diff). -On the browser-side, this complicates setup a tiny bit, yet not terribly. Instead of `init_console_log`, we now use `init_logging_and_telemetry` and need to make sure we spawn the runner for its handle at the end (the other changes are formatting and cosmetics): - -```diff ---- a/bin/node/cli/src/browser.rs -+++ b/bin/node/cli/src/browser.rs -@@ -21,9 +21,8 @@ use log::info; - use wasm_bindgen::prelude::*; - use browser_utils::{ - Client, -- browser_configuration, set_console_error_panic_hook, init_console_log, -+ browser_configuration, init_logging_and_telemetry, set_console_error_panic_hook, - }; --use std::str::FromStr; - - /// Starts the client. - #[wasm_bindgen] -@@ -33,29 +32,38 @@ pub async fn start_client(chain_spec: Option, log_level: String) -> Resu - .map_err(|err| JsValue::from_str(&err.to_string())) - } - --async fn start_inner(chain_spec: Option, log_level: String) -> Result> { -+async fn start_inner( -+ chain_spec: Option, -+ log_directives: String, -+) -> Result> { - set_console_error_panic_hook(); -- init_console_log(log::Level::from_str(&log_level)?)?; -+ let telemetry_worker = init_logging_and_telemetry(&log_directives)?; - let chain_spec = match chain_spec { - Some(chain_spec) => ChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec()) - .map_err(|e| format!("{:?}", e))?, - None => crate::chain_spec::development_config(), - }; - -- let config = browser_configuration(chain_spec).await?; -+ let telemetry_handle = telemetry_worker.handle(); -+ let config = browser_configuration( -+ chain_spec, -+ Some(telemetry_handle), -+ ).await?; - - info!("Substrate browser node"); - info!("✌️ version {}", config.impl_version); -- info!("❤️ by Parity Technologies, 2017-2020"); -+ info!("❤️ by Parity Technologies, 2017-2021"); - info!("📋 Chain specification: {}", config.chain_spec.name()); -- info!("🏷 Node name: {}", config.network.node_name); -+ info!("🏷 Node name: {}", config.network.node_name); - info!("👤 Role: {:?}", config.role); - - // Create the service. This is the most heavy initialization step. - let (task_manager, rpc_handlers) = - crate::service::new_light_base(config) -- .map(|(components, rpc_handlers, _, _, _)| (components, rpc_handlers)) -+ .map(|(components, rpc_handlers, _, _, _, _)| (components, rpc_handlers)) - .map_err(|e| format!("{:?}", e))?; - -+ task_manager.spawn_handle().spawn("telemetry", telemetry_worker.run()); -+ - Ok(browser_utils::start_client(task_manager, rpc_handlers)) - } - ``` - ##### Async & Remote Keystore support In order to allow for remote-keystores, the keystore-subsystem has been reworked to support async operations and generally refactored to not provide the keys itself but only sign on request. This allows for remote-keystore to never hand out keys and thus to operate any substrate-based node in a manner without ever having the private keys in the local system memory. diff --git a/substrate/primitives/timestamp/Cargo.toml b/substrate/primitives/timestamp/Cargo.toml index 137faa3725..60daf9642d 100644 --- a/substrate/primitives/timestamp/Cargo.toml +++ b/substrate/primitives/timestamp/Cargo.toml @@ -18,7 +18,6 @@ sp-std = { version = "4.0.0-dev", default-features = false, path = "../std" } sp-runtime = { version = "4.0.0-dev", default-features = false, path = "../runtime" } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] } sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../inherents" } -wasm-timer = { version = "0.2", optional = true } thiserror = { version = "1.0.21", optional = true } log = { version = "0.4.8", optional = true } futures-timer = { version = "3.0.2", optional = true } @@ -32,7 +31,6 @@ std = [ "sp-runtime/std", "codec/std", "sp-inherents/std", - "wasm-timer", "thiserror", "log", "futures-timer", diff --git a/substrate/primitives/timestamp/src/lib.rs b/substrate/primitives/timestamp/src/lib.rs index 5de1b10e79..02a579497b 100644 --- a/substrate/primitives/timestamp/src/lib.rs +++ b/substrate/primitives/timestamp/src/lib.rs @@ -164,7 +164,7 @@ impl TimestampInherentData for InherentData { /// This timestamp is the time since the UNIX epoch. #[cfg(feature = "std")] fn current_timestamp() -> std::time::Duration { - use wasm_timer::SystemTime; + use std::time::SystemTime; let now = SystemTime::now(); now.duration_since(SystemTime::UNIX_EPOCH) diff --git a/substrate/test-utils/test-runner/src/utils.rs b/substrate/test-utils/test-runner/src/utils.rs index 2fe3a98d44..3caba633dc 100644 --- a/substrate/test-utils/test-runner/src/utils.rs +++ b/substrate/test-utils/test-runner/src/utils.rs @@ -101,7 +101,6 @@ pub fn default_config( rpc_max_payload: None, prometheus_config: None, telemetry_endpoints: None, - telemetry_external_transport: None, default_heap_pages: None, offchain_worker: Default::default(), force_authoring: false, diff --git a/substrate/utils/browser/Cargo.toml b/substrate/utils/browser/Cargo.toml deleted file mode 100644 index 9ede0f2ce8..0000000000 --- a/substrate/utils/browser/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "substrate-browser-utils" -version = "0.10.0-dev" -authors = ["Parity Technologies "] -description = "Utilities for creating a browser light-client." -edition = "2018" -license = "Apache-2.0" -homepage = "https://substrate.dev" -repository = "https://github.com/paritytech/substrate/" -readme = "README.md" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[dependencies] -futures = "0.3.16" -log = "0.4.8" -libp2p-wasm-ext = { version = "0.29", features = ["websocket"] } -console_error_panic_hook = "0.1.6" -js-sys = "0.3.34" -wasm-bindgen = "0.2.73" -wasm-bindgen-futures = "0.4.18" -kvdb-memorydb = "0.10.0" -sp-database = { version = "4.0.0-dev", path = "../../primitives/database" } -sc-informant = { version = "0.10.0-dev", path = "../../client/informant" } -sc-service = { version = "0.10.0-dev", path = "../../client/service", default-features = false } -sc-network = { path = "../../client/network", version = "0.10.0-dev"} -sc-chain-spec = { path = "../../client/chain-spec", version = "4.0.0-dev"} -sc-tracing = { path = "../../client/tracing", version = "4.0.0-dev"} - -# Imported just for the `wasm-bindgen` feature -getrandom = { version = "0.2", features = ["js"] } -rand = { version = "0.7", features = ["wasm-bindgen"] } -futures-timer = { version = "3.0.1", features = ["wasm-bindgen"]} -chrono = { version = "0.4", features = ["wasmbind"] } diff --git a/substrate/utils/browser/README.md b/substrate/utils/browser/README.md deleted file mode 100644 index 9718db58b3..0000000000 --- a/substrate/utils/browser/README.md +++ /dev/null @@ -1 +0,0 @@ -License: Apache-2.0 \ No newline at end of file diff --git a/substrate/utils/browser/src/lib.rs b/substrate/utils/browser/src/lib.rs deleted file mode 100644 index 49f5c7ad4b..0000000000 --- a/substrate/utils/browser/src/lib.rs +++ /dev/null @@ -1,212 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use futures::{ - channel::{mpsc, oneshot}, - future::{ready, select}, - prelude::*, -}; -use libp2p_wasm_ext::{ffi, ExtTransport}; -use log::{debug, info}; -use sc_chain_spec::Extension; -use sc_network::config::TransportConfig; -use sc_service::{ - config::{DatabaseSource, KeystoreConfig, NetworkConfiguration}, - Configuration, GenericChainSpec, KeepBlocks, Role, RpcHandlers, RpcSession, RuntimeGenesis, - TaskManager, TransactionStorageMode, -}; -use sc_tracing::logging::LoggerBuilder; -use std::pin::Pin; -use wasm_bindgen::prelude::*; - -pub use console_error_panic_hook::set_once as set_console_error_panic_hook; - -/// Initialize the logger and return a `TelemetryWorker` and a wasm `ExtTransport`. -pub fn init_logging(pattern: &str) -> Result<(), sc_tracing::logging::Error> { - LoggerBuilder::new(pattern).init() -} - -/// Create a service configuration from a chain spec. -/// -/// This configuration contains good defaults for a browser light client. -pub fn browser_configuration( - chain_spec: GenericChainSpec, -) -> Result> -where - G: RuntimeGenesis + 'static, - E: Extension + 'static + Send + Sync, -{ - let name = chain_spec.name().to_string(); - let transport = ExtTransport::new(ffi::websocket_transport()); - - let mut network = NetworkConfiguration::new( - format!("{} (Browser)", name), - "unknown", - Default::default(), - None, - ); - network.boot_nodes = chain_spec.boot_nodes().to_vec(); - network.transport = TransportConfig::Normal { - wasm_external_transport: Some(transport.clone()), - allow_private_ipv4: true, - enable_mdns: false, - }; - - let config = Configuration { - network, - telemetry_endpoints: chain_spec.telemetry_endpoints().clone(), - chain_spec: Box::new(chain_spec), - task_executor: (|fut, _| { - wasm_bindgen_futures::spawn_local(fut); - async {} - }) - .into(), - telemetry_external_transport: Some(transport), - role: Role::Light, - database: { - info!("Opening Indexed DB database '{}'...", name); - let db = kvdb_memorydb::create(10); - - DatabaseSource::Custom(sp_database::as_database(db)) - }, - keystore_remote: Default::default(), - keystore: KeystoreConfig::InMemory, - default_heap_pages: Default::default(), - dev_key_seed: Default::default(), - disable_grandpa: Default::default(), - execution_strategies: Default::default(), - force_authoring: Default::default(), - impl_name: String::from("parity-substrate"), - impl_version: String::from("0.0.0"), - offchain_worker: Default::default(), - prometheus_config: Default::default(), - state_pruning: Default::default(), - keep_blocks: KeepBlocks::All, - transaction_storage: TransactionStorageMode::BlockBody, - rpc_cors: Default::default(), - rpc_http: Default::default(), - rpc_ipc: Default::default(), - rpc_ws: Default::default(), - rpc_ws_max_connections: Default::default(), - rpc_http_threads: Default::default(), - rpc_methods: Default::default(), - rpc_max_payload: Default::default(), - state_cache_child_ratio: Default::default(), - state_cache_size: Default::default(), - tracing_receiver: Default::default(), - tracing_targets: Default::default(), - transaction_pool: Default::default(), - wasm_method: Default::default(), - wasm_runtime_overrides: Default::default(), - max_runtime_instances: 8, - announce_block: true, - base_path: None, - informant_output_format: sc_informant::OutputFormat { enable_color: false }, - disable_log_reloading: false, - }; - - Ok(config) -} - -/// A running client. -#[wasm_bindgen] -pub struct Client { - rpc_send_tx: mpsc::UnboundedSender, -} - -struct RpcMessage { - rpc_json: String, - session: RpcSession, - send_back: oneshot::Sender> + Send>>>, -} - -/// Create a Client object that connects to a service. -pub fn start_client(mut task_manager: TaskManager, rpc_handlers: RpcHandlers) -> Client { - // We dispatch a background task responsible for processing the service. - // - // The main action performed by the code below consists in polling the service with - // `service.poll()`. - // The rest consists in handling RPC requests. - let (rpc_send_tx, rpc_send_rx) = mpsc::unbounded::(); - wasm_bindgen_futures::spawn_local( - select( - rpc_send_rx.for_each(move |message| { - let fut = rpc_handlers.rpc_query(&message.session, &message.rpc_json); - let _ = message.send_back.send(fut); - ready(()) - }), - Box::pin(async move { - let _ = task_manager.future().await; - }), - ) - .map(drop), - ); - - Client { rpc_send_tx } -} - -#[wasm_bindgen] -impl Client { - /// Allows starting an RPC request. Returns a `Promise` containing the result of that request. - #[wasm_bindgen(js_name = "rpcSend")] - pub fn rpc_send(&mut self, rpc: &str) -> js_sys::Promise { - let rpc_session = RpcSession::new(mpsc::unbounded().0); - let (tx, rx) = oneshot::channel(); - let _ = self.rpc_send_tx.unbounded_send(RpcMessage { - rpc_json: rpc.to_owned(), - session: rpc_session, - send_back: tx, - }); - wasm_bindgen_futures::future_to_promise(async { - match rx.await { - Ok(fut) => fut.await.map(|s| JsValue::from_str(&s)).ok_or_else(|| JsValue::NULL), - Err(_) => Err(JsValue::NULL), - } - }) - } - - /// Subscribes to an RPC pubsub endpoint. - #[wasm_bindgen(js_name = "rpcSubscribe")] - pub fn rpc_subscribe(&mut self, rpc: &str, callback: js_sys::Function) { - let (tx, rx) = mpsc::unbounded(); - let rpc_session = RpcSession::new(tx); - let (fut_tx, fut_rx) = oneshot::channel(); - let _ = self.rpc_send_tx.unbounded_send(RpcMessage { - rpc_json: rpc.to_owned(), - session: rpc_session.clone(), - send_back: fut_tx, - }); - wasm_bindgen_futures::spawn_local(async { - if let Ok(fut) = fut_rx.await { - fut.await; - } - }); - - wasm_bindgen_futures::spawn_local(async move { - let _ = rx - .for_each(|s| { - let _ = callback.call1(&callback, &JsValue::from_str(&s)); - ready(()) - }) - .await; - - // We need to keep `rpc_session` alive. - debug!("RPC subscription has ended"); - drop(rpc_session); - }); - } -}