Skip to content

Commit

Permalink
generate chainspec for benchmarking (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
salman01zp authored Mar 21, 2024
1 parent 7389279 commit aff933d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
59 changes: 58 additions & 1 deletion node/src/chainspec/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChainSpec, String> {
pub fn local_benchmarking_config(chain_id: u64) -> Result<ChainSpec, String> {
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());
Expand Down Expand Up @@ -161,6 +161,63 @@ pub fn local_testnet_config(chain_id: u64) -> Result<ChainSpec, String> {
))
}

pub fn local_testnet_config(chain_id: u64) -> Result<ChainSpec, String> {
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::<sr25519::Public>("Alice"),
// Pre-funded accounts
vec![
(get_account_id_from_seed::<sr25519::Public>("Alice"), ENDOWMENT),
(get_account_id_from_seed::<sr25519::Public>("Bob"), ENDOWMENT),
(get_account_id_from_seed::<sr25519::Public>("Charlie"), ENDOWMENT),
(get_account_id_from_seed::<sr25519::Public>("Dave"), ENDOWMENT),
(get_account_id_from_seed::<sr25519::Public>("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<ChainSpec, String> {
let wasm_binary = WASM_BINARY.ok_or_else(|| "tangle wasm not available".to_string())?;
let boot_nodes = get_bootnodes();
Expand Down
4 changes: 4 additions & 0 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit aff933d

Please sign in to comment.