mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
Companion for Substrate#14511 (#2821)
* Companion for Substrate#14511 https://github.com/paritytech/substrate/pull/14511 * update lockfile for {"substrate", "polkadot"} --------- Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use codec::Encode;
|
||||
use cumulus_client_cli::generate_genesis_block;
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
|
||||
use log::{info, warn};
|
||||
use parachain_template_runtime::Block;
|
||||
use sc_cli::{
|
||||
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
|
||||
NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
|
||||
NetworkParams, Result, SharedParams, SubstrateCli,
|
||||
};
|
||||
use sc_service::config::{BasePath, PrometheusConfig};
|
||||
use sp_core::hexdisplay::HexDisplay;
|
||||
use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
|
||||
use crate::{
|
||||
chain_spec,
|
||||
@@ -63,10 +60,6 @@ impl SubstrateCli for Cli {
|
||||
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
load_spec(id)
|
||||
}
|
||||
|
||||
fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
||||
¶chain_template_runtime::VERSION
|
||||
}
|
||||
}
|
||||
|
||||
impl SubstrateCli for RelayChainCli {
|
||||
@@ -103,10 +96,6 @@ impl SubstrateCli for RelayChainCli {
|
||||
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
|
||||
}
|
||||
|
||||
fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
||||
polkadot_cli::Cli::native_runtime_version(chain_spec)
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! construct_async_run {
|
||||
@@ -175,10 +164,10 @@ pub fn run() -> Result<()> {
|
||||
},
|
||||
Some(Subcommand::ExportGenesisState(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|_config| {
|
||||
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
|
||||
let state_version = Cli::native_runtime_version(&spec).state_version();
|
||||
cmd.run::<Block>(&*spec, state_version)
|
||||
runner.sync_run(|config| {
|
||||
let partials = new_partial(&config)?;
|
||||
|
||||
cmd.run(&*config.chain_spec, &*partials.client)
|
||||
})
|
||||
},
|
||||
Some(Subcommand::ExportGenesisWasm(cmd)) => {
|
||||
@@ -258,11 +247,12 @@ pub fn run() -> Result<()> {
|
||||
let collator_options = cli.run.collator_options();
|
||||
|
||||
runner.run_node_until_exit(|config| async move {
|
||||
let hwbench = (!cli.no_hardware_benchmarks).then_some(
|
||||
config.database.path().map(|database_path| {
|
||||
let hwbench = (!cli.no_hardware_benchmarks)
|
||||
.then_some(config.database.path().map(|database_path| {
|
||||
let _ = std::fs::create_dir_all(database_path);
|
||||
sc_sysinfo::gather_hwbench(Some(database_path))
|
||||
})).flatten();
|
||||
}))
|
||||
.flatten();
|
||||
|
||||
let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
|
||||
.map(|e| e.para_id)
|
||||
@@ -276,25 +266,26 @@ pub fn run() -> Result<()> {
|
||||
let id = ParaId::from(para_id);
|
||||
|
||||
let parachain_account =
|
||||
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(&id);
|
||||
|
||||
let state_version = Cli::native_runtime_version(&config.chain_spec).state_version();
|
||||
let block: Block = generate_genesis_block(&*config.chain_spec, state_version)
|
||||
.map_err(|e| format!("{:?}", e))?;
|
||||
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
||||
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(
|
||||
&id,
|
||||
);
|
||||
|
||||
let tokio_handle = config.tokio_handle.clone();
|
||||
let polkadot_config =
|
||||
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle)
|
||||
.map_err(|err| format!("Relay chain argument error: {}", err))?;
|
||||
|
||||
info!("Parachain id: {:?}", id);
|
||||
info!("Parachain Account: {}", parachain_account);
|
||||
info!("Parachain genesis state: {}", genesis_state);
|
||||
info!("Parachain Account: {parachain_account}");
|
||||
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
|
||||
|
||||
if !collator_options.relay_chain_rpc_urls.is_empty() && !cli.relay_chain_args.is_empty() {
|
||||
warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options.");
|
||||
if !collator_options.relay_chain_rpc_urls.is_empty() &&
|
||||
!cli.relay_chain_args.is_empty()
|
||||
{
|
||||
warn!(
|
||||
"Detected relay chain node arguments together with --relay-chain-rpc-url. \
|
||||
This command starts a minimal Polkadot node that only uses a \
|
||||
network-related subset of all relay chain CLI options."
|
||||
);
|
||||
}
|
||||
|
||||
crate::service::start_parachain_node(
|
||||
|
||||
Reference in New Issue
Block a user