From db08ac124eb5fb95323b38fb0c4a56cb32326ce2 Mon Sep 17 00:00:00 2001 From: Georgy Shepelev Date: Fri, 17 Jan 2025 11:27:11 +0400 Subject: [PATCH] chore(benchmarks): Implement new Substrate-approach to build the genesis (#4439) --- Cargo.lock | 6 +- Cargo.toml | 3 +- gsdk/Cargo.toml | 2 +- node/service/Cargo.toml | 2 +- node/service/src/chain_spec/mod.rs | 17 -- node/service/src/chain_spec/vara.rs | 164 +-------------- runtime/vara/Cargo.toml | 10 +- runtime/vara/src/genesis_config_presets.rs | 221 +++++++++++++++++++++ runtime/vara/src/lib.rs | 26 +-- scripts/benchmarking/run_all_benchmarks.sh | 30 ++- utils/cargo-gbuild/Cargo.toml | 2 +- utils/gring/Cargo.toml | 2 +- utils/regression-analysis/Cargo.toml | 2 +- 13 files changed, 279 insertions(+), 208 deletions(-) create mode 100644 runtime/vara/src/genesis_config_presets.rs diff --git a/Cargo.lock b/Cargo.lock index f29fabb853d..556875ab557 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15482,9 +15482,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.129" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbcf9b78a125ee667ae19388837dd12294b858d101fdd393cb9d5501ef09eb2" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", @@ -18810,11 +18810,13 @@ dependencies = [ "pallet-whitelist", "parity-scale-codec", "scale-info", + "serde_json", "sp-api 34.0.0 (git+https://github.com/gear-tech/polkadot-sdk.git?branch=gear-polkadot-stable2409)", "sp-arithmetic 26.0.0 (git+https://github.com/gear-tech/polkadot-sdk.git?branch=gear-polkadot-stable2409)", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", + "sp-consensus-grandpa", "sp-core 34.0.0 (git+https://github.com/gear-tech/polkadot-sdk.git?branch=gear-polkadot-stable2409)", "sp-externalities 0.29.0 (git+https://github.com/gear-tech/polkadot-sdk.git?branch=gear-polkadot-stable2409)", "sp-genesis-builder", diff --git a/Cargo.toml b/Cargo.toml index 0290b9b28b9..f2d6cf9ba36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -165,7 +165,7 @@ region = "3.0.2" reqwest = { version = "0.12.8", default-features = false } scale-info = { version = "2.5.0", default-features = false } serde = { version = "^1", default-features = false } -serde_json = "^1" +serde_json = { version = "1.0.135", default-features = false, features = ["alloc"] } serde_yaml = "0.8.26" sha-1 = "0.10.1" static_init = "1.0.3" @@ -285,7 +285,6 @@ pallet-gear-bank = { path = "pallets/gear-bank", default-features = false } pallet-gear-builtin = { path = "pallets/gear-builtin", default-features = false } pallet-gear-builtin-rpc = { path = "pallets/gear-builtin/rpc" } pallet-gear-builtin-rpc-runtime-api = { path = "pallets/gear-builtin/rpc/runtime-api", default-features = false } -runtime-common = { package = "gear-runtime-common", path = "runtime/common", default-features = false } runtime-primitives = { package = "gear-runtime-primitives", path = "runtime/primitives", default-features = false } service = { package = "gear-service", path = "node/service", default-features = false } testing = { package = "gear-node-testing", path = "node/testing" } diff --git a/gsdk/Cargo.toml b/gsdk/Cargo.toml index 1b54f5ff72f..cbf84f94db3 100644 --- a/gsdk/Cargo.toml +++ b/gsdk/Cargo.toml @@ -26,7 +26,7 @@ jsonrpsee = { workspace = true, features = [ "http-client", "ws-client" ] } log.workspace = true scale-value.workspace = true serde.workspace = true -serde_json.workspace = true +serde_json = { workspace = true, features = [ "std" ] } subxt.workspace = true thiserror.workspace = true sp-runtime = { workspace = true, features = [ "std" ] } diff --git a/node/service/Cargo.toml b/node/service/Cargo.toml index 4a6047770b7..565d17081a9 100644 --- a/node/service/Cargo.toml +++ b/node/service/Cargo.toml @@ -18,7 +18,7 @@ hex-literal.workspace = true jsonrpsee = { workspace = true, features = ["server"] } log.workspace = true serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } +serde_json = { workspace = true, features = [ "std" ] } # Gear common = { workspace = true, features = ["std"] } diff --git a/node/service/src/chain_spec/mod.rs b/node/service/src/chain_spec/mod.rs index a3641b4ae3d..afe47547e5d 100644 --- a/node/service/src/chain_spec/mod.rs +++ b/node/service/src/chain_spec/mod.rs @@ -20,8 +20,6 @@ pub use runtime_primitives::{AccountId, AccountPublic, Block}; use sc_chain_spec::ChainSpecExtension; -use sp_core::{Pair, Public}; -use sp_runtime::traits::IdentifyAccount; use serde::{Deserialize, Serialize}; @@ -45,18 +43,3 @@ pub struct Extensions { /// General `ChainSpec` used as a basis for a specialized config. pub type RawChainSpec = sc_service::GenericChainSpec; - -/// Generate a crypto pair from seed. -pub fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{seed}"), None) - .expect("static values are valid; qed") - .public() -} - -/// Generate an account ID from seed. -pub fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_from_seed::(seed)).into_account() -} diff --git a/node/service/src/chain_spec/vara.rs b/node/service/src/chain_spec/vara.rs index 06075b54641..af1029aedcf 100644 --- a/node/service/src/chain_spec/vara.rs +++ b/node/service/src/chain_spec/vara.rs @@ -16,24 +16,14 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::chain_spec::{get_account_id_from_seed, get_from_seed, AccountId, Extensions}; +use crate::chain_spec::Extensions; use gear_runtime_common::{ self, - constants::{BANK_ADDRESS, VARA_DECIMAL, VARA_SS58PREFIX, VARA_TESTNET_TOKEN_SYMBOL}, + constants::{VARA_DECIMAL, VARA_SS58PREFIX, VARA_TESTNET_TOKEN_SYMBOL}, }; -use pallet_im_online::sr25519::AuthorityId as ImOnlineId; -use pallet_staking::Forcing; use sc_chain_spec::Properties; use sc_service::ChainType; -use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use sp_consensus_babe::AuthorityId as BabeId; -use sp_consensus_grandpa::AuthorityId as GrandpaId; -use sp_core::sr25519; -use sp_runtime::{Perbill, Perquintill}; -use vara_runtime::{ - constants::currency::{ECONOMIC_UNITS, EXISTENTIAL_DEPOSIT, UNITS as TOKEN}, - SessionKeys, StakerStatus, WASM_BINARY, -}; +use vara_runtime::{genesis_config_presets, WASM_BINARY}; /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. pub type ChainSpec = sc_service::GenericChainSpec; @@ -49,42 +39,6 @@ pub fn vara_dev_properties() -> Properties { p } -/// Helper function that wraps a set of session keys. -fn session_keys( - babe: BabeId, - grandpa: GrandpaId, - im_online: ImOnlineId, - authority_discovery: AuthorityDiscoveryId, -) -> SessionKeys { - SessionKeys { - babe, - grandpa, - im_online, - authority_discovery, - } -} - -/// Generate authority keys. -pub fn authority_keys_from_seed( - s: &str, -) -> ( - AccountId, - AccountId, - BabeId, - GrandpaId, - ImOnlineId, - AuthorityDiscoveryId, -) { - ( - get_account_id_from_seed::(&format!("{s}//stash")), - get_account_id_from_seed::(s), - get_from_seed::(s), - get_from_seed::(s), - get_from_seed::(s), - get_from_seed::(s), - ) -} - pub fn development_config() -> Result { let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; @@ -92,19 +46,7 @@ pub fn development_config() -> Result { .with_name("Development") .with_id("vara_dev") .with_chain_type(ChainType::Development) - .with_genesis_config_patch(testnet_genesis( - // Initial PoA authorities - vec![authority_keys_from_seed("Alice")], - // Sudo account - get_account_id_from_seed::("Alice"), - // Pre-funded accounts - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - ], - BANK_ADDRESS.into(), - true, - )) + .with_genesis_config_patch(genesis_config_presets::development_genesis()) .with_properties(vara_dev_properties()) .build()) } @@ -116,103 +58,7 @@ pub fn local_testnet_config() -> Result { .with_name("Vara Local Testnet") .with_id("vara_local_testnet") .with_chain_type(ChainType::Local) - .with_genesis_config_patch(testnet_genesis( - // Initial PoA authorities - vec![ - authority_keys_from_seed("Alice"), - authority_keys_from_seed("Bob"), - ], - // Sudo account - get_account_id_from_seed::("Alice"), - // Pre-funded accounts - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - ], - BANK_ADDRESS.into(), - true, - )) + .with_genesis_config_patch(genesis_config_presets::local_testnet_genesis()) .with_properties(vara_dev_properties()) .build()) } - -/// Configure initial storage state for FRAME modules. -fn testnet_genesis( - initial_authorities: Vec<( - AccountId, - AccountId, - BabeId, - GrandpaId, - ImOnlineId, - AuthorityDiscoveryId, - )>, - root_key: AccountId, - endowed_accounts: Vec, - bank_account: AccountId, - _enable_println: bool, -) -> serde_json::Value { - const ENDOWMENT: u128 = 1_000_000 * TOKEN; - const STASH: u128 = 100 * TOKEN; - const MIN_NOMINATOR_BOND: u128 = 50 * TOKEN; - - let _num_endowed_accounts = endowed_accounts.len(); - - let mut balances = endowed_accounts - .iter() - .map(|k: &AccountId| (k.clone(), ENDOWMENT)) - .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) - .collect::>(); - - balances.push((bank_account, EXISTENTIAL_DEPOSIT)); - - serde_json::json!({ - "balances": { - "balances": balances, - }, - - "session": { - "keys": initial_authorities - .iter() - .map(|x| { - ( - x.0.clone(), - x.0.clone(), - session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()), - ) - }) - .collect::>(), - }, - "staking": { - "validatorCount": initial_authorities.len() as u32, - "minimumValidatorCount": 4, - "stakers": initial_authorities - .iter() - .map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::::Validator)) - .collect::>(), - "invulnerables": initial_authorities.iter().map(|x| x.0.clone()).collect::>(), - "forceEra": Forcing::ForceNone, - "slashRewardFraction": Perbill::from_percent(10), - "minNominatorBond": MIN_NOMINATOR_BOND, - }, - "nominationPools": { - "minCreateBond": 10 * ECONOMIC_UNITS, - "minJoinBond": ECONOMIC_UNITS, - }, - "stakingRewards": { - "nonStakeable": Perquintill::from_rational(4108_u64, 10_000_u64), // 41.08% - "idealStake": Perquintill::from_percent(85), // 85% - "targetInflation": Perquintill::from_rational(578_u64, 10_000_u64), // 5.78% - }, - "babe": { - "epochConfig": Some(vara_runtime::BABE_GENESIS_EPOCH_CONFIG), - }, - "sudo": { - // Assign network admin rights. - "key": Some(root_key), - }, - }) -} diff --git a/runtime/vara/Cargo.toml b/runtime/vara/Cargo.toml index 1b38269eb0b..6544dbb12fd 100644 --- a/runtime/vara/Cargo.toml +++ b/runtime/vara/Cargo.toml @@ -19,6 +19,7 @@ const-str.workspace = true log.workspace = true parity-scale-codec.workspace = true scale-info = { workspace = true, features = ["derive"] } +serde_json.workspace = true # Frame deps frame-support.workspace = true @@ -67,6 +68,7 @@ sp-api.workspace = true sp-authority-discovery.workspace = true sp-block-builder.workspace = true sp-consensus-babe.workspace = true +sp-consensus-grandpa.workspace = true sp-core.workspace = true sp-externalities = { workspace = true, optional = true } sp-genesis-builder.workspace = true @@ -93,7 +95,7 @@ hex-literal = { workspace = true, optional = true } # Internal deps common.workspace = true -runtime-common.workspace = true +gear-runtime-common.workspace = true pallet-gear-scheduler.workspace = true pallet-gear-messenger.workspace = true pallet-gear-program.workspace = true @@ -189,14 +191,16 @@ std = [ "pallet-utility/std", "pallet-vesting/std", "pallet-whitelist/std", - "runtime-common/std", + "gear-runtime-common/std", "runtime-primitives/std", "scale-info/std", + "serde_json/std", "sp-api/std", "sp-arithmetic/std", "sp-authority-discovery/std", "sp-block-builder/std", "sp-consensus-babe/std", + "sp-consensus-grandpa/std", "sp-core/std", "sp-externalities", "sp-inherents/std", @@ -282,7 +286,7 @@ try-runtime = [ "pallet-vesting/try-runtime", "pallet-whitelist/try-runtime", "pallet-bags-list/try-runtime", - "runtime-common/try-runtime", + "gear-runtime-common/try-runtime", ] dev = ["pallet-gear-debug", "pallet-gear-eth-bridge", "pallet-sudo"] metadata-hash = ["substrate-wasm-builder?/metadata-hash"] diff --git a/runtime/vara/src/genesis_config_presets.rs b/runtime/vara/src/genesis_config_presets.rs new file mode 100644 index 00000000000..bc581beb3e7 --- /dev/null +++ b/runtime/vara/src/genesis_config_presets.rs @@ -0,0 +1,221 @@ +// This file is part of Gear. + +// Copyright (C) 2025 Gear Technologies Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program 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. + +// This program 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 this program. If not, see . +use super::{UNITS as TOKEN, *}; +use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use pallet_staking::{Forcing, StakerStatus}; +use runtime_primitives::AccountPublic; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_consensus_grandpa::AuthorityId as GrandpaId; +use sp_core::{sr25519, Pair, Public}; +use sp_genesis_builder::{PresetId, DEV_RUNTIME_PRESET, LOCAL_TESTNET_RUNTIME_PRESET}; +use sp_runtime::{format, traits::IdentifyAccount}; + +/// Configure initial storage state for FRAME modules. +pub fn testnet_genesis( + initial_authorities: Vec<( + AccountId, + AccountId, + BabeId, + GrandpaId, + ImOnlineId, + AuthorityDiscoveryId, + )>, + root_key: AccountId, + endowed_accounts: Vec, + bank_account: AccountId, + _enable_println: bool, +) -> serde_json::Value { + const ENDOWMENT: u128 = 1_000_000 * TOKEN; + const STASH: u128 = 100 * TOKEN; + const MIN_NOMINATOR_BOND: u128 = 50 * TOKEN; + + let _num_endowed_accounts = endowed_accounts.len(); + + let mut balances = endowed_accounts + .iter() + .map(|k: &AccountId| (k.clone(), ENDOWMENT)) + .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) + .collect::>(); + + balances.push((bank_account, EXISTENTIAL_DEPOSIT)); + + serde_json::json!({ + "balances": { + "balances": balances, + }, + + "session": { + "keys": initial_authorities + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()), + ) + }) + .collect::>(), + }, + "staking": { + "validatorCount": initial_authorities.len() as u32, + "minimumValidatorCount": 4, + "stakers": initial_authorities + .iter() + .map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::::Validator)) + .collect::>(), + "invulnerables": initial_authorities.iter().map(|x| x.0.clone()).collect::>(), + "forceEra": Forcing::ForceNone, + "slashRewardFraction": Perbill::from_percent(10), + "minNominatorBond": MIN_NOMINATOR_BOND, + }, + "nominationPools": { + "minCreateBond": 10 * ECONOMIC_UNITS, + "minJoinBond": ECONOMIC_UNITS, + }, + "stakingRewards": { + // 41.08% + "nonStakeable": Perquintill::from_rational(4_108u64, 10_000u64), + // 85% + "idealStake": Perquintill::from_percent(85), + // 5.78% + "targetInflation": Perquintill::from_rational(578u64, 10_000u64), + }, + "babe": { + "epochConfig": Some(BABE_GENESIS_EPOCH_CONFIG), + }, + "sudo": { + // Assign network admin rights. + "key": Some(root_key), + }, + }) +} + +/// Helper function that wraps a set of session keys. +fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + im_online: ImOnlineId, + authority_discovery: AuthorityDiscoveryId, +) -> SessionKeys { + SessionKeys { + babe, + grandpa, + im_online, + authority_discovery, + } +} + +/// Generate a crypto pair from seed. +pub fn get_from_seed(seed: &str) -> ::Public { + TPublic::Pair::from_string(&format!("//{seed}"), None) + .expect("static values are valid; qed") + .public() +} + +/// Generate an account ID from seed. +pub fn get_account_id_from_seed(seed: &str) -> AccountId +where + AccountPublic: From<::Public>, +{ + AccountPublic::from(get_from_seed::(seed)).into_account() +} + +/// Generate authority keys. +pub fn authority_keys_from_seed( + s: &str, +) -> ( + AccountId, + AccountId, + BabeId, + GrandpaId, + ImOnlineId, + AuthorityDiscoveryId, +) { + ( + get_account_id_from_seed::(&format!("{s}//stash")), + get_account_id_from_seed::(s), + get_from_seed::(s), + get_from_seed::(s), + get_from_seed::(s), + get_from_seed::(s), + ) +} + +pub fn development_genesis() -> serde_json::Value { + testnet_genesis( + // Initial PoA authorities + vec![authority_keys_from_seed("Alice")], + // Sudo account + get_account_id_from_seed::("Alice"), + // Pre-funded accounts + vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + ], + BANK_ADDRESS.into(), + true, + ) +} + +pub fn local_testnet_genesis() -> serde_json::Value { + testnet_genesis( + // Initial PoA authorities + vec![ + authority_keys_from_seed("Alice"), + authority_keys_from_seed("Bob"), + ], + // Sudo account + get_account_id_from_seed::("Alice"), + // Pre-funded accounts + vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Charlie"), + get_account_id_from_seed::("Dave"), + get_account_id_from_seed::("Eve"), + get_account_id_from_seed::("Ferdie"), + ], + BANK_ADDRESS.into(), + true, + ) +} + +/// Provides the JSON representation of predefined genesis config for given `id`. +pub fn get_preset(id: &PresetId) -> Option> { + // TODO: remove after Substrate update + let id: &str = id.try_into().ok()?; + let patch = match id { + DEV_RUNTIME_PRESET => development_genesis(), + LOCAL_TESTNET_RUNTIME_PRESET => local_testnet_genesis(), + _ => return None, + }; + + Some( + serde_json::to_string(&patch) + .expect("serialization to json works.") + .into_bytes(), + ) +} + +/// List of supported presets. +pub fn preset_names() -> Vec { + vec![ + PresetId::from(DEV_RUNTIME_PRESET), + PresetId::from(LOCAL_TESTNET_RUNTIME_PRESET), + ] +} diff --git a/runtime/vara/src/lib.rs b/runtime/vara/src/lib.rs index e22bc1af26c..f198744a9e6 100644 --- a/runtime/vara/src/lib.rs +++ b/runtime/vara/src/lib.rs @@ -53,7 +53,6 @@ use pallet_identity::legacy::IdentityInfo; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_session::historical::{self as pallet_session_historical}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use runtime_common::constants::BANK_ADDRESS; use runtime_primitives::{Balance, BlockNumber, Hash, Moment, Nonce}; use scale_info::TypeInfo; use sp_api::impl_runtime_apis; @@ -114,6 +113,15 @@ pub use frame_support::{ }, PalletId, StorageValue, }; +pub use gear_runtime_common::{ + constants::{ + BANK_ADDRESS, RENT_DISABLED_DELTA_WEEK_FACTOR, RENT_FREE_PERIOD_MONTH_FACTOR, + RENT_RESUME_WEEK_FACTOR, RESUME_SESSION_DURATION_HOUR_FACTOR, + }, + impl_runtime_apis_plus_common, BlockHashCount, DealWithFees, AVERAGE_ON_INITIALIZE_RATIO, + GAS_LIMIT_MIN_PERCENTAGE_NUM, NORMAL_DISPATCH_LENGTH_RATIO, NORMAL_DISPATCH_WEIGHT_RATIO, + VALUE_PER_GAS, +}; pub use pallet_gear::manager::{ExtManager, HandleKind}; pub use pallet_gear_payment::CustomChargeTransactionPayment; pub use pallet_gear_staking_rewards::StakingBlackList; @@ -121,15 +129,6 @@ pub use pallet_gear_staking_rewards::StakingBlackList; pub use pallet_transaction_payment::{ CurrencyAdapter, FeeDetails, Multiplier, RuntimeDispatchInfo, }; -pub use runtime_common::{ - constants::{ - RENT_DISABLED_DELTA_WEEK_FACTOR, RENT_FREE_PERIOD_MONTH_FACTOR, RENT_RESUME_WEEK_FACTOR, - RESUME_SESSION_DURATION_HOUR_FACTOR, - }, - impl_runtime_apis_plus_common, BlockHashCount, DealWithFees, AVERAGE_ON_INITIALIZE_RATIO, - GAS_LIMIT_MIN_PERCENTAGE_NUM, NORMAL_DISPATCH_LENGTH_RATIO, NORMAL_DISPATCH_WEIGHT_RATIO, - VALUE_PER_GAS, -}; pub use runtime_primitives::{AccountId, Signature, VARA_SS58_PREFIX}; #[cfg(all(feature = "dev", any(feature = "std", test)))] @@ -143,6 +142,7 @@ pub use { }; pub mod constants; +pub mod genesis_config_presets; pub use constants::{currency::*, time::*}; @@ -229,7 +229,7 @@ const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( parameter_types! { pub const Version: RuntimeVersion = VERSION; pub const SS58Prefix: u8 = VARA_SS58_PREFIX; - pub RuntimeBlockWeights: BlockWeights = runtime_common::block_weights_for(MAXIMUM_BLOCK_WEIGHT); + pub RuntimeBlockWeights: BlockWeights = gear_runtime_common::block_weights_for(MAXIMUM_BLOCK_WEIGHT); pub RuntimeBlockLength: BlockLength = BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_LENGTH_RATIO); } @@ -1882,11 +1882,11 @@ impl_runtime_apis_plus_common! { } fn get_preset(id: &Option) -> Option> { - get_preset::(id, |_| None) + get_preset::(id, genesis_config_presets::get_preset) } fn preset_names() -> Vec { - vec![] + genesis_config_presets::preset_names() } } diff --git a/scripts/benchmarking/run_all_benchmarks.sh b/scripts/benchmarking/run_all_benchmarks.sh index 37d9eaeee74..1317a8a6e33 100755 --- a/scripts/benchmarking/run_all_benchmarks.sh +++ b/scripts/benchmarking/run_all_benchmarks.sh @@ -91,8 +91,13 @@ then cargo build --profile=production --locked --features=runtime-benchmarks fi +PATH_BASE=./target/production # The executable to use. -GEAR=./target/production/gear +GEAR=$PATH_BASE/gear +# The runtime to use. +RUNTIME=$PATH_BASE/wbuild/vara-runtime/vara_runtime.compact.compressed.wasm +# The preset of genesis builder to use. +PRESET=development # Manually exclude some pallets. EXCLUDED_PALLETS=( @@ -100,7 +105,11 @@ EXCLUDED_PALLETS=( # Load all pallet names in an array. ALL_PALLETS=($( - $GEAR benchmark pallet --list --chain=$chain_spec |\ + $GEAR benchmark pallet \ + --list \ + --runtime=$RUNTIME \ + --genesis-builder=runtime \ + --genesis-builder-preset=$PRESET | \ tail -n+2 |\ cut -d',' -f1 |\ sort |\ @@ -157,9 +166,12 @@ for PALLET in "${PALLETS[@]}"; do # Get all the extrinsics for the pallet if the pallet is "pallet_gear". if [ "$PALLET" == "pallet_gear" ] then - IFS=',' read -r -a ALL_EXTRINSICS <<< "$(IFS=',' $GEAR benchmark pallet --list \ - --chain=$chain_spec \ - --pallet="$PALLET" |\ + IFS=',' read -r -a ALL_EXTRINSICS <<< "$(IFS=',' $GEAR benchmark pallet \ + --list \ + --runtime=$RUNTIME \ + --genesis-builder=runtime \ + --genesis-builder-preset=$PRESET \ + --pallet="$PALLET" | \ tail -n+2 |\ cut -d',' -f2 |\ sort |\ @@ -186,7 +198,9 @@ for PALLET in "${PALLETS[@]}"; do OUTPUT=$( $TASKSET_CMD $GEAR benchmark pallet \ - --chain="$chain_spec" \ + --runtime=$RUNTIME \ + --genesis-builder=runtime \ + --genesis-builder-preset=$PRESET \ --steps=$BENCHMARK_STEPS \ --repeat=$BENCHMARK_REPEAT \ --pallet="$PALLET" \ @@ -208,7 +222,9 @@ for PALLET in "${PALLETS[@]}"; do touch "./${WEIGHTS_OUTPUT}/${PALLET}_onetime.rs" OUTPUT=$( $TASKSET_CMD $GEAR benchmark pallet \ - --chain="$chain_spec" \ + --runtime=$RUNTIME \ + --genesis-builder=runtime \ + --genesis-builder-preset=$PRESET \ --steps=$BENCHMARK_STEPS_ONE_TIME_EXTRINSICS \ --repeat=$BENCHMARK_REPEAT_ONE_TIME_EXTRINSICS \ --pallet="$PALLET" \ diff --git a/utils/cargo-gbuild/Cargo.toml b/utils/cargo-gbuild/Cargo.toml index cde5968209e..2740460fe74 100644 --- a/utils/cargo-gbuild/Cargo.toml +++ b/utils/cargo-gbuild/Cargo.toml @@ -18,7 +18,7 @@ clap = { workspace = true, features = ["derive"] } colored.workspace = true etc.workspace = true serde = { workspace = true, features = ["derive"] } -serde_json.workspace = true +serde_json = { workspace = true, features = [ "std" ] } toml.workspace = true tracing.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter"] } diff --git a/utils/gring/Cargo.toml b/utils/gring/Cargo.toml index 5934dfc45e4..1a905aee979 100644 --- a/utils/gring/Cargo.toml +++ b/utils/gring/Cargo.toml @@ -24,7 +24,7 @@ nacl.workspace = true rand = { workspace = true, features = ["std", "std_rng"] } schnorrkel.workspace = true serde = { workspace = true, features = ["derive"] } -serde_json.workspace = true +serde_json = { workspace = true, features = [ "std" ] } tracing.workspace = true # Feature CLI diff --git a/utils/regression-analysis/Cargo.toml b/utils/regression-analysis/Cargo.toml index bb33c28bf4b..0f30a30cee4 100644 --- a/utils/regression-analysis/Cargo.toml +++ b/utils/regression-analysis/Cargo.toml @@ -11,7 +11,7 @@ quick-xml = { workspace = true, features = [ "serialize" ] } tabled.workspace = true junit-common.workspace = true serde = { workspace = true, features = ["derive"] } -serde_json.workspace = true +serde_json = { workspace = true, features = [ "std" ] } thousands.workspace = true vara-runtime = { workspace = true, features = ["std"] }