Skip to content

Commit

Permalink
wip benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Supremesource committed Dec 2, 2024
1 parent cf4411a commit fc04b42
Show file tree
Hide file tree
Showing 13 changed files with 548 additions and 296 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ try-runtime-upgrade-devnet:
run-benchmarking:
cargo build -r --features runtime-benchmarks
./target/release/node-subspace build-spec --disable-default-bootnode --chain local > specs/benchmarks.json
./target/release/node-subspace benchmark pallet --chain specs/benchmarks.json --pallet pallet_subspace --extrinsic "*" --steps 50 --repeat 20 --output pallets/subspace/src/weights.rs --template=./.maintain/frame-weight-template.hbs
./target/release/node-subspace benchmark pallet --chain specs/benchmarks.json --pallet pallet_governance --extrinsic "*" --steps 50 --repeat 20 --output pallets/governance/src/weights.rs --template=./.maintain/frame-weight-template.hbs
./target/release/node-subspace benchmark pallet --chain specs/benchmarks.json --pallet pallet_subnet_emission --extrinsic "*" --steps 50 --repeat 20 --output pallets/subnet_emission/src/weights.rs --template=./.maintain/frame-weight-template.hbs
./target/release/node-subspace benchmark pallet --chain specs/local.json --pallet pallet_subspace --extrinsic "*" --steps 50 --repeat 20 --output pallets/subspace/src/weights.rs --template=./.maintain/frame-weight-template.hbs
./target/release/node-subspace benchmark pallet --chain specs/local.json --pallet pallet_governance --extrinsic "*" --steps 50 --repeat 20 --output pallets/governance/src/weights.rs --template=./.maintain/frame-weight-template.hbs
./target/release/node-subspace benchmark pallet --chain specs/local.json --pallet pallet_subnet_emission --extrinsic "*" --steps 50 --repeat 20 --output pallets/subnet_emission/src/weights.rs --template=./.maintain/frame-weight-template.hbs

specs/mainnet-copy.json:
$(PYTHON) scripts/snapshots/builder.py -o specs/mainnet-copy.json
Expand Down
2 changes: 1 addition & 1 deletion node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use sp_runtime::{generic::Era, OpaqueExtrinsic, SaturatedConversion};
use node_subspace_runtime::{self as runtime, AccountId, Balance, BalancesCall, SystemCall};
use sp_runtime::MultiAddress;

use crate::client::WasmClient as Client;
use crate::client::Client;

/// Generates extrinsics for the `benchmark overhead` command.
///
Expand Down
17 changes: 10 additions & 7 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl SubstrateCli for Cli {

fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
"local" => Box::new(chain_spec::generate_config("./specs/local.json")?),
"local" | "dev" => Box::new(chain_spec::generate_config("./specs/local.json")?),
"test" => Box::new(chain_spec::ChainSpec::from_json_bytes(
include_bytes!("../chain-specs/test.json").as_ref(),
)?),
Expand Down Expand Up @@ -236,10 +236,13 @@ pub fn run() -> sc_cli::Result<()> {

let runner = cli.create_runner(cmd)?;
match cmd {
BenchmarkCmd::Pallet(cmd) => runner
.sync_run(|config| cmd.run_with_spec::<Hashing, ()>(Some(config.chain_spec))),
BenchmarkCmd::Pallet(cmd) => runner.sync_run(|config| {
cmd.run_with_spec::<Hashing, crate::client::HostFunctions>(Some(
config.chain_spec,
))
}),
BenchmarkCmd::Block(cmd) => runner.sync_run(|mut config| {
let PartialComponents { client, .. } = service::new_chain_ops(config, cli.eth)?;
let PartialComponents { client, .. } = service::new_chain_ops(config)?;
cmd.run(client)
}),
BenchmarkCmd::Storage(cmd) => runner.sync_run(|mut config| {
Expand All @@ -248,7 +251,7 @@ pub fn run() -> sc_cli::Result<()> {
backend,
other: Other { config, .. },
..
} = service::new_chain_ops(config, cli.eth)?;
} = service::new_chain_ops(config)?;

let db = backend.expose_db();
let storage = backend.expose_storage();
Expand All @@ -259,7 +262,7 @@ pub fn run() -> sc_cli::Result<()> {
client,
other: Other { config, .. },
..
} = service::new_chain_ops(config, cli.eth)?;
} = service::new_chain_ops(config)?;

let ext_builder = RemarkBuilder::new(client.clone());
cmd.run(
Expand All @@ -271,7 +274,7 @@ pub fn run() -> sc_cli::Result<()> {
)
}),
BenchmarkCmd::Extrinsic(cmd) => runner.sync_run(|mut config| {
let PartialComponents { client, .. } = service::new_chain_ops(config, cli.eth)?;
let PartialComponents { client, .. } = service::new_chain_ops(config)?;

// Register the *Remark* and *TKA* builders.
let ext_factory = ExtrinsicFactory(vec![
Expand Down
3 changes: 2 additions & 1 deletion pallets/governance/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ benchmarks! {
params.max_allowed_modules, // max_allowed_modules: max number of modules allowed per subnet
params.max_registrations_per_block, // max_registrations_per_block: max number of registrations per block
params.max_allowed_weights, // max_allowed_weights: max number of weights per module
params.floor_delegation_fee, // floor_delegation_fee: min delegation fee
params.floor_stake_delegation_fee, // floor_delegation_fee: min delegation fee
params.floor_validator_weight_fee, // floor_validator_weight_fee: min validator weight fee
params.floor_founder_share, // floor_founder_share: min founder share
params.min_weight_stake, // min_weight_stake: min weight stake required
params.curator, // curator: subnet 0 dao multisig
Expand Down
Loading

0 comments on commit fc04b42

Please sign in to comment.