From aff933d23bb8bfeb2d9e098d283c60bc370db036 Mon Sep 17 00:00:00 2001 From: Salman Pathan Date: Thu, 21 Mar 2024 15:39:42 +0700 Subject: [PATCH] generate chainspec for benchmarking (#571) --- node/src/chainspec/testnet.rs | 59 ++++++++++++++++++++++++++++++++++- node/src/command.rs | 4 +++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/node/src/chainspec/testnet.rs b/node/src/chainspec/testnet.rs index ffa2d2487..631ca83a0 100644 --- a/node/src/chainspec/testnet.rs +++ b/node/src/chainspec/testnet.rs @@ -98,7 +98,7 @@ fn generate_session_keys( tangle_testnet_runtime::opaque::SessionKeys { babe, grandpa, im_online, role } } -pub fn local_testnet_config(chain_id: u64) -> Result { +pub fn local_benchmarking_config(chain_id: u64) -> Result { let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; let mut properties = sc_chain_spec::Properties::new(); properties.insert("tokenSymbol".into(), "tTNT".into()); @@ -161,6 +161,63 @@ pub fn local_testnet_config(chain_id: u64) -> Result { )) } +pub fn local_testnet_config(chain_id: u64) -> Result { + let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; + let mut properties = sc_chain_spec::Properties::new(); + properties.insert("tokenSymbol".into(), "tTNT".into()); + properties.insert("tokenDecimals".into(), 18u32.into()); + properties.insert("ss58Format".into(), 42.into()); + #[allow(deprecated)] + Ok(ChainSpec::from_genesis( + // Name + "Local Testnet", + // ID + "local_testnet", + ChainType::Local, + move || { + testnet_genesis( + // Initial PoA authorities + vec![ + authority_keys_from_seed("Alice"), + authority_keys_from_seed("Bob"), + authority_keys_from_seed("Charlie"), + authority_keys_from_seed("Dave"), + authority_keys_from_seed("Eve"), + ], + vec![], + // Sudo account + get_account_id_from_seed::("Alice"), + // Pre-funded accounts + vec![ + (get_account_id_from_seed::("Alice"), ENDOWMENT), + (get_account_id_from_seed::("Bob"), ENDOWMENT), + (get_account_id_from_seed::("Charlie"), ENDOWMENT), + (get_account_id_from_seed::("Dave"), ENDOWMENT), + (get_account_id_from_seed::("Eve"), ENDOWMENT), + ], + chain_id, + Default::default(), + Default::default(), + Default::default(), + true, + ) + }, + // Bootnodes + vec![], + // Telemetry + None, + // Protocol ID + None, + // Fork id + None, + // Properties + Some(properties), + // Extensions + None, + wasm_binary, + )) +} + pub fn tangle_testnet_config(chain_id: u64) -> Result { let wasm_binary = WASM_BINARY.ok_or_else(|| "tangle wasm not available".to_string())?; let boot_nodes = get_bootnodes(); diff --git a/node/src/command.rs b/node/src/command.rs index b84973cf2..ccf35905c 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -76,6 +76,10 @@ impl SubstrateCli for Cli { "" | "dev" | "local" => Box::new(chainspec::testnet::local_testnet_config( tangle_primitives::TESTNET_CHAIN_ID, )?), + // generates the spec for benchmarking. + "benchmark" => Box::new(chainspec::testnet::local_benchmarking_config( + tangle_primitives::TESTNET_CHAIN_ID, + )?), // generates the spec for testnet "testnet" => Box::new(chainspec::testnet::tangle_testnet_config( tangle_primitives::TESTNET_CHAIN_ID,