mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 18:11:10 +00:00
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 888009a8e0b7051bd4bfbbfdb0448bcf2e2aae93. * Add wasm support for state machine * Switch to my own libp2p version * Revert "Switch to my own libp2p version" This reverts commit ce613871b59264b3165b45c37943e6560240daa7. * Revert "Add wasm support for state machine" This reverts commit de7eaa0694d9534fc3b164621737968e9a6a7c5f. * 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 <ben@gnunicorn.org> * 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 4690cf1882aa0f99f7f00a58c4080c8aa9b77c36. * 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 baa4ffc94fd968b6660a2c17ba8113e06af15548. * Pass whole chain spec in start_client * Get Instant::now to work in transaction pool again * Informant dep reordering Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com> Co-authored-by: Benjamin Kampmann <ben.kampmann@googlemail.com> Co-authored-by: Demi Obenour <48690212+DemiMarie-parity@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
// Copyright 2017-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/>.
|
||||
|
||||
//! Console informant. Prints sync progress and block events. Runs on the calling thread.
|
||||
|
||||
use sc_client_api::BlockchainEvents;
|
||||
use futures::prelude::*;
|
||||
use log::{info, warn, trace};
|
||||
use sp_runtime::traits::Header;
|
||||
use sc_service::AbstractService;
|
||||
use std::time::Duration;
|
||||
|
||||
mod display;
|
||||
|
||||
/// The format to print telemetry output in.
|
||||
#[derive(PartialEq)]
|
||||
pub enum OutputFormat {
|
||||
Coloured,
|
||||
Plain,
|
||||
}
|
||||
|
||||
/// Creates an informant in the form of a `Future` that must be polled regularly.
|
||||
pub fn build(service: &impl AbstractService, format: OutputFormat) -> impl futures::Future<Output = ()> {
|
||||
let client = service.client();
|
||||
let pool = service.transaction_pool();
|
||||
|
||||
let mut display = display::InformantDisplay::new(format);
|
||||
|
||||
let display_notifications = service
|
||||
.network_status(Duration::from_millis(5000))
|
||||
.for_each(move |(net_status, _)| {
|
||||
let info = client.usage_info();
|
||||
if let Some(ref usage) = info.usage {
|
||||
trace!(target: "usage", "Usage statistics: {}", usage);
|
||||
} else {
|
||||
trace!(target: "usage", "Usage statistics not displayed as backend does not provide it")
|
||||
}
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
trace!(
|
||||
target: "usage",
|
||||
"Subsystems memory [txpool: {} kB]",
|
||||
parity_util_mem::malloc_size(&*pool) / 1024,
|
||||
);
|
||||
display.display(&info, net_status);
|
||||
future::ready(())
|
||||
});
|
||||
|
||||
let client = service.client();
|
||||
let mut last_best = {
|
||||
let info = client.usage_info();
|
||||
Some((info.chain.best_number, info.chain.best_hash))
|
||||
};
|
||||
|
||||
let display_block_import = client.import_notification_stream().for_each(move |n| {
|
||||
// detect and log reorganizations.
|
||||
if let Some((ref last_num, ref last_hash)) = last_best {
|
||||
if n.header.parent_hash() != last_hash && n.is_new_best {
|
||||
let maybe_ancestor = sp_blockchain::lowest_common_ancestor(
|
||||
&*client,
|
||||
last_hash.clone(),
|
||||
n.hash,
|
||||
);
|
||||
|
||||
match maybe_ancestor {
|
||||
Ok(ref ancestor) if ancestor.hash != *last_hash => info!(
|
||||
"Reorg from #{},{} to #{},{}, common ancestor #{},{}",
|
||||
last_num, last_hash,
|
||||
n.header.number(), n.hash,
|
||||
ancestor.number, ancestor.hash,
|
||||
),
|
||||
Ok(_) => {},
|
||||
Err(e) => warn!("Error computing tree route: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if n.is_new_best {
|
||||
last_best = Some((n.header.number().clone(), n.hash.clone()));
|
||||
}
|
||||
|
||||
info!(target: "substrate", "Imported #{} ({})", n.header.number(), n.hash);
|
||||
future::ready(())
|
||||
});
|
||||
|
||||
future::join(
|
||||
display_notifications,
|
||||
display_block_import
|
||||
).map(|_| ())
|
||||
}
|
||||
Reference in New Issue
Block a user