mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Companion PR for https://github.com/paritytech/substrate/pull/7463 (#1948)
* Adapt service creation to new substrate API * Fix test * WIP * Revert "WIP" This reverts commit 816a3633e91abc943b12b2bfa77ce98b959e78b2. * WIP * Adapt to current code * Fix tests * Yet another fix * CLEANUP * WIP * WIP * WIP * Adapt code to changes on substrate * Adapt code * Introduce kick. * Fixes * WIP * WIP * WIP * WIP * Bump * Update sp-io * WIP Co-authored-by: Gav Wood <gavin@parity.io> Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
This commit is contained in:
Generated
+166
-218
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@ use log::info;
|
|||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
use browser_utils::{
|
use browser_utils::{
|
||||||
Client,
|
Client,
|
||||||
browser_configuration, set_console_error_panic_hook, init_console_log,
|
browser_configuration, init_logging_and_telemetry, set_console_error_panic_hook,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Starts the client.
|
/// Starts the client.
|
||||||
@@ -29,13 +29,14 @@ pub async fn start_client(chain_spec: String, log_level: String) -> Result<Clien
|
|||||||
.map_err(|err| JsValue::from_str(&err.to_string()))
|
.map_err(|err| JsValue::from_str(&err.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start_inner(chain_spec: String, log_level: String) -> Result<Client, Box<dyn std::error::Error>> {
|
async fn start_inner(chain_spec: String, log_directives: String) -> Result<Client, Box<dyn std::error::Error>> {
|
||||||
set_console_error_panic_hook();
|
set_console_error_panic_hook();
|
||||||
init_console_log(log_level.parse()?)?;
|
let telemetry_worker = init_logging_and_telemetry(&log_directives)?;
|
||||||
|
|
||||||
let chain_spec = service::PolkadotChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec())
|
let chain_spec = service::PolkadotChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec())
|
||||||
.map_err(|e| format!("{:?}", e))?;
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
let config = browser_configuration(chain_spec).await?;
|
let telemetry_handle = telemetry_worker.handle();
|
||||||
|
let config = browser_configuration(chain_spec, Some(telemetry_handle)).await?;
|
||||||
|
|
||||||
info!("Polkadot browser node");
|
info!("Polkadot browser node");
|
||||||
info!(" version {}", config.impl_version);
|
info!(" version {}", config.impl_version);
|
||||||
@@ -45,7 +46,9 @@ async fn start_inner(chain_spec: String, log_level: String) -> Result<Client, Bo
|
|||||||
info!("👤 Role: {}", config.display_role());
|
info!("👤 Role: {}", config.display_role());
|
||||||
|
|
||||||
// Create the service. This is the most heavy initialization step.
|
// Create the service. This is the most heavy initialization step.
|
||||||
let (task_manager, rpc_handlers) = service::build_light(config).map_err(|e| format!("{:?}", e))?;
|
let (task_manager, rpc_handlers, _) = service::build_light(config).map_err(|e| format!("{:?}", e))?;
|
||||||
|
|
||||||
|
task_manager.spawn_handle().spawn("telemetry", telemetry_worker.run());
|
||||||
|
|
||||||
Ok(browser_utils::start_client(task_manager, rpc_handlers))
|
Ok(browser_utils::start_client(task_manager, rpc_handlers))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ pub fn run() -> Result<()> {
|
|||||||
let role = config.role.clone();
|
let role = config.role.clone();
|
||||||
|
|
||||||
let task_manager = match role {
|
let task_manager = match role {
|
||||||
Role::Light => service::build_light(config).map(|(task_manager, _)| task_manager),
|
Role::Light => service::build_light(config).map(|(task_manager, _, _)| task_manager),
|
||||||
_ => service::build_full(
|
_ => service::build_full(
|
||||||
config,
|
config,
|
||||||
service::IsCollator::No,
|
service::IsCollator::No,
|
||||||
@@ -249,15 +249,9 @@ pub fn run() -> Result<()> {
|
|||||||
})?)
|
})?)
|
||||||
},
|
},
|
||||||
Some(Subcommand::ValidationWorker(cmd)) => {
|
Some(Subcommand::ValidationWorker(cmd)) => {
|
||||||
let _ = sc_cli::init_logger(
|
let mut builder = sc_cli::GlobalLoggerBuilder::new("");
|
||||||
sc_cli::InitLoggerParams {
|
builder.with_colors(false);
|
||||||
pattern: "".into(),
|
let _ = builder.init();
|
||||||
tracing_receiver: Default::default(),
|
|
||||||
tracing_targets: None,
|
|
||||||
disable_log_reloading: false,
|
|
||||||
disable_log_color: true,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if cfg!(feature = "browser") || cfg!(target_os = "android") {
|
if cfg!(feature = "browser") || cfg!(target_os = "android") {
|
||||||
Err(sc_cli::Error::Input("Cannot run validation worker in browser".into()).into())
|
Err(sc_cli::Error::Input("Cannot run validation worker in browser".into()).into())
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ use std::sync::Arc;
|
|||||||
use prometheus_endpoint::Registry;
|
use prometheus_endpoint::Registry;
|
||||||
use sc_executor::native_executor_instance;
|
use sc_executor::native_executor_instance;
|
||||||
use service::RpcHandlers;
|
use service::RpcHandlers;
|
||||||
|
use telemetry::TelemetryConnectionNotifier;
|
||||||
|
|
||||||
pub use self::client::{AbstractClient, Client, ClientHandle, ExecuteWithClient, RuntimeApiCollection};
|
pub use self::client::{AbstractClient, Client, ClientHandle, ExecuteWithClient, RuntimeApiCollection};
|
||||||
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec, RococoChainSpec};
|
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec, RococoChainSpec};
|
||||||
@@ -215,6 +216,7 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration, jaeger_agent: O
|
|||||||
babe::BabeLink<Block>
|
babe::BabeLink<Block>
|
||||||
),
|
),
|
||||||
grandpa::SharedVoterState,
|
grandpa::SharedVoterState,
|
||||||
|
Option<telemetry::TelemetrySpan>,
|
||||||
)
|
)
|
||||||
>,
|
>,
|
||||||
Error
|
Error
|
||||||
@@ -230,7 +232,7 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration, jaeger_agent: O
|
|||||||
|
|
||||||
let inherent_data_providers = inherents::InherentDataProviders::new();
|
let inherent_data_providers = inherents::InherentDataProviders::new();
|
||||||
|
|
||||||
let (client, backend, keystore_container, task_manager) =
|
let (client, backend, keystore_container, task_manager, telemetry_span) =
|
||||||
service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
|
service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||||
let client = Arc::new(client);
|
let client = Arc::new(client);
|
||||||
|
|
||||||
@@ -332,7 +334,7 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration, jaeger_agent: O
|
|||||||
import_queue,
|
import_queue,
|
||||||
transaction_pool,
|
transaction_pool,
|
||||||
inherent_data_providers,
|
inherent_data_providers,
|
||||||
other: (rpc_extensions_builder, import_setup, rpc_setup)
|
other: (rpc_extensions_builder, import_setup, rpc_setup, telemetry_span)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,7 +560,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
|||||||
import_queue,
|
import_queue,
|
||||||
transaction_pool,
|
transaction_pool,
|
||||||
inherent_data_providers,
|
inherent_data_providers,
|
||||||
other: (rpc_extensions_builder, import_setup, rpc_setup)
|
other: (rpc_extensions_builder, import_setup, rpc_setup, telemetry_span)
|
||||||
} = new_partial::<RuntimeApi, Executor>(&mut config, jaeger_agent)?;
|
} = new_partial::<RuntimeApi, Executor>(&mut config, jaeger_agent)?;
|
||||||
|
|
||||||
let prometheus_registry = config.prometheus_registry().cloned();
|
let prometheus_registry = config.prometheus_registry().cloned();
|
||||||
@@ -604,11 +606,9 @@ pub fn new_full<RuntimeApi, Executor>(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let telemetry_connection_sinks = service::TelemetryConnectionSinks::default();
|
|
||||||
|
|
||||||
let availability_config = config.database.clone().try_into().map_err(Error::Availability)?;
|
let availability_config = config.database.clone().try_into().map_err(Error::Availability)?;
|
||||||
|
|
||||||
let rpc_handlers = service::spawn_tasks(service::SpawnTasksParams {
|
let (rpc_handlers, telemetry_connection_notifier) = service::spawn_tasks(service::SpawnTasksParams {
|
||||||
config,
|
config,
|
||||||
backend: backend.clone(),
|
backend: backend.clone(),
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
@@ -619,9 +619,9 @@ pub fn new_full<RuntimeApi, Executor>(
|
|||||||
task_manager: &mut task_manager,
|
task_manager: &mut task_manager,
|
||||||
on_demand: None,
|
on_demand: None,
|
||||||
remote_blockchain: None,
|
remote_blockchain: None,
|
||||||
telemetry_connection_sinks: telemetry_connection_sinks.clone(),
|
|
||||||
network_status_sinks: network_status_sinks.clone(),
|
network_status_sinks: network_status_sinks.clone(),
|
||||||
system_rpc_tx,
|
system_rpc_tx,
|
||||||
|
telemetry_span,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let (block_import, link_half, babe_link) = import_setup;
|
let (block_import, link_half, babe_link) = import_setup;
|
||||||
@@ -794,7 +794,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
|||||||
config,
|
config,
|
||||||
link: link_half,
|
link: link_half,
|
||||||
network: network.clone(),
|
network: network.clone(),
|
||||||
telemetry_on_connect: Some(telemetry_connection_sinks.on_connect_stream()),
|
telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()),
|
||||||
voting_rule,
|
voting_rule,
|
||||||
prometheus_registry: prometheus_registry.clone(),
|
prometheus_registry: prometheus_registry.clone(),
|
||||||
shared_voter_state,
|
shared_voter_state,
|
||||||
@@ -820,7 +820,11 @@ pub fn new_full<RuntimeApi, Executor>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a new service for a light client.
|
/// Builds a new service for a light client.
|
||||||
fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManager, RpcHandlers), Error>
|
fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(
|
||||||
|
TaskManager,
|
||||||
|
RpcHandlers,
|
||||||
|
Option<TelemetryConnectionNotifier>,
|
||||||
|
), Error>
|
||||||
where
|
where
|
||||||
Runtime: 'static + Send + Sync + ConstructRuntimeApi<Block, LightClient<Runtime, Dispatch>>,
|
Runtime: 'static + Send + Sync + ConstructRuntimeApi<Block, LightClient<Runtime, Dispatch>>,
|
||||||
<Runtime as ConstructRuntimeApi<Block, LightClient<Runtime, Dispatch>>>::RuntimeApi:
|
<Runtime as ConstructRuntimeApi<Block, LightClient<Runtime, Dispatch>>>::RuntimeApi:
|
||||||
@@ -830,7 +834,7 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManage
|
|||||||
set_prometheus_registry(&mut config)?;
|
set_prometheus_registry(&mut config)?;
|
||||||
use sc_client_api::backend::RemoteBackend;
|
use sc_client_api::backend::RemoteBackend;
|
||||||
|
|
||||||
let (client, backend, keystore_container, mut task_manager, on_demand) =
|
let (client, backend, keystore_container, mut task_manager, on_demand, telemetry_span) =
|
||||||
service::new_light_parts::<Block, Runtime, Dispatch>(&config)?;
|
service::new_light_parts::<Block, Runtime, Dispatch>(&config)?;
|
||||||
|
|
||||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||||
@@ -901,12 +905,11 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManage
|
|||||||
|
|
||||||
let rpc_extensions = polkadot_rpc::create_light(light_deps);
|
let rpc_extensions = polkadot_rpc::create_light(light_deps);
|
||||||
|
|
||||||
let rpc_handlers = service::spawn_tasks(service::SpawnTasksParams {
|
let (rpc_handlers, telemetry_connection_notifier) = service::spawn_tasks(service::SpawnTasksParams {
|
||||||
on_demand: Some(on_demand),
|
on_demand: Some(on_demand),
|
||||||
remote_blockchain: Some(backend.remote_blockchain()),
|
remote_blockchain: Some(backend.remote_blockchain()),
|
||||||
rpc_extensions_builder: Box::new(service::NoopRpcExtensionBuilder(rpc_extensions)),
|
rpc_extensions_builder: Box::new(service::NoopRpcExtensionBuilder(rpc_extensions)),
|
||||||
task_manager: &mut task_manager,
|
task_manager: &mut task_manager,
|
||||||
telemetry_connection_sinks: service::TelemetryConnectionSinks::default(),
|
|
||||||
config,
|
config,
|
||||||
keystore: keystore_container.sync_keystore(),
|
keystore: keystore_container.sync_keystore(),
|
||||||
backend,
|
backend,
|
||||||
@@ -915,11 +918,12 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManage
|
|||||||
network,
|
network,
|
||||||
network_status_sinks,
|
network_status_sinks,
|
||||||
system_rpc_tx,
|
system_rpc_tx,
|
||||||
|
telemetry_span,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
network_starter.start_network();
|
network_starter.start_network();
|
||||||
|
|
||||||
Ok((task_manager, rpc_handlers))
|
Ok((task_manager, rpc_handlers, telemetry_connection_notifier))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a new object suitable for chain operations.
|
/// Builds a new object suitable for chain operations.
|
||||||
@@ -955,7 +959,11 @@ pub fn new_chain_ops(mut config: &mut Configuration, jaeger_agent: Option<std::n
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Build a new light node.
|
/// Build a new light node.
|
||||||
pub fn build_light(config: Configuration) -> Result<(TaskManager, RpcHandlers), Error> {
|
pub fn build_light(config: Configuration) -> Result<(
|
||||||
|
TaskManager,
|
||||||
|
RpcHandlers,
|
||||||
|
Option<TelemetryConnectionNotifier>,
|
||||||
|
), Error> {
|
||||||
if config.chain_spec.is_rococo() {
|
if config.chain_spec.is_rococo() {
|
||||||
new_light::<rococo_runtime::RuntimeApi, RococoExecutor>(config)
|
new_light::<rococo_runtime::RuntimeApi, RococoExecutor>(config)
|
||||||
} else if config.chain_spec.is_kusama() {
|
} else if config.chain_spec.is_kusama() {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
|
|||||||
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
service = { package = "sc-service", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
service = { package = "sc-service", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ pub type Client = FullClient<polkadot_test_runtime::RuntimeApi, PolkadotTestExec
|
|||||||
pub use polkadot_service::FullBackend;
|
pub use polkadot_service::FullBackend;
|
||||||
|
|
||||||
/// Create a new full node.
|
/// Create a new full node.
|
||||||
#[sc_cli::prefix_logs_with(config.network.node_name.as_str())]
|
#[sc_tracing::logging::prefix_logs_with(config.network.node_name.as_str())]
|
||||||
pub fn new_full(
|
pub fn new_full(
|
||||||
config: Configuration,
|
config: Configuration,
|
||||||
is_collator: IsCollator,
|
is_collator: IsCollator,
|
||||||
@@ -198,6 +198,7 @@ pub fn node_config(
|
|||||||
base_path: Some(base_path),
|
base_path: Some(base_path),
|
||||||
informant_output_format: Default::default(),
|
informant_output_format: Default::default(),
|
||||||
disable_log_reloading: false,
|
disable_log_reloading: false,
|
||||||
|
telemetry_handle: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,9 @@ use sp_keyring::Sr25519Keyring;
|
|||||||
|
|
||||||
#[substrate_test_utils::test]
|
#[substrate_test_utils::test]
|
||||||
async fn ensure_test_service_build_blocks(task_executor: TaskExecutor) {
|
async fn ensure_test_service_build_blocks(task_executor: TaskExecutor) {
|
||||||
sc_cli::init_logger(
|
let mut builder = sc_cli::GlobalLoggerBuilder::new("");
|
||||||
sc_cli::InitLoggerParams {
|
builder.with_colors(false);
|
||||||
pattern: "".into(),
|
builder.init().expect("Sets up logger");
|
||||||
tracing_receiver: Default::default(),
|
|
||||||
tracing_targets: None,
|
|
||||||
disable_log_reloading: false,
|
|
||||||
disable_log_color: true,
|
|
||||||
},
|
|
||||||
).expect("Sets up logger");
|
|
||||||
|
|
||||||
let mut alice = run_validator_node(
|
let mut alice = run_validator_node(
|
||||||
task_executor.clone(),
|
task_executor.clone(),
|
||||||
|
|||||||
@@ -25,15 +25,9 @@ async fn collating_using_adder_collator(task_executor: sc_service::TaskExecutor)
|
|||||||
use futures::join;
|
use futures::join;
|
||||||
use polkadot_primitives::v1::Id as ParaId;
|
use polkadot_primitives::v1::Id as ParaId;
|
||||||
|
|
||||||
sc_cli::init_logger(
|
let mut builder = sc_cli::GlobalLoggerBuilder::new("");
|
||||||
sc_cli::InitLoggerParams {
|
builder.with_colors(false);
|
||||||
pattern: "".into(),
|
builder.init().expect("Set up logger");
|
||||||
tracing_receiver: Default::default(),
|
|
||||||
tracing_targets: None,
|
|
||||||
disable_log_reloading: false,
|
|
||||||
disable_log_color: true,
|
|
||||||
},
|
|
||||||
).expect("Sets up logger");
|
|
||||||
|
|
||||||
let para_id = ParaId::from(100);
|
let para_id = ParaId::from(100);
|
||||||
|
|
||||||
|
|||||||
@@ -205,4 +205,7 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
|
|||||||
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(w as Weight)))
|
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(w as Weight)))
|
||||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||||
}
|
}
|
||||||
|
fn kick(w: u32, ) -> Weight {
|
||||||
|
w as Weight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,4 +205,7 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
|
|||||||
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(w as Weight)))
|
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(w as Weight)))
|
||||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||||
}
|
}
|
||||||
|
fn kick(w: u32, ) -> Weight {
|
||||||
|
w as Weight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,4 +205,7 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
|
|||||||
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(w as Weight)))
|
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(w as Weight)))
|
||||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||||
}
|
}
|
||||||
|
fn kick(w: u32, ) -> Weight {
|
||||||
|
w as Weight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user