Companion PR for 'Remove substrate-in-the-browser #9541' (#3652)

* Remove telemetry external transport member

* Make it compile

* Remove more

Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
David
2021-08-18 00:54:10 +02:00
committed by GitHub
parent 6718e10f20
commit 9607487442
11 changed files with 157 additions and 339 deletions
+153 -214
View File
File diff suppressed because it is too large Load Diff
-9
View File
@@ -17,8 +17,6 @@ crate-type = ["cdylib", "rlib"]
log = "0.4.13" log = "0.4.13"
thiserror = "1.0.26" thiserror = "1.0.26"
structopt = { version = "0.3.21", optional = true } structopt = { version = "0.3.21", optional = true }
wasm-bindgen = { version = "0.2.70", optional = true }
wasm-bindgen-futures = { version = "0.4.25", optional = true }
futures = "0.3.15" futures = "0.3.15"
service = { package = "polkadot-service", path = "../node/service", default-features = false, optional = true } service = { package = "polkadot-service", path = "../node/service", default-features = false, optional = true }
@@ -29,7 +27,6 @@ frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", bran
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
browser-utils = { package = "substrate-browser-utils", git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
# this crate is used only to enable `trie-memory-tracker` feature # this crate is used only to enable `trie-memory-tracker` feature
# see https://github.com/paritytech/substrate/pull/6745 # see https://github.com/paritytech/substrate/pull/6745
@@ -57,12 +54,6 @@ cli = [
# is resolved. # is resolved.
"service/memory-stats", "service/memory-stats",
] ]
browser = [
"wasm-bindgen",
"wasm-bindgen-futures",
"browser-utils",
"service/light-node",
]
runtime-benchmarks = [ "service/runtime-benchmarks" ] runtime-benchmarks = [ "service/runtime-benchmarks" ]
trie-memory-tracker = [ "sp-trie/memory-tracker" ] trie-memory-tracker = [ "sp-trie/memory-tracker" ]
full-node = [ "service/full-node" ] full-node = [ "service/full-node" ]
-1
View File
@@ -1 +0,0 @@
pkg
-9
View File
@@ -1,9 +0,0 @@
# How to run this demo
```sh
cargo install wasm-pack # If necessary
wasm-pack build --target web --out-dir ./browser-demo/pkg --no-typescript --release ./.. -- --no-default-features --features "browser"
xdg-open index.html
```
-3
View File
@@ -1,3 +0,0 @@
#!/usr/bin/env sh
wasm-pack build --target web --out-dir ./browser-demo/pkg --no-typescript --release ./.. -- --no-default-features --features "browser"
python -m http.server 8000
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

-41
View File
@@ -1,41 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>Polkadot node</title>
<link rel="shortcut icon" href="/favicon.png" />
<script type="module">
import { start_client, default as init } from './pkg/polkadot_cli.js';
function log(msg) {
document.getElementsByTagName('body')[0].innerHTML += msg + '\n';
}
async function start() {
log('Loading WASM');
await init('./pkg/polkadot_cli_bg.wasm');
log('Successfully loaded WASM');
log('Fetching chain spec');
const chain_spec_response = await fetch("https://raw.githubusercontent.com/paritytech/polkadot/master/node/service/res/westend.json");
const chain_spec_text = await chain_spec_response.text();
// Build our client.
log('Starting client');
let client = start_client(chain_spec_text, 'info');
log('Client started');
client.rpcSubscribe('{"method":"chain_subscribeNewHead","params":[],"id":1,"jsonrpc":"2.0"}',
(r) => log("New chain head: " + r));
setInterval(() => {
client
.rpcSend('{"method":"system_networkState","params":[],"id":1,"jsonrpc":"2.0"}')
.then((r) => log("Network state: " + r));
}, 20000);
}
start();
</script>
</head>
<body style="white-space: pre"></body>
</html>
-50
View File
@@ -1,50 +0,0 @@
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate 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.
// Substrate 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 Substrate. If not, see <http://www.gnu.org/licenses/>.
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: String, log_level: String) -> Result<Client, JsValue> {
start_inner(chain_spec, log_level).map_err(|err| JsValue::from_str(&err.to_string()))
}
fn start_inner(
chain_spec: String,
log_directives: String,
) -> Result<Client, Box<dyn std::error::Error>> {
set_console_error_panic_hook();
init_logging(&log_directives)?;
let chain_spec = service::PolkadotChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec())
.map_err(|e| format!("{:?}", e))?;
let config = browser_configuration(chain_spec)?;
info!("Polkadot browser node");
info!(" version {}", config.impl_version);
info!(" by Parity Technologies, 2017-2020");
info!("📋 Chain specification: {}", config.chain_spec.name());
info!("🏷 Node name: {}", config.network.node_name);
info!("👤 Role: {}", config.display_role());
// Create the service. This is the most heavy initialization step.
let (task_manager, rpc_handlers) =
service::build_light(config).map_err(|e| format!("{:?}", e))?;
Ok(browser_utils::start_client(task_manager, rpc_handlers))
}
+4 -9
View File
@@ -240,11 +240,6 @@ fn run_node_inner(cli: Cli, overseer_gen: impl service::OverseerGen) -> Result<(
let role = config.role.clone(); let role = config.role.clone();
match role { match role {
#[cfg(feature = "browser")]
Role::Light => service::build_light(config)
.map(|(task_manager, _)| task_manager)
.map_err(Into::into),
#[cfg(not(feature = "browser"))]
Role::Light => Err(Error::Other("Light client not enabled".into())), Role::Light => Err(Error::Other("Light client not enabled".into())),
_ => service::build_full( _ => service::build_full(
config, config,
@@ -338,7 +333,7 @@ pub fn run() -> Result<()> {
builder.with_colors(false); builder.with_colors(false);
let _ = builder.init(); let _ = builder.init();
#[cfg(any(target_os = "android", feature = "browser"))] #[cfg(target_os = "android")]
{ {
return Err(sc_cli::Error::Input( return Err(sc_cli::Error::Input(
"PVF preparation workers are not supported under this platform".into(), "PVF preparation workers are not supported under this platform".into(),
@@ -346,7 +341,7 @@ pub fn run() -> Result<()> {
.into()) .into())
} }
#[cfg(not(any(target_os = "android", feature = "browser")))] #[cfg(not(target_os = "android"))]
{ {
polkadot_node_core_pvf::prepare_worker_entrypoint(&cmd.socket_path); polkadot_node_core_pvf::prepare_worker_entrypoint(&cmd.socket_path);
Ok(()) Ok(())
@@ -357,7 +352,7 @@ pub fn run() -> Result<()> {
builder.with_colors(false); builder.with_colors(false);
let _ = builder.init(); let _ = builder.init();
#[cfg(any(target_os = "android", feature = "browser"))] #[cfg(target_os = "android")]
{ {
return Err(sc_cli::Error::Input( return Err(sc_cli::Error::Input(
"PVF execution workers are not supported under this platform".into(), "PVF execution workers are not supported under this platform".into(),
@@ -365,7 +360,7 @@ pub fn run() -> Result<()> {
.into()) .into())
} }
#[cfg(not(any(target_os = "android", feature = "browser")))] #[cfg(not(target_os = "android"))]
{ {
polkadot_node_core_pvf::execute_worker_entrypoint(&cmd.socket_path); polkadot_node_core_pvf::execute_worker_entrypoint(&cmd.socket_path);
Ok(()) Ok(())
-2
View File
@@ -18,8 +18,6 @@
#![warn(missing_docs)] #![warn(missing_docs)]
#[cfg(feature = "browser")]
mod browser;
#[cfg(feature = "cli")] #[cfg(feature = "cli")]
mod cli; mod cli;
#[cfg(feature = "cli")] #[cfg(feature = "cli")]
-1
View File
@@ -181,7 +181,6 @@ pub fn node_config(
rpc_methods: Default::default(), rpc_methods: Default::default(),
prometheus_config: None, prometheus_config: None,
telemetry_endpoints: None, telemetry_endpoints: None,
telemetry_external_transport: None,
default_heap_pages: None, default_heap_pages: None,
offchain_worker: Default::default(), offchain_worker: Default::default(),
force_authoring: false, force_authoring: false,