mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 20:01:08 +00:00
Companion PR for Add a build-sync-spec subcommand and remove the CHT roots from the light sync state. (#1670)
* Add BuildSyncSpec * Remove accidental whitespace * Update substrate * Update substrate * Fix wasm compilation
This commit is contained in:
Generated
+139
-138
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,9 @@ pub enum Subcommand {
|
||||
/// Build a chain specification.
|
||||
BuildSpec(sc_cli::BuildSpecCmd),
|
||||
|
||||
/// Build a chain specification with a light client sync state.
|
||||
BuildSyncSpec(sc_cli::BuildSyncSpecCmd),
|
||||
|
||||
/// Validate blocks.
|
||||
CheckBlock(sc_cli::CheckBlockCmd),
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ use service::{IdentifyVariant, self};
|
||||
use service_new::{IdentifyVariant, self as service};
|
||||
use sc_cli::{SubstrateCli, Result, RuntimeVersion, Role};
|
||||
use crate::cli::{Cli, Subcommand};
|
||||
use std::sync::Arc;
|
||||
|
||||
fn get_exec_name() -> Option<String> {
|
||||
std::env::current_exe()
|
||||
@@ -154,6 +155,39 @@ pub fn run() -> Result<()> {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||
},
|
||||
Some(Subcommand::BuildSyncSpec(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
let chain_spec = &runner.config().chain_spec;
|
||||
|
||||
set_default_ss58_version(chain_spec);
|
||||
|
||||
let authority_discovery_enabled = cli.run.authority_discovery_enabled;
|
||||
let grandpa_pause = if cli.run.grandpa_pause.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some((cli.run.grandpa_pause[0], cli.run.grandpa_pause[1]))
|
||||
};
|
||||
|
||||
if chain_spec.is_kusama() {
|
||||
info!("----------------------------");
|
||||
info!("This chain is not in any way");
|
||||
info!(" endorsed by the ");
|
||||
info!(" KUSAMA FOUNDATION ");
|
||||
info!("----------------------------");
|
||||
}
|
||||
|
||||
runner.async_run(|config| {
|
||||
let chain_spec = config.chain_spec.cloned_box();
|
||||
let network_config = config.network.clone();
|
||||
let service::NewFull { task_manager, client, network_status_sinks, .. }
|
||||
= service::new_full_nongeneric(
|
||||
config, None, authority_discovery_enabled, grandpa_pause, false,
|
||||
)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
Ok((cmd.run(chain_spec, network_config, client, network_status_sinks), task_manager))
|
||||
})
|
||||
},
|
||||
Some(Subcommand::CheckBlock(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
let chain_spec = &runner.config().chain_spec;
|
||||
|
||||
@@ -27,7 +27,7 @@ use polkadot_primitives::v0::{
|
||||
};
|
||||
use polkadot_runtime_common::BlockHashCount;
|
||||
use polkadot_service::{
|
||||
new_full, FullNodeHandles, AbstractClient, ClientHandle, ExecuteWithClient,
|
||||
new_full, NewFull, FullNodeHandles, AbstractClient, ClientHandle, ExecuteWithClient,
|
||||
};
|
||||
use polkadot_test_runtime::{Runtime, SignedExtra, SignedPayload, VERSION};
|
||||
use sc_chain_spec::ChainSpec;
|
||||
@@ -74,7 +74,7 @@ pub fn polkadot_test_new_full(
|
||||
),
|
||||
ServiceError,
|
||||
> {
|
||||
let (task_manager, client, handles, network, rpc_handlers) =
|
||||
let NewFull { task_manager, client, node_handles, network, rpc_handlers, .. } =
|
||||
new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
@@ -83,7 +83,7 @@ pub fn polkadot_test_new_full(
|
||||
true,
|
||||
)?;
|
||||
|
||||
Ok((task_manager, client, handles, network, rpc_handlers))
|
||||
Ok((task_manager, client, node_handles, network, rpc_handlers))
|
||||
}
|
||||
|
||||
/// A wrapper for the test client that implements `ClientHandle`.
|
||||
|
||||
@@ -349,3 +349,48 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_blockchain::HeaderBackend<Block> for Client {
|
||||
fn header(&self, id: BlockId<Block>) -> sp_blockchain::Result<Option<<Block as BlockT>::Header>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.header(&id),
|
||||
Self::Westend(client) => client.header(&id),
|
||||
Self::Kusama(client) => client.header(&id),
|
||||
}
|
||||
}
|
||||
|
||||
fn info(&self) -> sp_blockchain::Info<Block> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.info(),
|
||||
Self::Westend(client) => client.info(),
|
||||
Self::Kusama(client) => client.info(),
|
||||
}
|
||||
}
|
||||
|
||||
fn status(&self, id: BlockId<Block>) -> sp_blockchain::Result<sp_blockchain::BlockStatus> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.status(id),
|
||||
Self::Westend(client) => client.status(id),
|
||||
Self::Kusama(client) => client.status(id),
|
||||
}
|
||||
}
|
||||
|
||||
fn number(
|
||||
&self,
|
||||
hash: <Block as BlockT>::Hash
|
||||
) -> sp_blockchain::Result<Option<NumberFor<Block>>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.number(hash),
|
||||
Self::Westend(client) => client.number(hash),
|
||||
Self::Kusama(client) => client.number(hash),
|
||||
}
|
||||
}
|
||||
|
||||
fn hash(&self, number: NumberFor<Block>) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.hash(number),
|
||||
Self::Westend(client) => client.hash(number),
|
||||
Self::Kusama(client) => client.hash(number),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+85
-40
@@ -243,6 +243,30 @@ pub fn new_partial<RuntimeApi, Executor>(config: &mut Configuration, test: bool)
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
pub struct NewFull<C> {
|
||||
pub task_manager: TaskManager,
|
||||
pub client: C,
|
||||
pub node_handles: FullNodeHandles,
|
||||
pub network: Arc<sc_network::NetworkService<Block, <Block as BlockT>::Hash>>,
|
||||
pub network_status_sinks: service::NetworkStatusSinks<Block>,
|
||||
pub rpc_handlers: RpcHandlers,
|
||||
}
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
impl<C> NewFull<C> {
|
||||
fn with_client(self, func: impl FnOnce(C) -> Client) -> NewFull<Client> {
|
||||
NewFull {
|
||||
client: func(self.client),
|
||||
task_manager: self.task_manager,
|
||||
node_handles: self.node_handles,
|
||||
network: self.network,
|
||||
network_status_sinks: self.network_status_sinks,
|
||||
rpc_handlers: self.rpc_handlers,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
pub fn new_full<RuntimeApi, Executor>(
|
||||
mut config: Configuration,
|
||||
@@ -250,13 +274,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
authority_discovery_enabled: bool,
|
||||
grandpa_pause: Option<(u32, u32)>,
|
||||
test: bool,
|
||||
) -> Result<(
|
||||
TaskManager,
|
||||
Arc<FullClient<RuntimeApi, Executor>>,
|
||||
FullNodeHandles,
|
||||
Arc<sc_network::NetworkService<Block, <Block as BlockT>::Hash>>,
|
||||
RpcHandlers,
|
||||
), Error>
|
||||
) -> Result<NewFull<Arc<FullClient<RuntimeApi, Executor>>>, Error>
|
||||
where
|
||||
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
|
||||
RuntimeApi::RuntimeApi:
|
||||
@@ -318,7 +336,8 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
telemetry_connection_sinks: telemetry_connection_sinks.clone(),
|
||||
network_status_sinks, system_rpc_tx,
|
||||
network_status_sinks: network_status_sinks.clone(),
|
||||
system_rpc_tx,
|
||||
})?;
|
||||
|
||||
let (block_import, link_half, babe_link) = import_setup;
|
||||
@@ -457,7 +476,45 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
|
||||
network_starter.start_network();
|
||||
|
||||
Ok((task_manager, client, FullNodeHandles, network, rpc_handlers))
|
||||
Ok(NewFull {
|
||||
task_manager, client, node_handles: FullNodeHandles, network, network_status_sinks,
|
||||
rpc_handlers,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
pub fn new_full_nongeneric(
|
||||
config: Configuration,
|
||||
collating_for: Option<(CollatorId, parachain::Id)>,
|
||||
authority_discovery_enabled: bool,
|
||||
grandpa_pause: Option<(u32, u32)>,
|
||||
test: bool,
|
||||
) -> Result<NewFull<Client>, Error> {
|
||||
if config.chain_spec.is_kusama() {
|
||||
new_full::<kusama_runtime::RuntimeApi, KusamaExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
test,
|
||||
).map(|full| full.with_client(Client::Kusama))
|
||||
} else if config.chain_spec.is_westend() {
|
||||
new_full::<westend_runtime::RuntimeApi, WestendExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
false,
|
||||
).map(|full| full.with_client(Client::Westend))
|
||||
} else {
|
||||
new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
false,
|
||||
).map(|full| full.with_client(Client::Polkadot))
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a new service for a light client.
|
||||
@@ -607,7 +664,9 @@ pub fn polkadot_new_full(
|
||||
FullNodeHandles,
|
||||
), ServiceError>
|
||||
{
|
||||
let (service, client, handles, _, _) = new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(
|
||||
let NewFull {
|
||||
task_manager, client, node_handles, ..
|
||||
} = new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
@@ -615,7 +674,7 @@ pub fn polkadot_new_full(
|
||||
false,
|
||||
)?;
|
||||
|
||||
Ok((service, client, handles))
|
||||
Ok((task_manager, client, node_handles))
|
||||
}
|
||||
|
||||
/// Create a new Kusama service for a full node.
|
||||
@@ -631,7 +690,9 @@ pub fn kusama_new_full(
|
||||
FullNodeHandles
|
||||
), ServiceError>
|
||||
{
|
||||
let (service, client, handles, _, _) = new_full::<kusama_runtime::RuntimeApi, KusamaExecutor>(
|
||||
let NewFull {
|
||||
task_manager, client, node_handles, ..
|
||||
} = new_full::<kusama_runtime::RuntimeApi, KusamaExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
@@ -639,7 +700,7 @@ pub fn kusama_new_full(
|
||||
false,
|
||||
)?;
|
||||
|
||||
Ok((service, client, handles))
|
||||
Ok((task_manager, client, node_handles))
|
||||
}
|
||||
|
||||
/// Create a new Westend service for a full node.
|
||||
@@ -656,7 +717,9 @@ pub fn westend_new_full(
|
||||
FullNodeHandles,
|
||||
), ServiceError>
|
||||
{
|
||||
let (service, client, handles, _, _) = new_full::<westend_runtime::RuntimeApi, WestendExecutor>(
|
||||
let NewFull {
|
||||
task_manager, client, node_handles, ..
|
||||
} = new_full::<westend_runtime::RuntimeApi, WestendExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
@@ -664,7 +727,7 @@ pub fn westend_new_full(
|
||||
false,
|
||||
)?;
|
||||
|
||||
Ok((service, client, handles))
|
||||
Ok((task_manager, client, node_handles))
|
||||
}
|
||||
|
||||
/// Handles to other sub-services that full nodes instantiate, which consumers
|
||||
@@ -692,29 +755,11 @@ pub fn build_full(
|
||||
authority_discovery_enabled: bool,
|
||||
grandpa_pause: Option<(u32, u32)>,
|
||||
) -> Result<(TaskManager, Client, FullNodeHandles), ServiceError> {
|
||||
if config.chain_spec.is_kusama() {
|
||||
new_full::<kusama_runtime::RuntimeApi, KusamaExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
false,
|
||||
).map(|(task_manager, client, handles, _, _)| (task_manager, Client::Kusama(client), handles))
|
||||
} else if config.chain_spec.is_westend() {
|
||||
new_full::<westend_runtime::RuntimeApi, WestendExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
false,
|
||||
).map(|(task_manager, client, handles, _, _)| (task_manager, Client::Westend(client), handles))
|
||||
} else {
|
||||
new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
false,
|
||||
).map(|(task_manager, client, handles, _, _)| (task_manager, Client::Polkadot(client), handles))
|
||||
}
|
||||
new_full_nongeneric(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
false,
|
||||
).map(|NewFull { task_manager, client, node_handles, .. }| (task_manager, client, node_handles))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user