Skip to content

Commit

Permalink
Upgrade substrate dependency to match 0.9.24 (#40)
Browse files Browse the repository at this point in the history
* Upgrade substrate dependency to match 0.9.24
  • Loading branch information
sudipghimire533 authored Jul 28, 2022
1 parent 5a62a8c commit 781ebe7
Show file tree
Hide file tree
Showing 25 changed files with 2,075 additions and 2,031 deletions.
3,397 changes: 1,698 additions & 1,699 deletions Cargo.lock

Large diffs are not rendered by default.

114 changes: 58 additions & 56 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'datahighway-collator'
version = '3.6.0'
version = '3.6.1'
authors = ['Anonymous']
description = 'DataHighway parachain collator FRAME-based Substrate Node based upon the Cumulus.'
license = 'Unlicense'
Expand All @@ -15,7 +15,7 @@ path = 'src/main.rs'

[dependencies]
derive_more = '0.99.2'
log = '0.4.14'
log = '0.4.17'
codec = { version = '3.1.2', package = 'parity-scale-codec', default-features = false, features = ['derive', 'max-encoded-len'] }
clap = { version = '3.1.6', features = ['derive'] }
serde = { version = '1.0.136', features = ['derive'] }
Expand All @@ -24,78 +24,80 @@ hex = { version = '0.4.3', default_features = false, features = ['alloc'] }
hex-literal = '0.3.4'

jsonrpc-core = '18.0.0'
jsonrpsee = { version = "0.13.0", features = ["server"] }

# Local
datahighway-parachain-runtime = { path = '../runtime', version = '3.6.0' }
module-primitives = { version = '3.0.6', default-features = false, path = '../pallets/primitives' }

# Substrate
frame-benchmarking = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
frame-benchmarking-cli = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
frame-try-runtime = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18', optional = true }
frame-benchmarking = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
frame-benchmarking-cli = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
frame-try-runtime = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', optional = true }

pallet-transaction-payment-rpc = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
pallet-transaction-payment-rpc = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }

## Substrate Client Dependencies
sc-basic-authorship = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-chain-spec = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-cli = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18', features = ['wasmtime'] }
sc-client-api = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-consensus = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-executor = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18', features = ['wasmtime'] }
sc-keystore = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-network = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-rpc = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-rpc-api = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-service = { git = 'https://github.com/paritytech/substrate', features = ['wasmtime'], branch = 'polkadot-v0.9.18' }
sc-telemetry = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-tracing = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-transaction-pool = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sc-transaction-pool-api = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-authorship = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-api = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-block-builder = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-blockchain = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-consensus = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-consensus-aura = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-core = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-inherents = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-keystore = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-offchain = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-runtime = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-session = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-timestamp = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-tracing = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
sp-transaction-pool = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
substrate-frame-rpc-system = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
substrate-prometheus-endpoint = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
try-runtime-cli = { git = 'https://github.com/paritytech/substrate', optional = true, branch = 'polkadot-v0.9.18' }
sc-basic-authorship = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-chain-spec = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-cli = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', features = ['wasmtime'] }
sc-client-api = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-consensus = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-executor = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', features = ['wasmtime'] }
sc-keystore = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-network = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-rpc = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-rpc-api = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-service = { git = 'https://github.com/paritytech/substrate', features = ['wasmtime'], branch = 'polkadot-v0.9.24' }
sc-telemetry = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-tracing = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-transaction-pool = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-transaction-pool-api = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sc-sysinfo = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-authorship = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-api = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-block-builder = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-blockchain = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-consensus = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-consensus-aura = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-core = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-inherents = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-keystore = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-offchain = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-runtime = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-session = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-timestamp = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-tracing = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
sp-transaction-pool = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
substrate-frame-rpc-system = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
substrate-prometheus-endpoint = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }
try-runtime-cli = { git = 'https://github.com/paritytech/substrate', optional = true, branch = 'polkadot-v0.9.24' }

# Polkadot
polkadot-cli = { git = 'https://github.com/paritytech/polkadot', branch = 'release-v0.9.18' }
polkadot-parachain = { git = 'https://github.com/paritytech/polkadot', branch = 'release-v0.9.18' }
polkadot-primitives = { git = 'https://github.com/paritytech/polkadot', branch = 'release-v0.9.18' }
polkadot-service = { git = 'https://github.com/paritytech/polkadot', branch = 'release-v0.9.18' }
xcm = { git = 'https://github.com/paritytech/polkadot', default-features = false, branch = 'release-v0.9.18' }
polkadot-cli = { git = 'https://github.com/paritytech/polkadot', branch = 'release-v0.9.24' }
polkadot-parachain = { git = 'https://github.com/paritytech/polkadot', branch = 'release-v0.9.24' }
polkadot-primitives = { git = 'https://github.com/paritytech/polkadot', branch = 'release-v0.9.24' }
polkadot-service = { git = 'https://github.com/paritytech/polkadot', branch = 'release-v0.9.24' }
xcm = { git = 'https://github.com/paritytech/polkadot', default-features = false, branch = 'release-v0.9.24' }

# Cumulus
cumulus-client-cli = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-client-collator = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-client-consensus-aura = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-client-consensus-common = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-client-network = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-client-service = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-primitives-core = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-primitives-parachain-inherent = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-relay-chain-inprocess-interface = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-relay-chain-interface = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-relay-chain-rpc-interface = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.18' }
cumulus-client-cli = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }
cumulus-client-collator = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }
cumulus-client-consensus-aura = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }
cumulus-client-consensus-common = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }
cumulus-client-network = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }
cumulus-client-service = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }
cumulus-primitives-core = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }
cumulus-primitives-parachain-inherent = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }
cumulus-relay-chain-inprocess-interface = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }
cumulus-relay-chain-interface = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }
cumulus-relay-chain-rpc-interface = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.24' }

[dev-dependencies]
futures = { version = '0.3.19' }

[build-dependencies]
substrate-build-script-utils = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.18' }
substrate-build-script-utils = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24' }

[features]
default = []
Expand Down
19 changes: 13 additions & 6 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ pub enum Subcommand {
/// Revert the chain to a previous state.
Revert(sc_cli::RevertCmd),

/// The custom benchmark subcommmand benchmarking runtime pallets.
#[clap(name = "benchmark", about = "Benchmark runtime pallets.")]
/// Sub-commands concerned with benchmarking.
/// The pallet benchmarking moved to the `pallet` sub-command.
#[clap(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),

/// Sub command for benchmarking the storage speed.
#[clap(name = "benchmark-storage", about = "Benchmark storage speed.")]
BenchmarkStorage(frame_benchmarking_cli::StorageCmd),

/// Try some command against runtime state.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd),
Expand Down Expand Up @@ -101,6 +98,16 @@ pub struct Cli {
#[clap(flatten)]
pub run: cumulus_client_cli::RunCmd,

/// Disable automatic hardware benchmarks.
///
/// By default these benchmarks are automatically ran at startup and measure
/// the CPU speed, the memory bandwidth and the disk speed.
///
/// The results are then printed out in the logs, and also sent as part of
/// telemetry, if telemetry is enabled.
#[clap(long)]
pub no_hardware_benchmarks: bool,

/// Relay chain arguments
#[clap(raw = true, conflicts_with = "relay-chain-rpc-url")]
pub relay_chain_args: Vec<String>,
Expand Down
78 changes: 47 additions & 31 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ use cumulus_client_service::genesis::generate_genesis_block;
use cumulus_primitives_core::ParaId;
use log::info;
use datahighway_parachain_runtime::{AuraId, Block, RuntimeApi};
use polkadot_parachain::primitives::AccountIdConversion;
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
};
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use sc_service::{
config::{BasePath, PrometheusConfig},
PartialComponents,
TaskManager,
};
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::Block as BlockT;
use sp_runtime::traits::{Block as BlockT, AccountIdConversion};
use std::{io::Write, net::SocketAddr};

fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
Expand Down Expand Up @@ -195,7 +195,7 @@ pub fn run() -> Result<()> {
}
Some(Subcommand::Revert(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.backend))
Ok(cmd.run(components.client, components.backend, None))
})
},
Some(Subcommand::ExportGenesisState(params)) => {
Expand Down Expand Up @@ -241,35 +241,41 @@ pub fn run() -> Result<()> {

Ok(())
}
Some(Subcommand::Benchmark(cmd)) =>
if cfg!(feature = "runtime-benchmarks") {
let runner = cli.create_runner(cmd)?;
Some(Subcommand::Benchmark(cmd)) => {
let runner = cli.create_runner(cmd)?;

runner.sync_run(|config| cmd.run::<Block, DataHighwayParachainRuntimeExecutor>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
},
Some(Subcommand::BenchmarkStorage(cmd)) => {
if !cfg!(feature = "runtime-benchmarks") {
return Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
match cmd {
BenchmarkCmd::Pallet(cmd) =>
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| cmd.run::<Block, DataHighwayParachainRuntimeExecutor>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
},
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
let partials = new_partial::<RuntimeApi, DataHighwayParachainRuntimeExecutor, _>(
&config,
crate::service::parachain_build_import_queue,
)?;
cmd.run(partials.client)
}),
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
let partials = new_partial(&config, crate::service::parachain_build_import_queue)?;
let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();

cmd.run(config, partials.client, db, storage)
}),
BenchmarkCmd::Overhead(_) => Err("Unsupported benchmarking command".into()),
BenchmarkCmd::Machine(cmd) =>
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())),
}
}

let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, backend, .. } = new_partial(
&config,
crate::service::parachain_build_import_queue,
)?;
let db = backend.expose_db();
let storage = backend.expose_storage();

Ok((cmd.run(config, client, db, storage), task_manager))
})
},
// TODO: move to if cfg!() syntax
// cfg! syntax is preferred in `substrate-parachain-template`
// keeping compatible will make is easy to upgrade in future
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
let runner = cli.create_runner(cmd)?;
Expand All @@ -292,6 +298,15 @@ pub fn run() -> Result<()> {
let collator_options = cli.run.collator_options();

runner.run_node_until_exit(|config| async move {
let hwbench = if !cli.no_hardware_benchmarks {
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(&database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
})
} else {
None
};

let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
.ok_or_else(|| "Could not find parachain ID in chain-spec.")?;
Expand All @@ -304,7 +319,7 @@ pub fn run() -> Result<()> {
let id = ParaId::from(para_id);

let parachain_account =
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
AccountIdConversion::<polkadot_primitives::v2::AccountId>::into_account_truncating(&id);

let state_version =
RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
Expand All @@ -326,7 +341,8 @@ pub fn run() -> Result<()> {
config,
polkadot_config,
collator_options,
id
id,
hwbench,
)
.await
.map(|r| r.0)
Expand Down
Loading

0 comments on commit 781ebe7

Please sign in to comment.