mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
Add a build-sync-spec subcommand and remove the CHT roots from the light sync state. (#6999)
* Move subcommands from sc-cli to nodes * Add --build-sync-spec subcommand * Remove CHTs from snapshots * Keep ProvideChtRoots
This commit is contained in:
@@ -380,7 +380,7 @@ pub fn local_testnet_config() -> ChainSpec {
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::service::{new_full_base, new_light_base};
|
||||
use crate::service::{new_full_base, new_light_base, NewFullBase};
|
||||
use sc_service_test;
|
||||
use sp_runtime::BuildStorage;
|
||||
|
||||
@@ -431,8 +431,9 @@ pub(crate) mod tests {
|
||||
sc_service_test::connectivity(
|
||||
integration_test_config_with_two_authorities(),
|
||||
|config| {
|
||||
let (keep_alive, _, client, network, transaction_pool) = new_full_base(config,|_, _| ())?;
|
||||
Ok(sc_service_test::TestNetComponents::new(keep_alive, client, network, transaction_pool))
|
||||
let NewFullBase { task_manager, client, network, transaction_pool, .. }
|
||||
= new_full_base(config,|_, _| ())?;
|
||||
Ok(sc_service_test::TestNetComponents::new(task_manager, client, network, transaction_pool))
|
||||
},
|
||||
|config| {
|
||||
let (keep_alive, _, client, network, transaction_pool) = new_light_base(config)?;
|
||||
|
||||
@@ -59,6 +59,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,7 +21,7 @@ use node_executor::Executor;
|
||||
use node_runtime::{Block, RuntimeApi};
|
||||
use sc_cli::{Result, SubstrateCli, RuntimeVersion, Role, ChainSpec};
|
||||
use sc_service::PartialComponents;
|
||||
use crate::service::new_partial;
|
||||
use crate::service::{new_partial, new_full_base, NewFullBase};
|
||||
|
||||
impl SubstrateCli for Cli {
|
||||
fn impl_name() -> String {
|
||||
@@ -101,6 +101,17 @@ 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)?;
|
||||
runner.async_run(|config| {
|
||||
let chain_spec = config.chain_spec.cloned_box();
|
||||
let network_config = config.network.clone();
|
||||
let NewFullBase { task_manager, client, network_status_sinks, .. }
|
||||
= new_full_base(config, |_, _| ())?;
|
||||
|
||||
Ok((cmd.run(chain_spec, network_config, client, network_status_sinks), task_manager))
|
||||
})
|
||||
},
|
||||
Some(Subcommand::CheckBlock(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
|
||||
@@ -151,6 +151,15 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
||||
})
|
||||
}
|
||||
|
||||
pub struct NewFullBase {
|
||||
pub task_manager: TaskManager,
|
||||
pub inherent_data_providers: InherentDataProviders,
|
||||
pub client: Arc<FullClient>,
|
||||
pub network: Arc<NetworkService<Block, <Block as BlockT>::Hash>>,
|
||||
pub network_status_sinks: sc_service::NetworkStatusSinks<Block>,
|
||||
pub transaction_pool: Arc<sc_transaction_pool::FullPool<Block, FullClient>>,
|
||||
}
|
||||
|
||||
/// Creates a full service from the configuration.
|
||||
pub fn new_full_base(
|
||||
config: Configuration,
|
||||
@@ -158,11 +167,7 @@ pub fn new_full_base(
|
||||
&sc_consensus_babe::BabeBlockImport<Block, FullClient, FullGrandpaBlockImport>,
|
||||
&sc_consensus_babe::BabeLink<Block>,
|
||||
)
|
||||
) -> Result<(
|
||||
TaskManager, InherentDataProviders, Arc<FullClient>,
|
||||
Arc<NetworkService<Block, <Block as BlockT>::Hash>>,
|
||||
Arc<sc_transaction_pool::FullPool<Block, FullClient>>,
|
||||
), ServiceError> {
|
||||
) -> Result<NewFullBase, ServiceError> {
|
||||
let sc_service::PartialComponents {
|
||||
client, backend, mut task_manager, import_queue, keystore, select_chain, transaction_pool,
|
||||
inherent_data_providers,
|
||||
@@ -210,7 +215,7 @@ pub fn new_full_base(
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
telemetry_connection_sinks: telemetry_connection_sinks.clone(),
|
||||
network_status_sinks,
|
||||
network_status_sinks: network_status_sinks.clone(),
|
||||
system_rpc_tx,
|
||||
})?;
|
||||
|
||||
@@ -330,13 +335,16 @@ pub fn new_full_base(
|
||||
}
|
||||
|
||||
network_starter.start_network();
|
||||
Ok((task_manager, inherent_data_providers, client, network, transaction_pool))
|
||||
Ok(NewFullBase {
|
||||
task_manager, inherent_data_providers, client, network, network_status_sinks,
|
||||
transaction_pool,
|
||||
})
|
||||
}
|
||||
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full(config: Configuration)
|
||||
-> Result<TaskManager, ServiceError> {
|
||||
new_full_base(config, |_, _| ()).map(|(task_manager, _, _, _, _)| {
|
||||
new_full_base(config, |_, _| ()).map(|NewFullBase { task_manager, .. }| {
|
||||
task_manager
|
||||
})
|
||||
}
|
||||
@@ -467,7 +475,7 @@ mod tests {
|
||||
use sp_finality_tracker;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use sc_service_test::TestNetNode;
|
||||
use crate::service::{new_full_base, new_light_base};
|
||||
use crate::service::{new_full_base, new_light_base, NewFullBase};
|
||||
use sp_runtime::traits::IdentifyAccount;
|
||||
use sp_transaction_pool::{MaintainedTransactionPool, ChainEvent};
|
||||
use sc_client_api::BlockBackend;
|
||||
@@ -499,18 +507,19 @@ mod tests {
|
||||
chain_spec,
|
||||
|config| {
|
||||
let mut setup_handles = None;
|
||||
let (keep_alive, inherent_data_providers, client, network, transaction_pool) =
|
||||
new_full_base(config,
|
||||
|
|
||||
block_import: &sc_consensus_babe::BabeBlockImport<Block, _, _>,
|
||||
babe_link: &sc_consensus_babe::BabeLink<Block>,
|
||||
| {
|
||||
setup_handles = Some((block_import.clone(), babe_link.clone()));
|
||||
}
|
||||
)?;
|
||||
let NewFullBase {
|
||||
task_manager, inherent_data_providers, client, network, transaction_pool, ..
|
||||
} = new_full_base(config,
|
||||
|
|
||||
block_import: &sc_consensus_babe::BabeBlockImport<Block, _, _>,
|
||||
babe_link: &sc_consensus_babe::BabeLink<Block>,
|
||||
| {
|
||||
setup_handles = Some((block_import.clone(), babe_link.clone()));
|
||||
}
|
||||
)?;
|
||||
|
||||
let node = sc_service_test::TestNetComponents::new(
|
||||
keep_alive, client, network, transaction_pool
|
||||
task_manager, client, network, transaction_pool
|
||||
);
|
||||
Ok((node, (inherent_data_providers, setup_handles.unwrap())))
|
||||
},
|
||||
@@ -661,8 +670,9 @@ mod tests {
|
||||
sc_service_test::consensus(
|
||||
crate::chain_spec::tests::integration_test_config_with_two_authorities(),
|
||||
|config| {
|
||||
let (keep_alive, _, client, network, transaction_pool) = new_full_base(config, |_, _| ())?;
|
||||
Ok(sc_service_test::TestNetComponents::new(keep_alive, client, network, transaction_pool))
|
||||
let NewFullBase { task_manager, client, network, transaction_pool, .. }
|
||||
= new_full_base(config,|_, _| ())?;
|
||||
Ok(sc_service_test::TestNetComponents::new(task_manager, client, network, transaction_pool))
|
||||
},
|
||||
|config| {
|
||||
let (keep_alive, _, client, network, transaction_pool) = new_light_base(config)?;
|
||||
|
||||
Reference in New Issue
Block a user