Skip to content

Commit

Permalink
Dependency update to Polkadot v1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NZT48 committed Jul 19, 2024
1 parent 29994fc commit eac54b0
Show file tree
Hide file tree
Showing 11 changed files with 1,827 additions and 1,544 deletions.
2,761 changes: 1,508 additions & 1,253 deletions Cargo.lock

Large diffs are not rendered by default.

227 changes: 115 additions & 112 deletions Cargo.toml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ try-runtime-cli = { workspace = true }
# Polkadot
polkadot-cli = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-service = { workspace = true }
xcm = { workspace = true }

# Cumulus
cumulus-client-cli = { workspace = true }
cumulus-client-consensus-aura = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-consensus-proposer = { workspace = true }
cumulus-client-collator = { workspace = true }
cumulus-client-service = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
Expand Down
10 changes: 9 additions & 1 deletion node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum Subcommand {
PurgeChain(cumulus_client_cli::PurgeChainCmd),

/// Export the genesis state of the parachain.
ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand),
ExportGenesisState(cumulus_client_cli::ExportGenesisHeadCommand),

/// Export the genesis wasm of the parachain.
ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),
Expand Down Expand Up @@ -70,6 +70,14 @@ pub struct Cli {
/// Relay chain arguments
#[arg(raw = true)]
pub relay_chain_args: Vec<String>,

/// Proposer's maximum block size limit in bytes
#[clap(long, default_value = sc_basic_authorship::DEFAULT_BLOCK_SIZE_LIMIT.to_string())]
pub proposer_block_size_limit: usize,

/// Proposer's soft deadline in percents of block size
#[clap(long, default_value = "50")]
pub proposer_soft_deadline_percent: u8,
}

#[derive(Debug)]
Expand Down
60 changes: 22 additions & 38 deletions node/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use std::{io::Write, net::SocketAddr};
use codec::Encode;
use cumulus_client_cli::generate_genesis_block;
use std::net::SocketAddr;
use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use log::{info};
use neuroweb_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 sc_service::{PartialComponents, config::{BasePath, PrometheusConfig}};
use sp_runtime::traits::AccountIdConversion;
use crate::{
chain_spec,
cli::{Cli, RelayChainCli, Subcommand},
service::{new_partial},
service::{new_partial, AdditionalConfig},
};

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Expand Down Expand Up @@ -65,13 +62,6 @@ impl SubstrateCli for Cli {
}
}


impl Cli {
fn runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
&neuroweb_runtime::VERSION
}
}

impl SubstrateCli for RelayChainCli {
fn impl_name() -> String {
"NeuroWeb".into()
Expand Down Expand Up @@ -174,22 +164,14 @@ pub fn run() -> Result<()> {
})
},
Some(Subcommand::ExportGenesisState(cmd)) => {
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
let state_version = Cli::runtime_version(&spec).state_version();

let block: Block = generate_genesis_block(&*spec, state_version)?;
let raw_header = block.header().encode();
let output_buf = if cmd.raw {
raw_header
} else {
format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()
};
if let Some(output) = &cmd.output {
std::fs::write(output, output_buf)?;
} else {
std::io::stdout().write_all(&output_buf)?;
}
Ok(())
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
let PartialComponents { client, .. } =
new_partial(
&config,
)?;
cmd.run(client)
})
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
let runner = cli.create_runner(cmd)?;
Expand All @@ -200,11 +182,13 @@ pub fn run() -> Result<()> {
},
Some(Subcommand::Benchmark(cmd)) => {
let runner = cli.create_runner(cmd)?;
use sp_runtime::traits::HashingFor;

// Switch on the concrete benchmark sub-command-
match cmd {
BenchmarkCmd::Pallet(cmd) => {
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| cmd.run::<Block, ()>(config))
runner.sync_run(|config| cmd.run::<HashingFor<Block>, ()>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
Expand Down Expand Up @@ -273,19 +257,13 @@ pub fn run() -> Result<()> {
let parachain_account =
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(&id);

let state_version = Cli::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()));

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!(
"Is collating: {}",
if config.role.is_authority() {
Expand All @@ -295,12 +273,18 @@ pub fn run() -> Result<()> {
}
);

let additional_config = AdditionalConfig {
proposer_block_size_limit: cli.proposer_block_size_limit,
proposer_soft_deadline_percent: cli.proposer_soft_deadline_percent
};

crate::service::start_parachain_node(
config,
polkadot_config,
collator_options,
id,
hwbench,
additional_config
)
.await
.map(|r| r.0)
Expand Down
Loading

0 comments on commit eac54b0

Please sign in to comment.