mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 14:31:02 +00:00
Add benchmarks for for import/validation/production (#2579)
* Add benchmarks * Remove endowed accounts * Fix group * Remove duplicate code * Comments * Use execute_block instead of block import * Apply suggestions from code review Co-authored-by: Anton <anton.kalyaev@gmail.com> * Add missing comments * Clippy * Reorganize utils * Remove unused import * Switch to compiled again * Apply suggestions from code review Co-authored-by: Davide Galassi <davxy@datawok.net> * Refactor local_testnet * Do not write wasm blob to file * Remove unnecessary block * Add comment fixes * fmt * lock --------- Co-authored-by: Anton <anton.kalyaev@gmail.com> Co-authored-by: Davide Galassi <davxy@datawok.net>
This commit is contained in:
@@ -80,12 +80,22 @@ where
|
||||
}
|
||||
|
||||
/// Get the chain spec for a specific parachain ID.
|
||||
pub fn get_chain_spec(id: ParaId) -> ChainSpec {
|
||||
/// The given accounts are initialized with funds in addition
|
||||
/// to the default known accounts.
|
||||
pub fn get_chain_spec_with_extra_endowed(
|
||||
id: ParaId,
|
||||
extra_endowed_accounts: Vec<AccountId>,
|
||||
) -> ChainSpec {
|
||||
ChainSpec::from_genesis(
|
||||
"Local Testnet",
|
||||
"local_testnet",
|
||||
ChainType::Local,
|
||||
move || GenesisExt { runtime_genesis_config: local_testnet_genesis(), para_id: id },
|
||||
move || GenesisExt {
|
||||
runtime_genesis_config: testnet_genesis_with_default_endowed(
|
||||
extra_endowed_accounts.clone(),
|
||||
),
|
||||
para_id: id,
|
||||
},
|
||||
Vec::new(),
|
||||
None,
|
||||
None,
|
||||
@@ -95,28 +105,36 @@ pub fn get_chain_spec(id: ParaId) -> ChainSpec {
|
||||
)
|
||||
}
|
||||
|
||||
/// Local testnet genesis for testing.
|
||||
pub fn local_testnet_genesis() -> cumulus_test_runtime::GenesisConfig {
|
||||
testnet_genesis(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
||||
],
|
||||
)
|
||||
/// Get the chain spec for a specific parachain ID.
|
||||
pub fn get_chain_spec(id: ParaId) -> ChainSpec {
|
||||
get_chain_spec_with_extra_endowed(id, Default::default())
|
||||
}
|
||||
|
||||
fn testnet_genesis(
|
||||
/// Local testnet genesis for testing.
|
||||
pub fn testnet_genesis_with_default_endowed(
|
||||
mut extra_endowed_accounts: Vec<AccountId>,
|
||||
) -> cumulus_test_runtime::GenesisConfig {
|
||||
let mut endowed = vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
||||
];
|
||||
endowed.append(&mut extra_endowed_accounts);
|
||||
|
||||
testnet_genesis(get_account_id_from_seed::<sr25519::Public>("Alice"), endowed)
|
||||
}
|
||||
|
||||
/// Creates a local testnet genesis with endowed accounts.
|
||||
pub fn testnet_genesis(
|
||||
root_key: AccountId,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
) -> cumulus_test_runtime::GenesisConfig {
|
||||
@@ -126,6 +144,7 @@ fn testnet_genesis(
|
||||
.expect("WASM binary was not build, please build it!")
|
||||
.to_vec(),
|
||||
},
|
||||
glutton: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
balances: cumulus_test_runtime::BalancesConfig {
|
||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
||||
|
||||
Reference in New Issue
Block a user