From fc4b914745e94688e82871fba6e19215ce3c3f15 Mon Sep 17 00:00:00 2001 From: kalaninja Date: Wed, 19 Jul 2023 13:00:34 +0700 Subject: [PATCH 1/4] add overhead benchmark to polkadot-parachain --- Cargo.lock | 5 + .../assets/asset-hub-kusama/src/lib.rs | 5 +- .../assets/asset-hub-polkadot/src/lib.rs | 5 +- .../assets/asset-hub-westend/src/lib.rs | 5 +- .../collectives-polkadot/src/lib.rs | 5 +- polkadot-parachain/Cargo.toml | 5 + polkadot-parachain/src/benchmarking.rs | 326 ++++++++++++++++++ polkadot-parachain/src/command.rs | 37 +- polkadot-parachain/src/main.rs | 1 + polkadot-parachain/src/service.rs | 2 +- .../tests/benchmark_overhead_works.rs | 35 ++ .../tests/benchmark_storage_works.rs | 3 +- 12 files changed, 414 insertions(+), 20 deletions(-) create mode 100644 polkadot-parachain/src/benchmarking.rs create mode 100644 polkadot-parachain/tests/benchmark_overhead_works.rs diff --git a/Cargo.lock b/Cargo.lock index 7fbc7dd6c9c..b209409e48a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9930,12 +9930,15 @@ dependencies = [ "cumulus-relay-chain-interface", "frame-benchmarking", "frame-benchmarking-cli", + "frame-system", "futures", "glutton-runtime", "hex-literal 0.4.1", "jsonrpsee", "log", "nix 0.26.2", + "pallet-asset-conversion-tx-payment", + "pallet-asset-tx-payment", "pallet-transaction-payment-rpc", "parachains-common", "parity-scale-codec", @@ -9968,7 +9971,9 @@ dependencies = [ "sp-blockchain", "sp-consensus-aura", "sp-core", + "sp-inherents", "sp-io", + "sp-keyring", "sp-keystore", "sp-offchain", "sp-runtime", diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs b/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs index ab570daa215..32e66dd7de8 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs @@ -81,7 +81,8 @@ pub use sp_runtime::BuildStorage; // Polkadot imports use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; -use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; +pub use polkadot_runtime_common::BlockHashCount; +use polkadot_runtime_common::SlowAdjustingFeeUpdate; use xcm::latest::BodyId; use xcm_executor::XcmExecutor; @@ -807,6 +808,8 @@ pub type SignedExtra = ( /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Migrations to apply on runtime upgrade. diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs index ea578c60707..c1368f93727 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs @@ -116,7 +116,8 @@ pub use sp_runtime::BuildStorage; // Polkadot imports use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; -use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; +pub use polkadot_runtime_common::BlockHashCount; +use polkadot_runtime_common::SlowAdjustingFeeUpdate; use xcm::latest::BodyId; use xcm_executor::XcmExecutor; @@ -787,6 +788,8 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_asset_tx_payment::ChargeAssetTxPayment, ); +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; diff --git a/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 2dffccae27e..2cba7fca8a3 100644 --- a/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -81,7 +81,8 @@ pub use sp_runtime::BuildStorage; use assets_common::{ foreign_creators::ForeignCreators, matching::FromSiblingParachain, MultiLocationForAssetId, }; -use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; +pub use polkadot_runtime_common::BlockHashCount; +use polkadot_runtime_common::SlowAdjustingFeeUpdate; use xcm_executor::XcmExecutor; use crate::xcm_config::ForeignCreatorsSovereignAccountOf; @@ -829,6 +830,8 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_asset_conversion_tx_payment::ChargeAssetTxPayment, ); +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index ce512d2353c..42e4607df94 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -91,7 +91,8 @@ pub use sp_runtime::BuildStorage; // Polkadot imports use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; -use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; +pub use polkadot_runtime_common::BlockHashCount; +use polkadot_runtime_common::SlowAdjustingFeeUpdate; use xcm::latest::BodyId; use xcm_executor::XcmExecutor; @@ -625,6 +626,8 @@ pub type SignedExtra = ( frame_system::CheckNonce, frame_system::CheckWeight, ); +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; diff --git a/polkadot-parachain/Cargo.toml b/polkadot-parachain/Cargo.toml index abd11529336..17ed04889f5 100644 --- a/polkadot-parachain/Cargo.toml +++ b/polkadot-parachain/Cargo.toml @@ -58,7 +58,9 @@ sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -70,6 +72,9 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" } frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-asset-conversion-tx-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/polkadot-parachain/src/benchmarking.rs b/polkadot-parachain/src/benchmarking.rs new file mode 100644 index 00000000000..d19dfb402f7 --- /dev/null +++ b/polkadot-parachain/src/benchmarking.rs @@ -0,0 +1,326 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +use std::{sync::Arc, time::Duration}; + +use sc_client_api::BlockBackend; +use sp_core::Pair; +use sp_inherents::{InherentData, InherentDataProvider}; +use sp_keyring::Sr25519Keyring; +use sp_runtime::{generic, OpaqueExtrinsic, SaturatedConversion}; + +use codec::Encode; +use cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider; + +use crate::service::ParachainClient; + +/// Generates `System::Remark` extrinsics for the benchmarks. +/// +/// Note: Should only be used for benchmarking. +pub struct RemarkBuilder { + client: Arc>, +} + +impl RemarkBuilder { + /// Creates a new [`Self`] from the given client. + pub fn new(client: Arc>) -> Self { + Self { client } + } +} + +impl frame_benchmarking_cli::ExtrinsicBuilder + for RemarkBuilder +{ + fn pallet(&self) -> &str { + "system" + } + + fn extrinsic(&self) -> &str { + "remark" + } + + fn build(&self, nonce: u32) -> Result { + use asset_hub_kusama_runtime as runtime; + + let period = runtime::BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let best_block = self.client.chain_info().best_number; + let tip = 0; + let extra: runtime::SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal( + period, + best_block.saturated_into(), + )), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_asset_tx_payment::ChargeAssetTxPayment::::from(tip, None), + ); + + let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); + let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); + let best_hash = self.client.chain_info().best_hash; + let payload = runtime::SignedPayload::from_raw( + call.clone(), + extra.clone(), + ( + (), + runtime::VERSION.spec_version, + runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ), + ); + + let sender = Sr25519Keyring::Bob.pair(); + let signature = payload.using_encoded(|x| sender.sign(x)); + let extrinsic = runtime::UncheckedExtrinsic::new_signed( + call, + sp_runtime::AccountId32::from(sender.public()).into(), + parachains_common::Signature::Sr25519(signature), + extra, + ); + + Ok(extrinsic.into()) + } +} + +impl frame_benchmarking_cli::ExtrinsicBuilder + for RemarkBuilder +{ + fn pallet(&self) -> &str { + "system" + } + + fn extrinsic(&self) -> &str { + "remark" + } + + fn build(&self, nonce: u32) -> Result { + use asset_hub_westend_runtime as runtime; + + let period = runtime::BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let best_block = self.client.chain_info().best_number; + let tip = 0; + let extra: runtime::SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal( + period, + best_block.saturated_into(), + )), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::::from( + tip, None, + ), + ); + + let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); + let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); + let best_hash = self.client.chain_info().best_hash; + let payload = runtime::SignedPayload::from_raw( + call.clone(), + extra.clone(), + ( + (), + runtime::VERSION.spec_version, + runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ), + ); + + let sender = Sr25519Keyring::Bob.pair(); + let signature = payload.using_encoded(|x| sender.sign(x)); + let extrinsic = runtime::UncheckedExtrinsic::new_signed( + call, + sp_runtime::AccountId32::from(sender.public()).into(), + parachains_common::Signature::Sr25519(signature), + extra, + ); + + Ok(extrinsic.into()) + } +} + +impl frame_benchmarking_cli::ExtrinsicBuilder + for RemarkBuilder +{ + fn pallet(&self) -> &str { + "system" + } + + fn extrinsic(&self) -> &str { + "remark" + } + + fn build(&self, nonce: u32) -> Result { + use asset_hub_polkadot_runtime as runtime; + + let period = runtime::BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let best_block = self.client.chain_info().best_number; + let tip = 0; + let extra: runtime::SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal( + period, + best_block.saturated_into(), + )), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_asset_tx_payment::ChargeAssetTxPayment::::from(tip, None), + ); + + let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); + let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); + let best_hash = self.client.chain_info().best_hash; + let payload = runtime::SignedPayload::from_raw( + call.clone(), + extra.clone(), + ( + (), + runtime::VERSION.spec_version, + runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ), + ); + + let sender = Sr25519Keyring::Bob.pair(); + let signature = payload.using_encoded(|x| sender.sign(x)); + let extrinsic = runtime::UncheckedExtrinsic::new_signed( + call, + sp_runtime::AccountId32::from(sender.public()).into(), + parachains_common::Signature::Sr25519(signature), + extra, + ); + + Ok(extrinsic.into()) + } +} + +impl frame_benchmarking_cli::ExtrinsicBuilder + for RemarkBuilder +{ + fn pallet(&self) -> &str { + "system" + } + + fn extrinsic(&self) -> &str { + "remark" + } + + fn build(&self, nonce: u32) -> Result { + use collectives_polkadot_runtime as runtime; + + let period = runtime::BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let best_block = self.client.chain_info().best_number; + let extra: runtime::SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal( + period, + best_block.saturated_into(), + )), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + ); + + let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); + let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); + let best_hash = self.client.chain_info().best_hash; + let payload = runtime::SignedPayload::from_raw( + call.clone(), + extra.clone(), + ( + (), + runtime::VERSION.spec_version, + runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + ), + ); + + let sender = Sr25519Keyring::Bob.pair(); + let signature = payload.using_encoded(|x| sender.sign(x)); + let extrinsic = runtime::UncheckedExtrinsic::new_signed( + call, + sp_runtime::AccountId32::from(sender.public()).into(), + parachains_common::Signature::Sr25519(signature), + extra, + ); + + Ok(extrinsic.into()) + } +} + +/// Generates inherent data for the `benchmark overhead` command. +pub fn inherent_benchmark_data() -> sc_cli::Result { + let mut inherent_data = InherentData::new(); + + let timestamp = sp_timestamp::InherentDataProvider::new(Duration::ZERO.into()); + futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data)) + .map_err(|e| format!("creating inherent data: {e:?}"))?; + + let parachain_inherent = MockValidationDataInherentDataProvider { + current_para_block: 1, + relay_offset: 0, + relay_blocks_per_para_block: 1, + para_blocks_per_relay_epoch: 0, + relay_randomness_config: (), + xcm_config: Default::default(), + raw_downward_messages: Default::default(), + raw_horizontal_messages: Default::default(), + }; + + futures::executor::block_on(parachain_inherent.provide_inherent_data(&mut inherent_data)) + .map_err(|e| format!("creating inherent data: {e:?}"))?; + + Ok(inherent_data) +} diff --git a/polkadot-parachain/src/command.rs b/polkadot-parachain/src/command.rs index 4bc19f86e4a..5e341622be6 100644 --- a/polkadot-parachain/src/command.rs +++ b/polkadot-parachain/src/command.rs @@ -15,9 +15,10 @@ // along with Cumulus. If not, see . use crate::{ + benchmarking::{inherent_benchmark_data, RemarkBuilder}, chain_spec, cli::{Cli, RelayChainCli, Subcommand}, - service::{new_partial, Block}, + service::new_partial, }; use cumulus_primitives_core::ParaId; use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; @@ -116,7 +117,7 @@ fn runtime(id: &str) -> Runtime { fn load_spec(id: &str) -> std::result::Result, String> { let (id, _, para_id) = extract_parachain_id(id); Ok(match id { - // - Defaul-like + // - Default-like "staging" => Box::new(chain_spec::rococo_parachain::staging_rococo_parachain_local_config()), "tick" => @@ -651,24 +652,19 @@ pub fn run() -> Result<()> { // Switch on the concrete benchmark sub-command- match cmd { + #[cfg(not(feature = "runtime-benchmarks"))] + BenchmarkCmd::Pallet(_) => Err("Benchmarking wasn't enabled when building the node. \ + You can enable it with `--features runtime-benchmarks`." + .into()), + #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Pallet(cmd) => - if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| cmd.run::(config)) - } else { - Err("Benchmarking wasn't enabled when building the node. \ - You can enable it with `--features runtime-benchmarks`." - .into()) - }, + runner.sync_run(|config| cmd.run::(config)), BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { construct_benchmark_partials!(config, |partials| cmd.run(partials.client)) }), #[cfg(not(feature = "runtime-benchmarks"))] - BenchmarkCmd::Storage(_) => - return Err(sc_cli::Error::Input( - "Compile with --features=runtime-benchmarks \ + BenchmarkCmd::Storage(_) => Err("Compile with --features=runtime-benchmarks \ to enable storage benchmarks." - .into(), - ) .into()), #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { @@ -679,6 +675,19 @@ pub fn run() -> Result<()> { cmd.run(config, partials.client.clone(), db, storage) }) }), + BenchmarkCmd::Overhead(cmd) => runner.sync_run(|config| { + construct_benchmark_partials!(config, |partials| { + let ext_builder = RemarkBuilder::new(partials.client.clone()); + + cmd.run( + config, + partials.client, + inherent_benchmark_data()?, + Vec::new(), + &ext_builder, + ) + }) + }), BenchmarkCmd::Machine(cmd) => runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), // NOTE: this allows the Client to leniently implement diff --git a/polkadot-parachain/src/main.rs b/polkadot-parachain/src/main.rs index d114d2f5f2c..d05f0488579 100644 --- a/polkadot-parachain/src/main.rs +++ b/polkadot-parachain/src/main.rs @@ -22,6 +22,7 @@ mod chain_spec; #[macro_use] mod service; +mod benchmarking; mod cli; mod command; mod rpc; diff --git a/polkadot-parachain/src/service.rs b/polkadot-parachain/src/service.rs index 552c6b4a832..9381e5c5b26 100644 --- a/polkadot-parachain/src/service.rs +++ b/polkadot-parachain/src/service.rs @@ -64,7 +64,7 @@ type HostFunctions = sp_io::SubstrateHostFunctions; type HostFunctions = (sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions); -type ParachainClient = TFullClient>; +pub type ParachainClient = TFullClient>; type ParachainBackend = TFullBackend; diff --git a/polkadot-parachain/tests/benchmark_overhead_works.rs b/polkadot-parachain/tests/benchmark_overhead_works.rs new file mode 100644 index 00000000000..34e91db36b6 --- /dev/null +++ b/polkadot-parachain/tests/benchmark_overhead_works.rs @@ -0,0 +1,35 @@ +use std::process::Command; + +use assert_cmd::cargo::cargo_bin; +use tempfile::tempdir; + +/// The runtimes that this command supports. +static RUNTIMES: [&str; 4] = + ["asset-hub-westend", "asset-hub-kusama", "asset-hub-polkadot", "collectives-polkadot"]; + +/// The `benchmark overhead` command works for the dev runtimes. +#[test] +#[ignore] +fn benchmark_overhead_works() { + for runtime in RUNTIMES { + let tmp_dir = tempdir().expect("could not create a temp dir"); + let base_path = tmp_dir.path(); + let runtime = format!("{}-dev", runtime); + + let status = Command::new(cargo_bin("polkadot-parachain")) + .args(["benchmark", "overhead", "--chain", &runtime, "-d"]) + .arg(base_path) + .arg("--weight-path") + .arg(base_path) + .args(["--warmup", "10", "--repeat", "10"]) + .args(["--add", "100", "--mul", "1.2", "--metric", "p75"]) + .args(["--max-ext-per-block", "10"]) + .status() + .unwrap(); + assert!(status.success()); + + // Weight files have been created. + assert!(base_path.join("block_weights.rs").exists()); + assert!(base_path.join("extrinsic_weights.rs").exists()); + } +} diff --git a/polkadot-parachain/tests/benchmark_storage_works.rs b/polkadot-parachain/tests/benchmark_storage_works.rs index df3078b4dab..f6b669f6f24 100644 --- a/polkadot-parachain/tests/benchmark_storage_works.rs +++ b/polkadot-parachain/tests/benchmark_storage_works.rs @@ -8,7 +8,8 @@ use std::{ use tempfile::tempdir; /// The runtimes that this command supports. -static RUNTIMES: [&str; 3] = ["asset-hub-westend", "asset-hub-kusama", "asset-hub-polkadot"]; +static RUNTIMES: [&str; 4] = + ["asset-hub-westend", "asset-hub-kusama", "asset-hub-polkadot", "collectives-polkadot"]; /// The `benchmark storage` command works for the dev runtimes. #[test] From 8a0ec56da3487f6eaf4768e132127aa3ea4d3db9 Mon Sep 17 00:00:00 2001 From: kalaninja Date: Wed, 19 Jul 2023 18:48:33 +0700 Subject: [PATCH 2/4] add overhead benchmarks for bridge-hub --- Cargo.lock | 1 + .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 6 +- .../bridge-hub-polkadot/src/lib.rs | 6 +- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 6 +- polkadot-parachain/Cargo.toml | 1 + polkadot-parachain/src/benchmarking.rs | 199 ++++++++++++++++++ .../tests/benchmark_overhead_works.rs | 11 +- .../tests/benchmark_storage_works.rs | 11 +- 8 files changed, 234 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c21de37b4ab..3a1972c0149 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10066,6 +10066,7 @@ dependencies = [ "nix 0.26.2", "pallet-asset-conversion-tx-payment", "pallet-asset-tx-payment", + "pallet-transaction-payment", "pallet-transaction-payment-rpc", "parachains-common", "parity-scale-codec", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index e7c8216e644..acfd236c2e1 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -64,7 +64,8 @@ use xcm_config::{ #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; +pub use polkadot_runtime_common::BlockHashCount; +use polkadot_runtime_common::SlowAdjustingFeeUpdate; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; @@ -101,6 +102,9 @@ pub type SignedExtra = ( pallet_transaction_payment::ChargeTransactionPayment, ); +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; + /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index b82c3a461e9..0940ae696dc 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -65,7 +65,8 @@ use xcm_config::{ pub use sp_runtime::BuildStorage; // Polkadot imports -use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; +pub use polkadot_runtime_common::BlockHashCount; +use polkadot_runtime_common::SlowAdjustingFeeUpdate; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; @@ -101,6 +102,9 @@ pub type SignedExtra = ( pallet_transaction_payment::ChargeTransactionPayment, ); +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; + /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index c4bfa641db0..b34d23c050c 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -66,7 +66,8 @@ use bp_runtime::HeaderId; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; +pub use polkadot_runtime_common::BlockHashCount; +use polkadot_runtime_common::SlowAdjustingFeeUpdate; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; @@ -118,6 +119,9 @@ pub type SignedExtra = ( (BridgeRefundBridgeHubRococoMessages, BridgeRefundBridgeHubWococoMessages), ); +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; + /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; diff --git a/polkadot-parachain/Cargo.toml b/polkadot-parachain/Cargo.toml index bd580a24d54..f36e5b81c9c 100644 --- a/polkadot-parachain/Cargo.toml +++ b/polkadot-parachain/Cargo.toml @@ -75,6 +75,7 @@ frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://gith frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-asset-conversion-tx-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/polkadot-parachain/src/benchmarking.rs b/polkadot-parachain/src/benchmarking.rs index d19dfb402f7..c570439819d 100644 --- a/polkadot-parachain/src/benchmarking.rs +++ b/polkadot-parachain/src/benchmarking.rs @@ -300,6 +300,205 @@ impl frame_benchmarking_cli::ExtrinsicBuilder } } +impl frame_benchmarking_cli::ExtrinsicBuilder + for RemarkBuilder +{ + fn pallet(&self) -> &str { + "system" + } + + fn extrinsic(&self) -> &str { + "remark" + } + + fn build(&self, nonce: u32) -> Result { + use bridge_hub_polkadot_runtime as runtime; + + let period = runtime::BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let best_block = self.client.chain_info().best_number; + let extra: runtime::SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal( + period, + best_block.saturated_into(), + )), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(0), + ); + + let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); + let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); + let best_hash = self.client.chain_info().best_hash; + let payload = runtime::SignedPayload::from_raw( + call.clone(), + extra.clone(), + ( + (), + runtime::VERSION.spec_version, + runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ), + ); + + let sender = Sr25519Keyring::Bob.pair(); + let signature = payload.using_encoded(|x| sender.sign(x)); + let extrinsic = runtime::UncheckedExtrinsic::new_signed( + call, + sp_runtime::AccountId32::from(sender.public()).into(), + parachains_common::Signature::Sr25519(signature), + extra, + ); + + Ok(extrinsic.into()) + } +} + +impl frame_benchmarking_cli::ExtrinsicBuilder + for RemarkBuilder +{ + fn pallet(&self) -> &str { + "system" + } + + fn extrinsic(&self) -> &str { + "remark" + } + + fn build(&self, nonce: u32) -> Result { + use bridge_hub_kusama_runtime as runtime; + + let period = runtime::BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let best_block = self.client.chain_info().best_number; + let extra: runtime::SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal( + period, + best_block.saturated_into(), + )), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(0), + ); + + let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); + let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); + let best_hash = self.client.chain_info().best_hash; + let payload = runtime::SignedPayload::from_raw( + call.clone(), + extra.clone(), + ( + (), + runtime::VERSION.spec_version, + runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ), + ); + + let sender = Sr25519Keyring::Bob.pair(); + let signature = payload.using_encoded(|x| sender.sign(x)); + let extrinsic = runtime::UncheckedExtrinsic::new_signed( + call, + sp_runtime::AccountId32::from(sender.public()).into(), + parachains_common::Signature::Sr25519(signature), + extra, + ); + + Ok(extrinsic.into()) + } +} + +impl frame_benchmarking_cli::ExtrinsicBuilder + for RemarkBuilder +{ + fn pallet(&self) -> &str { + "system" + } + + fn extrinsic(&self) -> &str { + "remark" + } + + fn build(&self, nonce: u32) -> Result { + use bridge_hub_rococo_runtime as runtime; + + let period = runtime::BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let best_block = self.client.chain_info().best_number; + let extra: runtime::SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal( + period, + best_block.saturated_into(), + )), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(0), + bridge_hub_rococo_runtime::BridgeRejectObsoleteHeadersAndMessages {}, + ( + bridge_hub_rococo_runtime::bridge_hub_wococo_config::BridgeRefundBridgeHubRococoMessages::default(), + bridge_hub_rococo_runtime::bridge_hub_rococo_config::BridgeRefundBridgeHubWococoMessages::default(), + ), + ); + + let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); + let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); + let best_hash = self.client.chain_info().best_hash; + let payload = runtime::SignedPayload::from_raw( + call.clone(), + extra.clone(), + ( + (), + runtime::VERSION.spec_version, + runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + (), + ((), ()), + ), + ); + + let sender = Sr25519Keyring::Bob.pair(); + let signature = payload.using_encoded(|x| sender.sign(x)); + let extrinsic = runtime::UncheckedExtrinsic::new_signed( + call, + sp_runtime::AccountId32::from(sender.public()).into(), + parachains_common::Signature::Sr25519(signature), + extra, + ); + + Ok(extrinsic.into()) + } +} + /// Generates inherent data for the `benchmark overhead` command. pub fn inherent_benchmark_data() -> sc_cli::Result { let mut inherent_data = InherentData::new(); diff --git a/polkadot-parachain/tests/benchmark_overhead_works.rs b/polkadot-parachain/tests/benchmark_overhead_works.rs index 34e91db36b6..7f4aaed3176 100644 --- a/polkadot-parachain/tests/benchmark_overhead_works.rs +++ b/polkadot-parachain/tests/benchmark_overhead_works.rs @@ -4,8 +4,15 @@ use assert_cmd::cargo::cargo_bin; use tempfile::tempdir; /// The runtimes that this command supports. -static RUNTIMES: [&str; 4] = - ["asset-hub-westend", "asset-hub-kusama", "asset-hub-polkadot", "collectives-polkadot"]; +static RUNTIMES: [&str; 7] = [ + "asset-hub-westend", + "asset-hub-kusama", + "asset-hub-polkadot", + "collectives-polkadot", + "bridge-hub-polkadot", + "bridge-hub-kusama", + "bridge-hub-rococo", +]; /// The `benchmark overhead` command works for the dev runtimes. #[test] diff --git a/polkadot-parachain/tests/benchmark_storage_works.rs b/polkadot-parachain/tests/benchmark_storage_works.rs index f6b669f6f24..e1e02699c5d 100644 --- a/polkadot-parachain/tests/benchmark_storage_works.rs +++ b/polkadot-parachain/tests/benchmark_storage_works.rs @@ -8,8 +8,15 @@ use std::{ use tempfile::tempdir; /// The runtimes that this command supports. -static RUNTIMES: [&str; 4] = - ["asset-hub-westend", "asset-hub-kusama", "asset-hub-polkadot", "collectives-polkadot"]; +static RUNTIMES: [&str; 7] = [ + "asset-hub-westend", + "asset-hub-kusama", + "asset-hub-polkadot", + "collectives-polkadot", + "bridge-hub-polkadot", + "bridge-hub-kusama", + "bridge-hub-rococo", +]; /// The `benchmark storage` command works for the dev runtimes. #[test] From 9c5f504bb7623212bfd29c46eeb05ca31e03a696 Mon Sep 17 00:00:00 2001 From: kalaninja Date: Sat, 22 Jul 2023 17:55:04 +0700 Subject: [PATCH 3/4] reduce copy-paste --- Cargo.lock | 1 + polkadot-parachain/Cargo.toml | 1 + polkadot-parachain/src/benchmarking.rs | 682 +++++++++++-------------- polkadot-parachain/src/command.rs | 39 +- 4 files changed, 318 insertions(+), 405 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a1972c0149..e1cdd444a91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10073,6 +10073,7 @@ dependencies = [ "penpal-runtime", "polkadot-cli", "polkadot-primitives", + "polkadot-runtime-common", "polkadot-service", "rococo-parachain-runtime", "sc-basic-authorship", diff --git a/polkadot-parachain/Cargo.toml b/polkadot-parachain/Cargo.toml index f36e5b81c9c..a5c511c4b90 100644 --- a/polkadot-parachain/Cargo.toml +++ b/polkadot-parachain/Cargo.toml @@ -83,6 +83,7 @@ substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/subs # Use rococo-native as this is currently the default "local" relay chain polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master", features = ["rococo-native"] } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "master" } xcm = { git = "https://github.com/paritytech/polkadot", branch = "master" } diff --git a/polkadot-parachain/src/benchmarking.rs b/polkadot-parachain/src/benchmarking.rs index c570439819d..7ad1e8e1c60 100644 --- a/polkadot-parachain/src/benchmarking.rs +++ b/polkadot-parachain/src/benchmarking.rs @@ -14,422 +14,340 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -use std::{sync::Arc, time::Duration}; +use std::{marker::PhantomData, sync::Arc, time::Duration}; +use codec::Encode; use sc_client_api::BlockBackend; -use sp_core::Pair; +use sp_core::{Pair, H256}; use sp_inherents::{InherentData, InherentDataProvider}; use sp_keyring::Sr25519Keyring; -use sp_runtime::{generic, OpaqueExtrinsic, SaturatedConversion}; +use sp_runtime::{generic, traits::SignedExtension, OpaqueExtrinsic, SaturatedConversion}; -use codec::Encode; use cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider; +use parachains_common::BlockNumber; use crate::service::ParachainClient; -/// Generates `System::Remark` extrinsics for the benchmarks. -/// -/// Note: Should only be used for benchmarking. -pub struct RemarkBuilder { - client: Arc>, +/// Trait for providing the signed extra for a given runtime. +trait SignedExtraProvider { + fn get_extra(period: u64, best_block: BlockNumber, nonce: u32) -> SignedExtra; + fn get_additional_signed(genesis_hash: H256, best_hash: H256) -> SignedExtra::AdditionalSigned; } -impl RemarkBuilder { - /// Creates a new [`Self`] from the given client. - pub fn new(client: Arc>) -> Self { - Self { client } - } -} +/// Generates the signed extra for the given runtime. +pub struct SignedExtraFor(PhantomData); -impl frame_benchmarking_cli::ExtrinsicBuilder - for RemarkBuilder +impl SignedExtraProvider + for SignedExtraFor { - fn pallet(&self) -> &str { - "system" - } - - fn extrinsic(&self) -> &str { - "remark" - } - - fn build(&self, nonce: u32) -> Result { - use asset_hub_kusama_runtime as runtime; - - let period = runtime::BlockHashCount::get() - .checked_next_power_of_two() - .map(|c| c / 2) - .unwrap_or(2) as u64; - let best_block = self.client.chain_info().best_number; - let tip = 0; - let extra: runtime::SignedExtra = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(generic::Era::mortal( + fn get_extra( + period: u64, + best_block: BlockNumber, + nonce: u32, + ) -> asset_hub_kusama_runtime::SignedExtra { + ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal( period, best_block.saturated_into(), )), - frame_system::CheckNonce::::from(nonce), - frame_system::CheckWeight::::new(), - pallet_asset_tx_payment::ChargeAssetTxPayment::::from(tip, None), - ); - - let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); - let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); - let best_hash = self.client.chain_info().best_hash; - let payload = runtime::SignedPayload::from_raw( - call.clone(), - extra.clone(), - ( - (), - runtime::VERSION.spec_version, - runtime::VERSION.transaction_version, - genesis_hash, - best_hash, - (), - (), - (), - ), - ); - - let sender = Sr25519Keyring::Bob.pair(); - let signature = payload.using_encoded(|x| sender.sign(x)); - let extrinsic = runtime::UncheckedExtrinsic::new_signed( - call, - sp_runtime::AccountId32::from(sender.public()).into(), - parachains_common::Signature::Sr25519(signature), - extra, - ); + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_asset_tx_payment::ChargeAssetTxPayment::::from(0, None), + ) + } - Ok(extrinsic.into()) + fn get_additional_signed( + genesis_hash: H256, + best_hash: H256, + ) -> ::AdditionalSigned { + ( + (), + asset_hub_kusama_runtime::VERSION.spec_version, + asset_hub_kusama_runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ) } } -impl frame_benchmarking_cli::ExtrinsicBuilder - for RemarkBuilder +impl SignedExtraProvider + for SignedExtraFor { - fn pallet(&self) -> &str { - "system" - } - - fn extrinsic(&self) -> &str { - "remark" - } - - fn build(&self, nonce: u32) -> Result { - use asset_hub_westend_runtime as runtime; - - let period = runtime::BlockHashCount::get() - .checked_next_power_of_two() - .map(|c| c / 2) - .unwrap_or(2) as u64; - let best_block = self.client.chain_info().best_number; - let tip = 0; - let extra: runtime::SignedExtra = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(generic::Era::mortal( - period, - best_block.saturated_into(), - )), - frame_system::CheckNonce::::from(nonce), - frame_system::CheckWeight::::new(), - pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::::from( - tip, None, + fn get_extra( + period: u64, + best_block: BlockNumber, + nonce: u32, + ) -> asset_hub_westend_runtime::SignedExtra { + ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from( + generic::Era::mortal(period, best_block.saturated_into()), ), - ); - - let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); - let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); - let best_hash = self.client.chain_info().best_hash; - let payload = runtime::SignedPayload::from_raw( - call.clone(), - extra.clone(), - ( - (), - runtime::VERSION.spec_version, - runtime::VERSION.transaction_version, - genesis_hash, - best_hash, - (), - (), - (), - ), - ); - - let sender = Sr25519Keyring::Bob.pair(); - let signature = payload.using_encoded(|x| sender.sign(x)); - let extrinsic = runtime::UncheckedExtrinsic::new_signed( - call, - sp_runtime::AccountId32::from(sender.public()).into(), - parachains_common::Signature::Sr25519(signature), - extra, - ); + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::< + asset_hub_westend_runtime::Runtime, + >::from(0, None), + ) + } - Ok(extrinsic.into()) + fn get_additional_signed( + genesis_hash: H256, + best_hash: H256, + ) -> ::AdditionalSigned { + ( + (), + asset_hub_westend_runtime::VERSION.spec_version, + asset_hub_westend_runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ) } } -impl frame_benchmarking_cli::ExtrinsicBuilder - for RemarkBuilder +impl SignedExtraProvider + for SignedExtraFor { - fn pallet(&self) -> &str { - "system" - } - - fn extrinsic(&self) -> &str { - "remark" - } - - fn build(&self, nonce: u32) -> Result { - use asset_hub_polkadot_runtime as runtime; - - let period = runtime::BlockHashCount::get() - .checked_next_power_of_two() - .map(|c| c / 2) - .unwrap_or(2) as u64; - let best_block = self.client.chain_info().best_number; - let tip = 0; - let extra: runtime::SignedExtra = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(generic::Era::mortal( - period, - best_block.saturated_into(), - )), - frame_system::CheckNonce::::from(nonce), - frame_system::CheckWeight::::new(), - pallet_asset_tx_payment::ChargeAssetTxPayment::::from(tip, None), - ); - - let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); - let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); - let best_hash = self.client.chain_info().best_hash; - let payload = runtime::SignedPayload::from_raw( - call.clone(), - extra.clone(), - ( - (), - runtime::VERSION.spec_version, - runtime::VERSION.transaction_version, - genesis_hash, - best_hash, - (), - (), - (), + fn get_extra( + period: u64, + best_block: BlockNumber, + nonce: u32, + ) -> asset_hub_polkadot_runtime::SignedExtra { + ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from( + generic::Era::mortal(period, best_block.saturated_into()), ), - ); - - let sender = Sr25519Keyring::Bob.pair(); - let signature = payload.using_encoded(|x| sender.sign(x)); - let extrinsic = runtime::UncheckedExtrinsic::new_signed( - call, - sp_runtime::AccountId32::from(sender.public()).into(), - parachains_common::Signature::Sr25519(signature), - extra, - ); + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_asset_tx_payment::ChargeAssetTxPayment::::from(0, None), + ) + } - Ok(extrinsic.into()) + fn get_additional_signed( + genesis_hash: H256, + best_hash: H256, + ) -> ::AdditionalSigned { + ( + (), + asset_hub_polkadot_runtime::VERSION.spec_version, + asset_hub_polkadot_runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ) } } -impl frame_benchmarking_cli::ExtrinsicBuilder - for RemarkBuilder +impl SignedExtraProvider + for SignedExtraFor { - fn pallet(&self) -> &str { - "system" - } - - fn extrinsic(&self) -> &str { - "remark" - } - - fn build(&self, nonce: u32) -> Result { - use collectives_polkadot_runtime as runtime; - - let period = runtime::BlockHashCount::get() - .checked_next_power_of_two() - .map(|c| c / 2) - .unwrap_or(2) as u64; - let best_block = self.client.chain_info().best_number; - let extra: runtime::SignedExtra = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(generic::Era::mortal( - period, - best_block.saturated_into(), - )), - frame_system::CheckNonce::::from(nonce), - frame_system::CheckWeight::::new(), - ); - - let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); - let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); - let best_hash = self.client.chain_info().best_hash; - let payload = runtime::SignedPayload::from_raw( - call.clone(), - extra.clone(), - ( - (), - runtime::VERSION.spec_version, - runtime::VERSION.transaction_version, - genesis_hash, - best_hash, - (), - (), + fn get_extra( + period: u64, + best_block: BlockNumber, + nonce: u32, + ) -> collectives_polkadot_runtime::SignedExtra { + ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from( + generic::Era::mortal(period, best_block.saturated_into()), ), - ); - - let sender = Sr25519Keyring::Bob.pair(); - let signature = payload.using_encoded(|x| sender.sign(x)); - let extrinsic = runtime::UncheckedExtrinsic::new_signed( - call, - sp_runtime::AccountId32::from(sender.public()).into(), - parachains_common::Signature::Sr25519(signature), - extra, - ); + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + ) + } - Ok(extrinsic.into()) + fn get_additional_signed( + genesis_hash: H256, + best_hash: H256, + ) -> ::AdditionalSigned { + ( + (), + collectives_polkadot_runtime::VERSION.spec_version, + collectives_polkadot_runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + ) } } -impl frame_benchmarking_cli::ExtrinsicBuilder - for RemarkBuilder +impl SignedExtraProvider + for SignedExtraFor { - fn pallet(&self) -> &str { - "system" + fn get_extra( + period: u64, + best_block: BlockNumber, + nonce: u32, + ) -> bridge_hub_polkadot_runtime::SignedExtra { + ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from( + generic::Era::mortal(period, best_block.saturated_into()), + ), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::< + bridge_hub_polkadot_runtime::Runtime, + >::from(0), + ) } - fn extrinsic(&self) -> &str { - "remark" + fn get_additional_signed( + genesis_hash: H256, + best_hash: H256, + ) -> ::AdditionalSigned { + ( + (), + bridge_hub_polkadot_runtime::VERSION.spec_version, + bridge_hub_polkadot_runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ) } +} - fn build(&self, nonce: u32) -> Result { - use bridge_hub_polkadot_runtime as runtime; - - let period = runtime::BlockHashCount::get() - .checked_next_power_of_two() - .map(|c| c / 2) - .unwrap_or(2) as u64; - let best_block = self.client.chain_info().best_number; - let extra: runtime::SignedExtra = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(generic::Era::mortal( - period, - best_block.saturated_into(), - )), - frame_system::CheckNonce::::from(nonce), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(0), - ); - - let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); - let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); - let best_hash = self.client.chain_info().best_hash; - let payload = runtime::SignedPayload::from_raw( - call.clone(), - extra.clone(), - ( - (), - runtime::VERSION.spec_version, - runtime::VERSION.transaction_version, - genesis_hash, - best_hash, - (), - (), - (), +impl SignedExtraProvider + for SignedExtraFor +{ + fn get_extra( + period: u64, + best_block: BlockNumber, + nonce: u32, + ) -> bridge_hub_kusama_runtime::SignedExtra { + ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from( + generic::Era::mortal(period, best_block.saturated_into()), ), - ); - - let sender = Sr25519Keyring::Bob.pair(); - let signature = payload.using_encoded(|x| sender.sign(x)); - let extrinsic = runtime::UncheckedExtrinsic::new_signed( - call, - sp_runtime::AccountId32::from(sender.public()).into(), - parachains_common::Signature::Sr25519(signature), - extra, - ); + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::< + bridge_hub_kusama_runtime::Runtime, + >::from(0), + ) + } - Ok(extrinsic.into()) + fn get_additional_signed( + genesis_hash: H256, + best_hash: H256, + ) -> ::AdditionalSigned { + ( + (), + bridge_hub_kusama_runtime::VERSION.spec_version, + bridge_hub_kusama_runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ) } } -impl frame_benchmarking_cli::ExtrinsicBuilder - for RemarkBuilder +impl SignedExtraProvider + for SignedExtraFor { - fn pallet(&self) -> &str { - "system" + fn get_extra( + period: u64, + best_block: BlockNumber, + nonce: u32, + ) -> bridge_hub_rococo_runtime::SignedExtra { + ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from( + generic::Era::mortal(period, best_block.saturated_into()), + ), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(0), + bridge_hub_rococo_runtime::BridgeRejectObsoleteHeadersAndMessages {}, + ( + bridge_hub_rococo_runtime::bridge_hub_wococo_config::BridgeRefundBridgeHubRococoMessages::default(), + bridge_hub_rococo_runtime::bridge_hub_rococo_config::BridgeRefundBridgeHubWococoMessages::default(), + ), + ) } - fn extrinsic(&self) -> &str { - "remark" + fn get_additional_signed( + genesis_hash: H256, + best_hash: H256, + ) -> ::AdditionalSigned { + ( + (), + bridge_hub_rococo_runtime::VERSION.spec_version, + bridge_hub_rococo_runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + (), + ((), ()), + ) } +} - fn build(&self, nonce: u32) -> Result { - use bridge_hub_kusama_runtime as runtime; - - let period = runtime::BlockHashCount::get() - .checked_next_power_of_two() - .map(|c| c / 2) - .unwrap_or(2) as u64; - let best_block = self.client.chain_info().best_number; - let extra: runtime::SignedExtra = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(generic::Era::mortal( - period, - best_block.saturated_into(), - )), - frame_system::CheckNonce::::from(nonce), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(0), - ); - - let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); - let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); - let best_hash = self.client.chain_info().best_hash; - let payload = runtime::SignedPayload::from_raw( - call.clone(), - extra.clone(), - ( - (), - runtime::VERSION.spec_version, - runtime::VERSION.transaction_version, - genesis_hash, - best_hash, - (), - (), - (), - ), - ); - - let sender = Sr25519Keyring::Bob.pair(); - let signature = payload.using_encoded(|x| sender.sign(x)); - let extrinsic = runtime::UncheckedExtrinsic::new_signed( - call, - sp_runtime::AccountId32::from(sender.public()).into(), - parachains_common::Signature::Sr25519(signature), - extra, - ); +/// Generates `System::Remark` extrinsics for the benchmarks. +/// +/// Note: Should only be used for benchmarking. +pub struct RemarkBuilder { + client: Arc>, + _phantom: PhantomData<(SignedExtra, RuntimeCall, Extra, SystemConfig)>, +} - Ok(extrinsic.into()) +impl + RemarkBuilder +{ + /// Creates a new [`Self`] from the given client. + pub fn new(client: Arc>) -> Self { + Self { client, _phantom: PhantomData } } } -impl frame_benchmarking_cli::ExtrinsicBuilder - for RemarkBuilder +impl + frame_benchmarking_cli::ExtrinsicBuilder + for RemarkBuilder +where + SystemConfig: frame_system::Config, + SignedExtra: Clone, + RuntimeCall: From> + Clone + Encode, + SignedExtra: SignedExtension, + Extra: SignedExtraProvider, { fn pallet(&self) -> &str { "system" @@ -440,57 +358,27 @@ impl frame_benchmarking_cli::ExtrinsicBuilder } fn build(&self, nonce: u32) -> Result { - use bridge_hub_rococo_runtime as runtime; - - let period = runtime::BlockHashCount::get() + let period = polkadot_runtime_common::BlockHashCount::get() .checked_next_power_of_two() .map(|c| c / 2) .unwrap_or(2) as u64; let best_block = self.client.chain_info().best_number; - let extra: runtime::SignedExtra = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(generic::Era::mortal( - period, - best_block.saturated_into(), - )), - frame_system::CheckNonce::::from(nonce), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(0), - bridge_hub_rococo_runtime::BridgeRejectObsoleteHeadersAndMessages {}, - ( - bridge_hub_rococo_runtime::bridge_hub_wococo_config::BridgeRefundBridgeHubRococoMessages::default(), - bridge_hub_rococo_runtime::bridge_hub_rococo_config::BridgeRefundBridgeHubWococoMessages::default(), - ), - ); + let extra = Extra::get_extra(period, best_block, nonce); - let call: runtime::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); + let call: RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); let best_hash = self.client.chain_info().best_hash; - let payload = runtime::SignedPayload::from_raw( - call.clone(), + let payload = generic::SignedPayload::::from_raw( + call.clone().into(), extra.clone(), - ( - (), - runtime::VERSION.spec_version, - runtime::VERSION.transaction_version, - genesis_hash, - best_hash, - (), - (), - (), - (), - ((), ()), - ), + Extra::get_additional_signed(genesis_hash, best_hash), ); let sender = Sr25519Keyring::Bob.pair(); let signature = payload.using_encoded(|x| sender.sign(x)); - let extrinsic = runtime::UncheckedExtrinsic::new_signed( + let extrinsic = generic::UncheckedExtrinsic::new_signed( call, - sp_runtime::AccountId32::from(sender.public()).into(), + sp_runtime::AccountId32::from(sender.public()), parachains_common::Signature::Sr25519(signature), extra, ); diff --git a/polkadot-parachain/src/command.rs b/polkadot-parachain/src/command.rs index 71fdc0a7d54..bde5d94053b 100644 --- a/polkadot-parachain/src/command.rs +++ b/polkadot-parachain/src/command.rs @@ -15,7 +15,7 @@ // along with Cumulus. If not, see . use crate::{ - benchmarking::{inherent_benchmark_data, RemarkBuilder}, + benchmarking::{inherent_benchmark_data, RemarkBuilder, SignedExtraFor}, chain_spec, cli::{Cli, RelayChainCli, Subcommand}, service::new_partial, @@ -383,24 +383,27 @@ impl SubstrateCli for RelayChainCli { /// Creates partial components for the runtimes that are supported by the benchmarks. macro_rules! construct_benchmark_partials { - ($config:expr, |$partials:ident| $code:expr) => { + ($config:expr, |$partials:ident, $runtime:ident| $code:expr) => { match $config.chain_spec.runtime() { Runtime::AssetHubKusama => { - let $partials = new_partial::( + use asset_hub_kusama_runtime as $runtime; + let $partials = new_partial::<$runtime::RuntimeApi, _>( &$config, crate::service::aura_build_import_queue::<_, AuraId>, )?; $code }, Runtime::AssetHubWestend => { - let $partials = new_partial::( + use asset_hub_westend_runtime as $runtime; + let $partials = new_partial::<$runtime::RuntimeApi, _>( &$config, crate::service::aura_build_import_queue::<_, AuraId>, )?; $code }, Runtime::AssetHubPolkadot => { - let $partials = new_partial::( + use asset_hub_polkadot_runtime as $runtime; + let $partials = new_partial::<$runtime::RuntimeApi, _>( &$config, crate::service::aura_build_import_queue::<_, AssetHubPolkadotAuraId>, )?; @@ -410,6 +413,8 @@ macro_rules! construct_benchmark_partials { chain_spec::bridge_hubs::BridgeHubRuntimeType::Polkadot | chain_spec::bridge_hubs::BridgeHubRuntimeType::PolkadotLocal | chain_spec::bridge_hubs::BridgeHubRuntimeType::PolkadotDevelopment => { + #[allow(unused_imports)] + use bridge_hub_polkadot_runtime as $runtime; let $partials = new_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, @@ -419,6 +424,8 @@ macro_rules! construct_benchmark_partials { chain_spec::bridge_hubs::BridgeHubRuntimeType::Kusama | chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaLocal | chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaDevelopment => { + #[allow(unused_imports)] + use bridge_hub_kusama_runtime as $runtime; let $partials = new_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, @@ -426,6 +433,8 @@ macro_rules! construct_benchmark_partials { $code }, chain_spec::bridge_hubs::BridgeHubRuntimeType::Westend => { + #[allow(unused_imports)] + use bridge_hub_kusama_runtime as $runtime; let $partials = new_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, @@ -435,6 +444,8 @@ macro_rules! construct_benchmark_partials { chain_spec::bridge_hubs::BridgeHubRuntimeType::Rococo | chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoLocal | chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoDevelopment => { + #[allow(unused_imports)] + use bridge_hub_rococo_runtime as $runtime; let $partials = new_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, @@ -443,6 +454,8 @@ macro_rules! construct_benchmark_partials { }, chain_spec::bridge_hubs::BridgeHubRuntimeType::Wococo | chain_spec::bridge_hubs::BridgeHubRuntimeType::WococoLocal => { + #[allow(unused_imports)] + use bridge_hub_rococo_runtime as $runtime; let $partials = new_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, @@ -451,7 +464,8 @@ macro_rules! construct_benchmark_partials { }, }, Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => { - let $partials = new_partial::( + use collectives_polkadot_runtime as $runtime; + let $partials = new_partial::<$runtime::RuntimeApi, _>( &$config, crate::service::aura_build_import_queue::<_, AuraId>, )?; @@ -460,6 +474,9 @@ macro_rules! construct_benchmark_partials { _ => Err("The chain is not supported".into()), } }; + ($config:expr, |$partials:ident| $code:expr) => { + construct_benchmark_partials!($config, |$partials, runtime| $code) + }; } macro_rules! construct_async_run { @@ -720,8 +737,14 @@ pub fn run() -> Result<()> { }) }), BenchmarkCmd::Overhead(cmd) => runner.sync_run(|config| { - construct_benchmark_partials!(config, |partials| { - let ext_builder = RemarkBuilder::new(partials.client.clone()); + construct_benchmark_partials!(config, |partials, runtime| { + let ext_builder = RemarkBuilder::< + runtime::RuntimeApi, + runtime::SignedExtra, + runtime::RuntimeCall, + SignedExtraFor, + runtime::Runtime, + >::new(partials.client.clone()); cmd.run( config, From 9db08590ea517f4ee382dfe819ca9db79c5ad587 Mon Sep 17 00:00:00 2001 From: kalaninja Date: Sun, 23 Jul 2023 17:58:42 +0700 Subject: [PATCH 4/4] fix test --- polkadot-parachain/src/benchmarking.rs | 48 +++++++++++++++----------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/polkadot-parachain/src/benchmarking.rs b/polkadot-parachain/src/benchmarking.rs index 7ad1e8e1c60..3f274a42a08 100644 --- a/polkadot-parachain/src/benchmarking.rs +++ b/polkadot-parachain/src/benchmarking.rs @@ -21,7 +21,11 @@ use sc_client_api::BlockBackend; use sp_core::{Pair, H256}; use sp_inherents::{InherentData, InherentDataProvider}; use sp_keyring::Sr25519Keyring; -use sp_runtime::{generic, traits::SignedExtension, OpaqueExtrinsic, SaturatedConversion}; +use sp_runtime::{ + generic::{Era, SignedPayload, UncheckedExtrinsic}, + traits::SignedExtension, + MultiAddress, OpaqueExtrinsic, SaturatedConversion, +}; use cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider; use parachains_common::BlockNumber; @@ -50,7 +54,7 @@ impl SignedExtraProvider frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(generic::Era::mortal( + frame_system::CheckEra::::from(Era::mortal( period, best_block.saturated_into(), )), @@ -90,9 +94,10 @@ impl SignedExtraProvider frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from( - generic::Era::mortal(period, best_block.saturated_into()), - ), + frame_system::CheckEra::::from(Era::mortal( + period, + best_block.saturated_into(), + )), frame_system::CheckNonce::::from(nonce), frame_system::CheckWeight::::new(), pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::< @@ -132,7 +137,7 @@ impl SignedExtraProvider frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), frame_system::CheckEra::::from( - generic::Era::mortal(period, best_block.saturated_into()), + Era::mortal(period, best_block.saturated_into()), ), frame_system::CheckNonce::::from(nonce), frame_system::CheckWeight::::new(), @@ -170,9 +175,10 @@ impl SignedExtraProvider frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from( - generic::Era::mortal(period, best_block.saturated_into()), - ), + frame_system::CheckEra::::from(Era::mortal( + period, + best_block.saturated_into(), + )), frame_system::CheckNonce::::from(nonce), frame_system::CheckWeight::::new(), ) @@ -207,9 +213,10 @@ impl SignedExtraProvider frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from( - generic::Era::mortal(period, best_block.saturated_into()), - ), + frame_system::CheckEra::::from(Era::mortal( + period, + best_block.saturated_into(), + )), frame_system::CheckNonce::::from(nonce), frame_system::CheckWeight::::new(), pallet_transaction_payment::ChargeTransactionPayment::< @@ -248,9 +255,10 @@ impl SignedExtraProvider frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from( - generic::Era::mortal(period, best_block.saturated_into()), - ), + frame_system::CheckEra::::from(Era::mortal( + period, + best_block.saturated_into(), + )), frame_system::CheckNonce::::from(nonce), frame_system::CheckWeight::::new(), pallet_transaction_payment::ChargeTransactionPayment::< @@ -290,7 +298,7 @@ impl SignedExtraProvider frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), frame_system::CheckEra::::from( - generic::Era::mortal(period, best_block.saturated_into()), + Era::mortal(period, best_block.saturated_into()), ), frame_system::CheckNonce::::from(nonce), frame_system::CheckWeight::::new(), @@ -368,17 +376,17 @@ where let call: RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); let best_hash = self.client.chain_info().best_hash; - let payload = generic::SignedPayload::::from_raw( - call.clone().into(), + let payload = SignedPayload::::from_raw( + call.clone(), extra.clone(), Extra::get_additional_signed(genesis_hash, best_hash), ); let sender = Sr25519Keyring::Bob.pair(); let signature = payload.using_encoded(|x| sender.sign(x)); - let extrinsic = generic::UncheckedExtrinsic::new_signed( + let extrinsic = UncheckedExtrinsic::, _, _, _>::new_signed( call, - sp_runtime::AccountId32::from(sender.public()), + sp_runtime::AccountId32::from(sender.public()).into(), parachains_common::Signature::Sr25519(signature), extra, );