Newer
Older
}
/// Helper function to create kusama GenesisConfig for testing
pub fn kusama_testnet_genesis(
initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AuthorityDiscoveryId,
)>,
_root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> kusama::GenesisConfig {
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
const ENDOWMENT: u128 = 1_000_000 * KSM;
const STASH: u128 = 100 * KSM;
kusama::GenesisConfig {
frame_system: Some(kusama::SystemConfig {
changes_trie_config: Default::default(),
}),
pallet_indices: Some(kusama::IndicesConfig { indices: vec![] }),
pallet_balances: Some(kusama::BalancesConfig {
balances: endowed_accounts
.iter()
.map(|k| (k.clone(), ENDOWMENT))
.collect(),
pallet_session: Some(kusama::SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
kusama_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
),
)
})
.collect::<Vec<_>>(),
pallet_staking: Some(kusama::StakingConfig {
minimum_validator_count: 1,
validator_count: 2,
stakers: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.1.clone(),
STASH,
kusama::StakerStatus::Validator,
)
})
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
force_era: Forcing::NotForcing,
slash_reward_fraction: Perbill::from_percent(10),
pallet_elections_phragmen: Some(Default::default()),
pallet_democracy: Some(kusama::DemocracyConfig::default()),
pallet_collective_Instance1: Some(kusama::CouncilConfig {
members: vec![],
phantom: Default::default(),
}),
pallet_collective_Instance2: Some(kusama::TechnicalCommitteeConfig {
members: vec![],
phantom: Default::default(),
}),
pallet_membership_Instance1: Some(Default::default()),
pallet_babe: Some(Default::default()),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
pallet_authority_discovery: Some(kusama::AuthorityDiscoveryConfig { keys: vec![] }),
claims: Some(kusama::ClaimsConfig {
claims: vec![],
vesting: vec![],
}),
pallet_vesting: Some(kusama::VestingConfig { vesting: vec![] }),
/// Helper function to create westend GenesisConfig for testing
initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AuthorityDiscoveryId,
)>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> westend::GenesisConfig {
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
const ENDOWMENT: u128 = 1_000_000 * DOTS;
const STASH: u128 = 100 * DOTS;
westend::GenesisConfig {
frame_system: Some(westend::SystemConfig {
changes_trie_config: Default::default(),
}),
pallet_indices: Some(westend::IndicesConfig { indices: vec![] }),
pallet_balances: Some(westend::BalancesConfig {
balances: endowed_accounts
.iter()
.map(|k| (k.clone(), ENDOWMENT))
.collect(),
pallet_session: Some(westend::SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
westend_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
),
)
})
.collect::<Vec<_>>(),
pallet_staking: Some(westend::StakingConfig {
minimum_validator_count: 1,
validator_count: 2,
stakers: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.1.clone(),
STASH,
westend::StakerStatus::Validator,
)
})
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
force_era: Forcing::NotForcing,
slash_reward_fraction: Perbill::from_percent(10),
pallet_babe: Some(Default::default()),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
pallet_authority_discovery: Some(westend::AuthorityDiscoveryConfig { keys: vec![] }),
pallet_vesting: Some(westend::VestingConfig { vesting: vec![] }),
pallet_sudo: Some(westend::SudoConfig { key: root_key }),
}
}
/// Helper function to create rococo GenesisConfig for testing
pub fn rococo_testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId, AuthorityDiscoveryId)>,
_root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> rococo_runtime::GenesisConfig {
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
const ENDOWMENT: u128 = 1_000_000 * DOTS;
rococo_runtime::GenesisConfig {
frame_system: Some(rococo_runtime::SystemConfig {
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
pallet_indices: Some(rococo_runtime::IndicesConfig {
indices: vec![],
pallet_balances: Some(rococo_runtime::BalancesConfig {
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
}),
pallet_session: Some(rococo_runtime::SessionConfig {
keys: initial_authorities.iter().map(|x| (
x.0.clone(),
x.0.clone(),
rococo_session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone(), x.6.clone()),
)).collect::<Vec<_>>(),
}),
pallet_babe: Some(Default::default()),
pallet_grandpa: Some(Default::default()),
pallet_im_online: Some(Default::default()),
pallet_authority_discovery: Some(rococo_runtime::AuthorityDiscoveryConfig {
keys: vec![],
pallet_staking: Some(Default::default()),
fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
vec![get_authority_keys_from_seed("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
vec![get_authority_keys_from_seed("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
vec![get_authority_keys_from_seed("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
/// Polkadot development config (single validator Alice)
pub fn polkadot_development_config() -> Result<PolkadotChainSpec, String> {
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
Ok(PolkadotChainSpec::from_genesis(
"Development",
"dev",
ChainType::Development,
move || polkadot_development_config_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
}
/// Kusama development config (single validator Alice)
pub fn kusama_development_config() -> Result<KusamaChainSpec, String> {
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
Ok(KusamaChainSpec::from_genesis(
"Development",
"kusama_dev",
ChainType::Development,
move || kusama_development_config_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
}
/// Westend development config (single validator Alice)
pub fn westend_development_config() -> Result<WestendChainSpec, String> {
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;
Ok(WestendChainSpec::from_genesis(
"Development",
"westend_dev",
ChainType::Development,
move || westend_development_config_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
fn polkadot_local_testnet_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
/// Polkadot local testnet config (multivalidator Alice + Bob)
pub fn polkadot_local_testnet_config() -> Result<PolkadotChainSpec, String> {
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
Ok(PolkadotChainSpec::from_genesis(
"Local Testnet",
"local_testnet",
ChainType::Local,
move || polkadot_local_testnet_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
fn kusama_local_testnet_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
/// Kusama local testnet config (multivalidator Alice + Bob)
pub fn kusama_local_testnet_config() -> Result<KusamaChainSpec, String> {
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
Ok(KusamaChainSpec::from_genesis(
"Kusama Local Testnet",
"kusama_local_testnet",
ChainType::Local,
move || kusama_local_testnet_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
/// Westend local testnet config (multivalidator Alice + Bob)
pub fn westend_local_testnet_config() -> Result<WestendChainSpec, String> {
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;
Ok(WestendChainSpec::from_genesis(
"Westend Local Testnet",
"westend_local_testnet",
ChainType::Local,
move || westend_local_testnet_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
fn rococo_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisConfig {
rococo_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
/// Rococo local testnet config (multivalidator Alice + Bob)
pub fn rococo_local_testnet_config() -> Result<RococoChainSpec, String> {
let wasm_binary = rococo::WASM_BINARY.ok_or("Rococo development wasm not available")?;
Ok(RococoChainSpec::from_genesis(
"Rococo Local Testnet",
"rococo_local_testnet",
ChainType::Local,
move || rococo_local_testnet_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
))
}