Skip to content

Commit 865e7cd

Browse files
authored
Merge pull request #25 from paritytech/bko-benchmarking
Fixing runtime-benchmarks
2 parents 62e97bf + a140f71 commit 865e7cd

File tree

4 files changed

+43
-11
lines changed

4 files changed

+43
-11
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/src/command.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ pub fn run() -> sc_cli::Result<()> {
143143
service::new_partial(&config)?;
144144
let db = backend.expose_db();
145145
let storage = backend.expose_storage();
146+
let shared_cache = backend.expose_shared_trie_cache();
146147

147-
cmd.run(config, client, db, storage)
148+
cmd.run(config, client, db, storage, shared_cache)
148149
},
149150
BenchmarkCmd::Overhead(cmd) => {
150151
let PartialComponents { client, .. } = service::new_partial(&config)?;

runtime/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ sp-std = { default-features = false, git = "https://github.com/paritytech/polkad
4444
sp-transaction-pool = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
4545
sp-transaction-storage-proof = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
4646
sp-version = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
47+
sp-storage = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
4748

4849
# Used for the node's RPCs
4950
frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
@@ -79,6 +80,12 @@ xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-
7980
xcm-builder = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", package = "staging-xcm-builder" }
8081
xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", package = "staging-xcm-executor" }
8182

83+
# TODO: just to pass `--features runtime-benchmarks`
84+
pallet-xcm = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
85+
pallet-staking = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
86+
sp-staking = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
87+
parachains-common = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
88+
8289
[build-dependencies]
8390
substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", optional = true }
8491

@@ -156,7 +163,12 @@ std = [
156163
"xcm/std",
157164

158165
"pallet-bridge-relayers/std",
166+
"pallet-staking?/std",
167+
"pallet-xcm?/std",
168+
"parachains-common?/std",
159169
"sp-genesis-builder/std",
170+
"sp-staking?/std",
171+
"sp-storage?/std",
160172
"substrate-wasm-builder",
161173
]
162174
runtime-benchmarks = [
@@ -168,6 +180,7 @@ runtime-benchmarks = [
168180
"pallet-sudo/runtime-benchmarks",
169181
"pallet-timestamp/runtime-benchmarks",
170182
"sp-runtime/runtime-benchmarks",
183+
"sp-storage",
171184

172185
"frame-benchmarking/runtime-benchmarks",
173186
"frame-system-benchmarking/runtime-benchmarks",
@@ -188,6 +201,11 @@ runtime-benchmarks = [
188201
"xcm-builder/runtime-benchmarks",
189202
"xcm-executor/runtime-benchmarks",
190203
"xcm/runtime-benchmarks",
204+
205+
"pallet-staking/runtime-benchmarks",
206+
"pallet-xcm/runtime-benchmarks",
207+
"parachains-common/runtime-benchmarks",
208+
"sp-staking/runtime-benchmarks",
191209
]
192210
try-runtime = [
193211
"frame-executive/try-runtime",
@@ -209,10 +227,13 @@ try-runtime = [
209227

210228
"pallet-bridge-relayers/try-runtime",
211229
"pallet-relayer-set/try-runtime",
230+
"pallet-staking?/try-runtime",
212231
"pallet-transaction-payment/try-runtime",
213232
"pallet-transaction-storage/try-runtime",
214233
"pallet-validator-set/try-runtime",
234+
"pallet-xcm?/try-runtime",
215235
"pallets-common/try-runtime",
236+
"parachains-common?/try-runtime",
216237
"sp-runtime/try-runtime",
217238
]
218239
rococo = []

runtime/src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ impl pallet_timestamp::Config for Runtime {
335335
type WeightInfo = ();
336336
}
337337

338+
// TODO: remove sudo before go live
338339
impl pallet_sudo::Config for Runtime {
339340
type RuntimeEvent = RuntimeEvent;
340341
type RuntimeCall = RuntimeCall;
@@ -592,22 +593,22 @@ pub type Executive = frame_executive::Executive<
592593
AllPalletsWithSystem,
593594
>;
594595

595-
#[cfg(feature = "runtime-benchmarks")]
596-
#[macro_use]
597-
extern crate frame_benchmarking;
598-
599596
#[cfg(feature = "runtime-benchmarks")]
600597
mod benches {
601-
define_benchmarks!(
598+
frame_benchmarking::define_benchmarks!(
602599
[frame_benchmarking, BaselineBench::<Runtime>]
603600
[frame_system, SystemBench::<Runtime>]
604601
[pallet_timestamp, Timestamp]
605602
[pallet_sudo, Sudo]
606603
[pallet_transaction_storage, TransactionStorage]
607604
[pallet_validator_set, ValidatorSet]
608-
[pallet_bridge_grandpa, BridgePolkadotGrandpa]
609-
[pallet_bridge_parachains, BridgeParachainsBench::<Runtime, bridge_config::WithPolkadotBridgeParachainsInstance>]
610-
[pallet_bridge_messages, BridgeMessagesBench::<Runtime, bridge_config::WithBridgeHubPolkadotMessagesInstance>]
605+
// TODO: Rococo vs Polkadot https://github.com/paritytech/polkadot-bulletin-chain/issues/22
606+
[pallet_bridge_grandpa, BridgeRococoGrandpa]
607+
// [pallet_bridge_parachains, BridgeParachainsBench::<Runtime, bridge_config::WithRococoBridgeParachainsInstance>]
608+
// [pallet_bridge_messages, BridgeMessagesBench::<Runtime, bridge_config::WithBridgeHubRococoMessagesInstance>]
609+
// [pallet_bridge_grandpa, BridgePolkadotGrandpa]
610+
// [pallet_bridge_parachains, BridgeParachainsBench::<Runtime, bridge_config::WithPolkadotBridgeParachainsInstance>]
611+
// [pallet_bridge_messages, BridgeMessagesBench::<Runtime, bridge_config::WithBridgeHubPolkadotMessagesInstance>]
611612
[pallet_relayer_set, RelayerSet]
612613
);
613614
}
@@ -866,10 +867,12 @@ impl_runtime_apis! {
866867
(list, storage_info)
867868
}
868869

870+
#[allow(non_local_definitions)]
869871
fn dispatch_benchmark(
870872
config: frame_benchmarking::BenchmarkConfig
871-
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
872-
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, TrackedStorageKey};
873+
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
874+
use sp_storage::TrackedStorageKey;
875+
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch};
873876

874877
use frame_system_benchmarking::Pallet as SystemBench;
875878
use baseline::Pallet as BaselineBench;

0 commit comments

Comments
 (0)