Skip to content

Commit b2be21f

Browse files
committed
feat: sort pallets and extrinsics in alphebetical order
1 parent e4eb96a commit b2be21f

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

crates/pop-cli/src/commands/bench/pallet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use pop_parachains::{
2121
PalletExtrinsicsRegistry, GENESIS_BUILDER_DEV_PRESET,
2222
};
2323
use std::{
24-
collections::HashMap,
24+
collections::BTreeMap,
2525
env::current_dir,
2626
path::{Path, PathBuf},
2727
};
@@ -240,7 +240,7 @@ impl BenchmarkPallet {
240240
self.all = false;
241241
}
242242

243-
let mut registry: PalletExtrinsicsRegistry = HashMap::default();
243+
let mut registry: PalletExtrinsicsRegistry = BTreeMap::default();
244244

245245
cli.intro(if self.list {
246246
"Listing available pallets and extrinsics"

crates/pop-cli/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ mod cli;
1919
mod commands;
2020
mod common;
2121
mod style;
22-
mod wallet_integration;
22+
#[cfg(feature = "telemetry")]
2323
use tracing_subscriber::EnvFilter;
24+
mod wallet_integration;
2425

2526
#[tokio::main]
2627
async fn main() -> Result<()> {

crates/pop-parachains/src/bench/mod.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use frame_benchmarking_cli::PalletCmd;
66
use sc_chain_spec::GenesisConfigBuilderRuntimeCaller;
77
use sp_runtime::traits::BlakeTwo256;
88
use std::{
9-
collections::HashMap,
9+
collections::BTreeMap,
1010
fmt::Display,
1111
fs::{self, File},
1212
io::Read,
@@ -32,7 +32,7 @@ type HostFunctions = (
3232

3333
/// Type alias for records where the key is the pallet name and the value is an array of its
3434
/// extrinsics.
35-
pub type PalletExtrinsicsRegistry = HashMap<String, Vec<String>>;
35+
pub type PalletExtrinsicsRegistry = BTreeMap<String, Vec<String>>;
3636

3737
/// How the genesis state for benchmarking should be built.
3838
#[derive(clap::ValueEnum, Debug, Eq, PartialEq, Clone, Copy, EnumIter, EnumMessageDerive)]
@@ -179,6 +179,11 @@ fn process_pallet_extrinsics(output_file: PathBuf) -> anyhow::Result<PalletExtri
179179
let extrinsic = record[1].trim().to_string();
180180
registry.entry(pallet).or_default().push(extrinsic);
181181
}
182+
183+
// Sort the extrinsics by alphabetical order for each pallet.
184+
for extrinsics in registry.values_mut() {
185+
extrinsics.sort();
186+
}
182187
Ok(registry)
183188
}
184189

@@ -253,6 +258,21 @@ mod tests {
253258
binary.source(false, &(), true).await?;
254259

255260
let registry = load_pallet_extrinsics(&runtime_path, &binary.path()).await?;
261+
let pallets: Vec<String> = registry.keys().map(|k| k.clone()).collect();
262+
assert_eq!(
263+
pallets,
264+
vec![
265+
"cumulus_pallet_parachain_system",
266+
"cumulus_pallet_xcmp_queue",
267+
"frame_system",
268+
"pallet_balances",
269+
"pallet_collator_selection",
270+
"pallet_message_queue",
271+
"pallet_session",
272+
"pallet_sudo",
273+
"pallet_timestamp"
274+
]
275+
);
256276
assert_eq!(
257277
registry.get("pallet_timestamp").cloned().unwrap_or_default(),
258278
["on_finalize", "set"]

0 commit comments

Comments
 (0)