From 9f81da13a87784f4b2837f17ebb812f6a59b920d Mon Sep 17 00:00:00 2001 From: David Palm Date: Wed, 23 Sep 2020 15:18:19 +0200 Subject: [PATCH 1/8] Upgrade to substrate 2.0.0 --- Cargo.toml | 40 ++++++++++++++--------------- client/Cargo.toml | 10 ++++---- proc-macro/Cargo.toml | 6 ++--- src/frame/contracts.rs | 1 + src/frame/staking.rs | 4 +-- src/metadata.rs | 2 +- test-node/Cargo.toml | 38 +++++++++++++-------------- test-node/runtime/Cargo.toml | 50 ++++++++++++++++++------------------ test-node/runtime/src/lib.rs | 8 +++--- 9 files changed, 80 insertions(+), 79 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7eda6d6a98..7a88fcd158 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,33 +34,33 @@ serde_json = "1.0.57" url = "2.1.1" codec = { package = "parity-scale-codec", version = "1.3.5", default-features = false, features = ["derive", "full"] } -frame-metadata = { version = "11.0.0-rc6", package = "frame-metadata" } -frame-support = { version = "2.0.0-rc6", package = "frame-support" } -sp-runtime = { version = "2.0.0-rc6", package = "sp-runtime" } -sp-version = { version = "2.0.0-rc6", package = "sp-version" } -pallet-indices = { version = "2.0.0-rc6", package = "pallet-indices" } +frame-metadata = { version = "12", package = "frame-metadata" } +frame-support = { version = "2.0.0", package = "frame-support" } +sp-runtime = { version = "2.0.0", package = "sp-runtime" } +sp-version = { version = "2.0.0", package = "sp-version" } +pallet-indices = { version = "2.0.0", package = "pallet-indices" } hex = "0.4.2" -sp-std = "2.0.0-rc6" -application-crypto = { version = "2.0.0-rc6", package = "sp-application-crypto" } -sp-finality-grandpa = "2.0.0-rc6" -sp-consensus-babe = "0.8.0-rc6" -pallet-im-online = "2.0.0-rc6" -sp-authority-discovery = "2.0.0-rc6" -pallet-staking = "2.0.0-rc6" +sp-std = "2.0.0" +application-crypto = { version = "2.0.0", package = "sp-application-crypto" } +sp-finality-grandpa = "2.0.0" +sp-consensus-babe = "0.8.0" +pallet-im-online = "2.0.0" +sp-authority-discovery = "2.0.0" +pallet-staking = "2.0.0" -sp-rpc = { version = "2.0.0-rc6", package = "sp-rpc" } -sp-core = { version = "2.0.0-rc6", package = "sp-core" } -sc-rpc-api = { version = "0.8.0-rc6", package = "sc-rpc-api" } -sp-transaction-pool = { version = "2.0.0-rc6", package = "sp-transaction-pool" } +sp-rpc = { version = "2.0.0", package = "sp-rpc" } +sp-core = { version = "2.0.0", package = "sp-core" } +sc-rpc-api = { version = "0.8.0", package = "sc-rpc-api" } +sp-transaction-pool = { version = "2.0.0", package = "sp-transaction-pool" } substrate-subxt-client = { version = "0.4.0", path = "client", optional = true } substrate-subxt-proc-macro = { version = "0.12.0", path = "proc-macro" } [dev-dependencies] -async-std = { version = "1.6.3", features = ["attributes"] } +async-std = { version = "1.6.4", features = ["attributes"] } env_logger = "0.7.1" -frame-system = { version = "2.0.0-rc6", package = "frame-system" } -pallet-balances = { version = "2.0.0-rc6", package = "pallet-balances" } -sp-keyring = { version = "2.0.0-rc6", package = "sp-keyring" } +frame-system = { version = "2.0.0", package = "frame-system" } +pallet-balances = { version = "2.0.0", package = "pallet-balances" } +sp-keyring = { version = "2.0.0", package = "sp-keyring" } substrate-subxt-client = { version = "0.4.0", path = "client" } tempdir = "0.3.7" test-node = { path = "test-node" } diff --git a/client/Cargo.toml b/client/Cargo.toml index f8fe327f73..57d3b91449 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -12,19 +12,19 @@ description = "Embed a substrate node into your subxt application." keywords = ["parity", "substrate", "blockchain"] [dependencies] -async-std = "1.6.3" +async-std = "1.6.4" futures = { version = "0.3.5", features = ["compat"] } futures01 = { package = "futures", version = "0.1.29" } jsonrpsee = "0.1.0" log = "0.4.11" -sc-network = { version = "0.8.0-rc6", default-features = false } -sc-service = { version = "0.8.0-rc6", default-features = false } +sc-network = { version = "0.8.0", default-features = false } +sc-service = { version = "0.8.0", default-features = false } serde_json = "1.0.57" -sp-keyring = "2.0.0-rc6" +sp-keyring = "2.0.0" thiserror = "1.0.20" [dev-dependencies] -async-std = { version = "1.6.3", features = ["attributes"] } +async-std = { version = "1.6.4", features = ["attributes"] } env_logger = "0.7.1" substrate-subxt = { path = ".." } tempdir = "0.3.7" diff --git a/proc-macro/Cargo.toml b/proc-macro/Cargo.toml index 47072b398b..2df506500a 100644 --- a/proc-macro/Cargo.toml +++ b/proc-macro/Cargo.toml @@ -24,11 +24,11 @@ syn = "1.0.38" synstructure = "0.12.4" [dev-dependencies] -async-std = { version = "1.6.3", features = ["attributes"] } -codec = { package = "parity-scale-codec", version = "1.3.4", features = ["derive"] } +async-std = { version = "1.6.4", features = ["attributes"] } +codec = { package = "parity-scale-codec", version = "1.3.5", features = ["derive"] } env_logger = "0.7.1" pretty_assertions = "0.6.1" -sp-keyring = "2.0.0-rc6" +sp-keyring = "2.0.0" substrate-subxt = { path = ".." } trybuild = "1.0.32" diff --git a/src/frame/contracts.rs b/src/frame/contracts.rs index a3cfd149ed..1941918dd9 100644 --- a/src/frame/contracts.rs +++ b/src/frame/contracts.rs @@ -116,6 +116,7 @@ pub struct InstantiatedEvent { } #[cfg(test)] +#[cfg(feature = "integration-tests")] mod tests { use sp_keyring::AccountKeyring; diff --git a/src/frame/staking.rs b/src/frame/staking.rs index 522473accb..06aa598143 100644 --- a/src/frame/staking.rs +++ b/src/frame/staking.rs @@ -57,7 +57,7 @@ pub struct ErasRewardPointsStore { #[derive(Clone, Encode, Decode, Debug, Call)] pub struct SetPayeeCall { /// The payee - pub payee: RewardDestination, + pub payee: RewardDestination, /// Marker for the runtime pub _runtime: PhantomData, } @@ -99,7 +99,7 @@ pub struct LedgerStore { /// Where the reward payment should be made. Keyed by stash. #[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)] pub struct PayeeStore { - #[store(returns = RewardDestination)] + #[store(returns = RewardDestination)] /// TŮ—he stash account pub stash: T::AccountId, } diff --git a/src/metadata.rs b/src/metadata.rs index e528400c22..deae0778b4 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -482,7 +482,7 @@ impl TryFrom for Metadata { return Err(ConversionError::InvalidPrefix.into()) } let meta = match metadata.1 { - RuntimeMetadata::V11(meta) => meta, + RuntimeMetadata::V12(meta) => meta, _ => return Err(ConversionError::InvalidVersion.into()), }; let mut modules = HashMap::new(); diff --git a/test-node/Cargo.toml b/test-node/Cargo.toml index 5b25fd25a4..3ad5623242 100644 --- a/test-node/Cargo.toml +++ b/test-node/Cargo.toml @@ -15,28 +15,28 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] futures = "0.3.5" log = "0.4.11" -structopt = "0.3.16" +structopt = "0.3.17" parking_lot = "0.11.0" -sc-cli = { version = "0.8.0-rc6", features = ["wasmtime"] } -sp-core = "2.0.0-rc6" -sc-executor = { version = "0.8.0-rc6", features = ["wasmtime"] } -sc-service = { version = "0.8.0-rc6", features = ["wasmtime"] } -sp-inherents = "2.0.0-rc6" -sc-transaction-pool = "2.0.0-rc6" -sp-transaction-pool = "2.0.0-rc6" -sc-network = "0.8.0-rc6" -sc-consensus-aura = "0.8.0-rc6" -sp-consensus-aura = "0.8.0-rc6" -sp-consensus = "0.8.0-rc6" -sc-consensus = "0.8.0-rc6" -sc-finality-grandpa = "0.8.0-rc6" -sp-finality-grandpa = "2.0.0-rc6" -sc-client-api = "2.0.0-rc6" -sp-runtime = "2.0.0-rc6" -sc-basic-authorship = "0.8.0-rc6" +sc-cli = { version = "0.8.0", features = ["wasmtime"] } +sp-core = "2.0.0" +sc-executor = { version = "0.8.0", features = ["wasmtime"] } +sc-service = { version = "0.8.0", features = ["wasmtime"] } +sp-inherents = "2.0.0" +sc-transaction-pool = "2.0.0" +sp-transaction-pool = "2.0.0" +sc-network = "0.8.0" +sc-consensus-aura = "0.8.0" +sp-consensus-aura = "0.8.0" +sp-consensus = "0.8.0" +sc-consensus = "0.8.0" +sc-finality-grandpa = "0.8.0" +sp-finality-grandpa = "2.0.0" +sc-client-api = "2.0.0" +sp-runtime = "2.0.0" +sc-basic-authorship = "0.8.0" test-node-runtime = { path = "runtime" } [build-dependencies] -substrate-build-script-utils = "2.0.0-rc6" +substrate-build-script-utils = "2.0.0" diff --git a/test-node/runtime/Cargo.toml b/test-node/runtime/Cargo.toml index 804f120f16..51f65ac79a 100644 --- a/test-node/runtime/Cargo.toml +++ b/test-node/runtime/Cargo.toml @@ -11,32 +11,32 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.3.5", default-features = false, features = ["derive"] } -frame-executive = { version = "2.0.0-rc6", default-features = false } -frame-support = { version = "2.0.0-rc6", default-features = false } -frame-system = { version = "2.0.0-rc6", default-features = false } -pallet-aura = { version = "2.0.0-rc6", default-features = false } -pallet-balances = { version = "2.0.0-rc6", default-features = false } -pallet-grandpa = { version = "2.0.0-rc6", default-features = false } -pallet-randomness-collective-flip = { version = "2.0.0-rc6", default-features = false } -pallet-staking = { version = "2.0.0-rc6", default-features = false } -pallet-sudo = { version = "2.0.0-rc6", default-features = false } -pallet-timestamp = { version = "2.0.0-rc6", default-features = false } -pallet-transaction-payment = { version = "2.0.0-rc6", default-features = false } -serde = { version = "1.0.115", optional = true, features = ["derive"] } -sp-api = { version = "2.0.0-rc6", default-features = false } -sp-block-builder = { version = "2.0.0-rc6", default-features = false } -sp-consensus-aura = { version = "0.8.0-rc6", default-features = false } -sp-core = { version = "2.0.0-rc6", default-features = false } -sp-inherents = { version = "2.0.0-rc6", default-features = false } -sp-io = { version = "2.0.0-rc6", default-features = false } -sp-offchain = { version = "2.0.0-rc6", default-features = false } -sp-runtime = { version = "2.0.0-rc6", default-features = false } -sp-session = { version = "2.0.0-rc6", default-features = false } -sp-std = { version = "2.0.0-rc6", default-features = false } -sp-transaction-pool = { version = "2.0.0-rc6", default-features = false } -sp-version = { version = "2.0.0-rc6", default-features = false } +frame-executive = { version = "2.0.0", default-features = false } +frame-support = { version = "2.0.0", default-features = false } +frame-system = { version = "2.0.0", default-features = false } +pallet-aura = { version = "2.0.0", default-features = false } +pallet-balances = { version = "2.0.0", default-features = false } +pallet-grandpa = { version = "2.0.0", default-features = false } +pallet-randomness-collective-flip = { version = "2.0.0", default-features = false } +pallet-staking = { version = "2.0.0", default-features = false } +pallet-sudo = { version = "2.0.0", default-features = false } +pallet-timestamp = { version = "2.0.0", default-features = false } +pallet-transaction-payment = { version = "2.0.0", default-features = false } +serde = { version = "1.0.116", optional = true, features = ["derive"] } +sp-api = { version = "2.0.0", default-features = false } +sp-block-builder = { version = "2.0.0", default-features = false } +sp-consensus-aura = { version = "0.8.0", default-features = false } +sp-core = { version = "2.0.0", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false } +sp-io = { version = "2.0.0", default-features = false } +sp-offchain = { version = "2.0.0", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false } +sp-session = { version = "2.0.0", default-features = false } +sp-std = { version = "2.0.0", default-features = false } +sp-transaction-pool = { version = "2.0.0", default-features = false } +sp-version = { version = "2.0.0", default-features = false } [build-dependencies] substrate-wasm-builder-runner = "1.0.6" diff --git a/test-node/runtime/src/lib.rs b/test-node/runtime/src/lib.rs index 85abd73d32..ae78b2477d 100644 --- a/test-node/runtime/src/lib.rs +++ b/test-node/runtime/src/lib.rs @@ -226,10 +226,6 @@ impl frame_system::Trait for Runtime { type AvailableBlockRatio = AvailableBlockRatio; /// Version of the runtime. type Version = Version; - /// Converts a module to the index of the module in `construct_runtime!`. - /// - /// This type is being generated by `construct_runtime!`. - type ModuleToIndex = ModuleToIndex; /// What to do if a new account is created. type OnNewAccount = (); /// What to do if an account is fully reaped from the system. @@ -238,6 +234,8 @@ impl frame_system::Trait for Runtime { type AccountData = pallet_balances::AccountData; /// Weight information for the extrinsics of this pallet. type SystemWeightInfo = (); + /// Provides information about the pallet setup in the runtime. + type PalletInfo = PalletInfo; } impl pallet_aura::Trait for Runtime { @@ -259,6 +257,7 @@ impl pallet_grandpa::Trait for Runtime { )>>::IdentificationTuple; type HandleEquivocation = (); + type WeightInfo = (); } parameter_types! { @@ -286,6 +285,7 @@ impl pallet_balances::Trait for Runtime { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type MaxLocks = (); } parameter_types! { From 6a0fbf2c85eab645d1f0187fff945d838b686606 Mon Sep 17 00:00:00 2001 From: David Palm Date: Wed, 23 Sep 2020 15:59:18 +0200 Subject: [PATCH 2/8] WIP implement Subcommand manually (see https://github.com/paritytech/substrate/pull/6894#issuecomment-676060197) --- test-node/src/cli.rs | 28 +++++++++++++++++++++++++++- test-node/src/command.rs | 32 +++++++++++++++++--------------- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/test-node/src/cli.rs b/test-node/src/cli.rs index b94a06ad74..195f9075ec 100644 --- a/test-node/src/cli.rs +++ b/test-node/src/cli.rs @@ -16,10 +16,36 @@ use sc_cli::{ RunCmd, - Subcommand, + BuildSpecCmd, + // ExportBlocksCmd, ImportBlocksCmd, CheckBlockCmd, ExportStateCmd, RevertCmd, + PurgeChainCmd, + // Subcommand, + CliConfiguration, SharedParams, }; use structopt::StructOpt; +#[derive(Debug, StructOpt)] +pub enum Subcommand { + /// Build a spec.json file, outputs to stdout. + BuildSpec(BuildSpecCmd), + /// Export blocks to a file. + // ExportBlocks(ExportBlocksCmd), + /// Import blocks from file. + // ImportBlocks(ImportBlocksCmd), + /// Validate a single block. + // CheckBlock(CheckBlockCmd), + /// Export state as raw chain spec. + // ExportState(ExportStateCmd), + /// Revert chain to the previous state. + // Revert(RevertCmd), + /// Remove the whole chain data. + PurgeChain(PurgeChainCmd), +} + +impl CliConfiguration for Subcommand { + fn shared_params(&self) -> &SharedParams { todo!() } +} + #[derive(Debug, StructOpt)] pub struct Cli { #[structopt(subcommand)] diff --git a/test-node/src/command.rs b/test-node/src/command.rs index f4d7e82fd9..850c39d80c 100644 --- a/test-node/src/command.rs +++ b/test-node/src/command.rs @@ -16,7 +16,7 @@ use crate::{ chain_spec, - cli::Cli, + cli::{Cli, Subcommand}, service, }; use sc_cli::{ @@ -25,7 +25,7 @@ use sc_cli::{ RuntimeVersion, SubstrateCli, }; -use sc_service::PartialComponents; +// use sc_service::PartialComponents; impl SubstrateCli for Cli { fn impl_name() -> String { @@ -74,19 +74,21 @@ pub fn run() -> sc_cli::Result<()> { let cli = Cli::from_args(); match &cli.subcommand { - Some(subcommand) => { - let runner = cli.create_runner(subcommand)?; - runner.run_subcommand(subcommand, |config| { - let PartialComponents { - client, - backend, - task_manager, - import_queue, - .. - } = service::new_partial(&config)?; - Ok((client, backend, import_queue, task_manager)) - }) - } + Some(Subcommand::BuildSpec(_cmd)) => todo!(), + Some(Subcommand::PurgeChain(_cmd)) => todo!(), + // Some(subcommand) => { + // let runner = cli.create_runner(subcommand)?; + // runner.run_subcommand(subcommand, |config| { + // let PartialComponents { + // client, + // backend, + // task_manager, + // import_queue, + // .. + // } = service::new_partial(&config)?; + // Ok((client, backend, import_queue, task_manager)) + // }) + // } None => { let runner = cli.create_runner(&cli.run)?; runner.run_node_until_exit(|config| { From d100d070471d956cd554f4675b677d6928fd79c9 Mon Sep 17 00:00:00 2001 From: David Palm Date: Thu, 24 Sep 2020 09:33:48 +0200 Subject: [PATCH 3/8] Add pallet-staking/std to the std feature --- test-node/runtime/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/test-node/runtime/Cargo.toml b/test-node/runtime/Cargo.toml index 51f65ac79a..a75d1cde3f 100644 --- a/test-node/runtime/Cargo.toml +++ b/test-node/runtime/Cargo.toml @@ -52,6 +52,7 @@ std = [ "pallet-balances/std", "pallet-grandpa/std", "pallet-randomness-collective-flip/std", + "pallet-staking/std", "pallet-sudo/std", "pallet-timestamp/std", "pallet-transaction-payment/std", From 9f0d358b4449f4d5e082b25d45aad2d158e7e8d3 Mon Sep 17 00:00:00 2001 From: David Palm Date: Thu, 24 Sep 2020 10:12:25 +0200 Subject: [PATCH 4/8] Sort out the subcommand impl --- test-node/src/cli.rs | 27 +++++---------------------- test-node/src/command.rs | 28 ++++++++++++---------------- 2 files changed, 17 insertions(+), 38 deletions(-) diff --git a/test-node/src/cli.rs b/test-node/src/cli.rs index 195f9075ec..c2935beb1a 100644 --- a/test-node/src/cli.rs +++ b/test-node/src/cli.rs @@ -15,35 +15,18 @@ // along with substrate-subxt. If not, see . use sc_cli::{ - RunCmd, BuildSpecCmd, - // ExportBlocksCmd, ImportBlocksCmd, CheckBlockCmd, ExportStateCmd, RevertCmd, PurgeChainCmd, - // Subcommand, - CliConfiguration, SharedParams, + RunCmd, }; use structopt::StructOpt; #[derive(Debug, StructOpt)] pub enum Subcommand { - /// Build a spec.json file, outputs to stdout. - BuildSpec(BuildSpecCmd), - /// Export blocks to a file. - // ExportBlocks(ExportBlocksCmd), - /// Import blocks from file. - // ImportBlocks(ImportBlocksCmd), - /// Validate a single block. - // CheckBlock(CheckBlockCmd), - /// Export state as raw chain spec. - // ExportState(ExportStateCmd), - /// Revert chain to the previous state. - // Revert(RevertCmd), - /// Remove the whole chain data. - PurgeChain(PurgeChainCmd), -} - -impl CliConfiguration for Subcommand { - fn shared_params(&self) -> &SharedParams { todo!() } + /// Build a spec.json file, outputs to stdout. + BuildSpec(BuildSpecCmd), + /// Remove the whole chain data. + PurgeChain(PurgeChainCmd), } #[derive(Debug, StructOpt)] diff --git a/test-node/src/command.rs b/test-node/src/command.rs index 850c39d80c..14aef05638 100644 --- a/test-node/src/command.rs +++ b/test-node/src/command.rs @@ -16,7 +16,10 @@ use crate::{ chain_spec, - cli::{Cli, Subcommand}, + cli::{ + Cli, + Subcommand, + }, service, }; use sc_cli::{ @@ -74,21 +77,14 @@ pub fn run() -> sc_cli::Result<()> { let cli = Cli::from_args(); match &cli.subcommand { - Some(Subcommand::BuildSpec(_cmd)) => todo!(), - Some(Subcommand::PurgeChain(_cmd)) => todo!(), - // Some(subcommand) => { - // let runner = cli.create_runner(subcommand)?; - // runner.run_subcommand(subcommand, |config| { - // let PartialComponents { - // client, - // backend, - // task_manager, - // import_queue, - // .. - // } = service::new_partial(&config)?; - // Ok((client, backend, import_queue, task_manager)) - // }) - // } + Some(Subcommand::BuildSpec(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) + } + Some(Subcommand::PurgeChain(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.sync_run(|config| cmd.run(config.database)) + } None => { let runner = cli.create_runner(&cli.run)?; runner.run_node_until_exit(|config| { From a0f430c6accb00e4d4d3ebd0c2ebbfa75044b6fa Mon Sep 17 00:00:00 2001 From: David Palm Date: Thu, 24 Sep 2020 11:48:13 +0200 Subject: [PATCH 5/8] Sort out the module index (ty @ascjones) Sort out the RefCount type (ty @dvc94ch) Random tweaks to make test-node more similar to the vanilla node-template --- src/frame/balances.rs | 2 +- src/frame/system.rs | 2 +- src/metadata.rs | 8 +++++--- test-node/runtime/src/lib.rs | 11 ++++++++--- test-node/src/chain_spec.rs | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/frame/balances.rs b/src/frame/balances.rs index 9ebf6d6388..598421c8f1 100644 --- a/src/frame/balances.rs +++ b/src/frame/balances.rs @@ -146,7 +146,7 @@ mod tests { let event = client .transfer_and_watch(&alice, &bob.account_id(), 10_000) .await - .unwrap() + .expect("sending an xt works") .transfer() .unwrap() .unwrap(); diff --git a/src/frame/system.rs b/src/frame/system.rs index 7c6db4dba4..b0cb80fcbb 100644 --- a/src/frame/system.rs +++ b/src/frame/system.rs @@ -118,7 +118,7 @@ pub trait System { } /// Type used to encode the number of references an account has. -pub type RefCount = u8; +pub type RefCount = u32; /// Information of an account. #[derive(Clone, Debug, Eq, PartialEq, Default, Decode, Encode)] diff --git a/src/metadata.rs b/src/metadata.rs index deae0778b4..18ea8181fb 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -163,6 +163,7 @@ impl Metadata { #[derive(Clone, Debug)] pub struct ModuleMetadata { + index: u8, name: String, storage: HashMap, // constants @@ -509,6 +510,7 @@ impl TryFrom for Metadata { modules.insert( module_name.clone(), ModuleMetadata { + index: module.index, name: module_name.clone(), storage: storage_map, }, @@ -523,7 +525,7 @@ impl TryFrom for Metadata { modules_with_calls.insert( module_name.clone(), ModuleWithCalls { - index: modules_with_calls.len() as u8, + index: module.index, calls: call_map, }, ); @@ -536,7 +538,7 @@ impl TryFrom for Metadata { modules_with_events.insert( module_name.clone(), ModuleWithEvents { - index: modules_with_events.len() as u8, + index: module.index, name: module_name.clone(), events: event_map, }, @@ -549,7 +551,7 @@ impl TryFrom for Metadata { modules_with_errors.insert( module_name.clone(), ModuleWithErrors { - index: modules_with_errors.len() as u8, + index: module.index, name: module_name.clone(), errors: error_map, }, diff --git a/test-node/runtime/src/lib.rs b/test-node/runtime/src/lib.rs index ae78b2477d..3a94d77339 100644 --- a/test-node/runtime/src/lib.rs +++ b/test-node/runtime/src/lib.rs @@ -169,18 +169,22 @@ pub fn native_version() -> NativeVersion { } } +const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10); parameter_types! { pub const BlockHashCount: BlockNumber = 2400; /// We allow for 2 seconds of compute with a 6 second average block time. pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - /// Assume 10% of weight for average on_initialize calls. - pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get() - .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get(); + /// Assume 10% of weight for average on_initialize calls. + pub MaximumExtrinsicWeight: Weight = + AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT) + * MaximumBlockWeight::get(); pub const MaximumBlockLength: u32 = 5 * 1024 * 1024; pub const Version: RuntimeVersion = VERSION; } +// const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct()); + impl frame_system::Trait for Runtime { /// The basic call filter to use in dispatchable. type BaseCallFilter = (); @@ -234,6 +238,7 @@ impl frame_system::Trait for Runtime { type AccountData = pallet_balances::AccountData; /// Weight information for the extrinsics of this pallet. type SystemWeightInfo = (); + // type SystemWeightInfo = weights::frame_system::WeightInfo; /// Provides information about the pallet setup in the runtime. type PalletInfo = PalletInfo; } diff --git a/test-node/src/chain_spec.rs b/test-node/src/chain_spec.rs index a9cc64e42d..7ee9f0476d 100644 --- a/test-node/src/chain_spec.rs +++ b/test-node/src/chain_spec.rs @@ -101,7 +101,7 @@ pub fn development_config() -> Result { // Properties None, // Extensions - None, + Default::default(), )) } From 6845ec43cd4c0928c09b9c60b4c204c4b0a751c7 Mon Sep 17 00:00:00 2001 From: David Palm Date: Thu, 24 Sep 2020 11:49:40 +0200 Subject: [PATCH 6/8] obey the fmt --- test-node/runtime/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test-node/runtime/src/lib.rs b/test-node/runtime/src/lib.rs index 3a94d77339..493fa709e0 100644 --- a/test-node/runtime/src/lib.rs +++ b/test-node/runtime/src/lib.rs @@ -175,10 +175,10 @@ parameter_types! { /// We allow for 2 seconds of compute with a 6 second average block time. pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - /// Assume 10% of weight for average on_initialize calls. - pub MaximumExtrinsicWeight: Weight = - AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT) - * MaximumBlockWeight::get(); + /// Assume 10% of weight for average on_initialize calls. + pub MaximumExtrinsicWeight: Weight = + AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT) + * MaximumBlockWeight::get(); pub const MaximumBlockLength: u32 = 5 * 1024 * 1024; pub const Version: RuntimeVersion = VERSION; } From 5bb6a15fb98b4f6600f02cb7d88fa787c0f3fd3a Mon Sep 17 00:00:00 2001 From: David Palm Date: Thu, 24 Sep 2020 12:20:21 +0200 Subject: [PATCH 7/8] cleanup --- test-node/runtime/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/test-node/runtime/src/lib.rs b/test-node/runtime/src/lib.rs index 493fa709e0..baed45b801 100644 --- a/test-node/runtime/src/lib.rs +++ b/test-node/runtime/src/lib.rs @@ -183,8 +183,6 @@ parameter_types! { pub const Version: RuntimeVersion = VERSION; } -// const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct()); - impl frame_system::Trait for Runtime { /// The basic call filter to use in dispatchable. type BaseCallFilter = (); @@ -238,7 +236,6 @@ impl frame_system::Trait for Runtime { type AccountData = pallet_balances::AccountData; /// Weight information for the extrinsics of this pallet. type SystemWeightInfo = (); - // type SystemWeightInfo = weights::frame_system::WeightInfo; /// Provides information about the pallet setup in the runtime. type PalletInfo = PalletInfo; } From 6c7ba8c8b3c653a1a4892243ed93012b1e27ead6 Mon Sep 17 00:00:00 2001 From: David Palm Date: Thu, 24 Sep 2020 12:21:25 +0200 Subject: [PATCH 8/8] more cleanup --- test-node/src/command.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/test-node/src/command.rs b/test-node/src/command.rs index 14aef05638..3e6929cca4 100644 --- a/test-node/src/command.rs +++ b/test-node/src/command.rs @@ -28,7 +28,6 @@ use sc_cli::{ RuntimeVersion, SubstrateCli, }; -// use sc_service::PartialComponents; impl SubstrateCli for Cli { fn impl_name() -> String {