Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit ae03ee9

Browse files
expensestomakabkchrsvyatonikgnunicorn
authored
Fix timer panics in the wasm light client (#4561)
* Make WASM browser thing compile * Fix * updated exit-future (github repo) * Switch to broadcast crate * Migrate client/cli * Switch exit-future to modernize branch * Small changes * Switch to cargo version and fix fg tests * fix basic-authorship * Fix crash on grafana macro * Fix grafana macro * Switch node python version * Disable record_metrics_slice in grafana macro on wasm * Update client/grafana-data-source/src/lib.rs * Revert "Update client/grafana-data-source/src/lib.rs" This reverts commit 888009a. * Add wasm support for state machine * Switch to my own libp2p version * Revert "Switch to my own libp2p version" This reverts commit ce61387. * Revert "Add wasm support for state machine" This reverts commit de7eaa0. * Add sc-browser * Squash * remove sc-browser * Fix keystore on wasm * stubs for removed functions to make env compatible with old runtimes * Add test (that doesn't work) * Fix build scripts * Revert basic-authorship due to no panics * Revert cli/informant * Revert consensus * revert offchain * Update utils/browser/Cargo.toml Co-Authored-By: Benjamin Kampmann <[email protected]> * export console functions * Add new chainspec * Fix ws in chain spec * revert chainspec * Fix chainspec * Use an Option<PathBuf> in keystore instead of cfg flags * Remove crud * Only use wasm-timer for instant and systemtime * Remove telemetry changes * Assuming this is ok * Add a KeystoreConfig * Add stubs back in * Update libp2p * Revert "Add stubs back in" This reverts commit 4690cf1. * Remove commented js again * Bump kvdb-web version * Fix cli * Switch branch on futures-timer * Fix tests * Remove sc-client test build in check-web-wasm because there isn't a good way to build futures-timer with wasm-bindgen support in the build * Remove more things ^^ * Switch branch on futures-timer back * Put DB io stats behind a cfg flag * Fix things * Don't timeout transports on wasm * Update branch of futures-timer and fix bad merge * Spawn informant * Fix network test * Fix delay resets * Changes * Fix tests * use wasm_timer for transaction pool * Fixes * Switch futures-timer to crates * Only diagnose futures on native * Fix sc-network-test tests * Select log level in js * Fix syncing ;^) * Allow disabling colours in the informant * Use OutputFormat enum for informant * MallocSizeOf impl on transaction pool broke stuff because wasm_timer::Instant doesnt impl it so just revert the transaction pool to master * Update futures-diagnose * Revert "MallocSizeOf impl on transaction pool broke stuff because wasm_timer::Instant doesnt impl it so just revert the transaction pool to master" This reverts commit baa4ffc. * Pass whole chain spec in start_client * Get Instant::now to work in transaction pool again * Informant dep reordering Co-authored-by: Pierre Krieger <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Svyatoslav Nikolsky <[email protected]> Co-authored-by: Benjamin Kampmann <[email protected]> Co-authored-by: Demi Obenour <[email protected]>
1 parent 7e8ac2e commit ae03ee9

File tree

54 files changed

+297
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+297
-153
lines changed

Cargo.lock

Lines changed: 71 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ members = [
3535
"client/executor/wasmtime",
3636
"client/executor/runtime-test",
3737
"client/finality-grandpa",
38+
"client/informant",
3839
"client/tracing",
3940
"client/keystore",
4041
"client/network",

bin/node/cli/browser-demo/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
async function start() {
1616
log('Loading WASM');
1717
await init('./pkg/node_cli_bg.wasm');
18-
log('Successfully loaded WASM');
18+
log('Fetching chain spec');
19+
const chain_spec_response = await fetch("https://raw.githubusercontent.com/paritytech/substrate/master/bin/node/cli/res/flaming-fir.json");
20+
const chain_spec_text = await chain_spec_response.text();
1921

2022
// Build our client.
21-
log('Starting client');
22-
let client = await start_client(ws());
23+
let client = await start_client(chain_spec_text, 'info', ws());
2324
log('Client started');
2425

2526
client.rpcSubscribe('{"method":"chain_subscribeNewHead","params":[],"id":1,"jsonrpc":"2.0"}',

bin/node/cli/src/browser.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
1616

17-
use crate::ChainSpec;
17+
use crate::chain_spec::ChainSpec;
1818
use log::info;
1919
use wasm_bindgen::prelude::*;
2020
use sc_service::Configuration;
2121
use browser_utils::{
2222
Transport, Client,
2323
browser_configuration, set_console_error_panic_hook, init_console_log,
2424
};
25+
use std::str::FromStr;
2526

2627
/// Starts the client.
2728
#[wasm_bindgen]
28-
pub async fn start_client(wasm_ext: Transport) -> Result<Client, JsValue> {
29-
start_inner(wasm_ext)
29+
pub async fn start_client(chain_spec: String, log_level: String, wasm_ext: Transport) -> Result<Client, JsValue> {
30+
start_inner(chain_spec, log_level, wasm_ext)
3031
.await
3132
.map_err(|err| JsValue::from_str(&err.to_string()))
3233
}
3334

34-
async fn start_inner(wasm_ext: Transport) -> Result<Client, Box<dyn std::error::Error>> {
35+
async fn start_inner(chain_spec: String, log_level: String, wasm_ext: Transport) -> Result<Client, Box<dyn std::error::Error>> {
3536
set_console_error_panic_hook();
36-
init_console_log(log::Level::Info)?;
37-
38-
let chain_spec = ChainSpec::FlamingFir.load()
37+
init_console_log(log::Level::from_str(&log_level)?)?;
38+
let chain_spec = ChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec())
3939
.map_err(|e| format!("{:?}", e))?;
4040

4141
let config: Configuration<_, _> = browser_configuration(wasm_ext, chain_spec)

client/authority-discovery/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bytes = "0.4.12"
1414
codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" }
1515
derive_more = "0.99.2"
1616
futures = "0.3.1"
17-
futures-timer = "2.0"
17+
futures-timer = "3.0.1"
1818
libp2p = { version = "0.15.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] }
1919
log = "0.4.8"
2020
prost = "0.6.1"

client/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tokio = { version = "0.2.9", features = [ "signal", "rt-core", "rt-threaded" ] }
2121
futures = "0.3.1"
2222
fdlimit = "0.1.1"
2323
serde_json = "1.0.41"
24+
sc-informant = { version = "0.8", path = "../informant" }
2425
sp-panic-handler = { version = "2.0.0", path = "../../primitives/panic-handler" }
2526
sc-client-api = { version = "2.0.0", path = "../api" }
2627
sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" }

0 commit comments

Comments
 (0)