pub fn testnet_genesis(
	initial_authorities: Vec<(AccountId, AccountId, AuthorityId)>,
	root_key: AccountId,
	endowed_accounts: Option<Vec<AccountId>>,
	enable_println: bool,
) -> GenesisConfig {
	let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(|| {
		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"),
			get_account_id_from_seed("Alice//stash"),
			get_account_id_from_seed("Bob//stash"),
			get_account_id_from_seed("Charlie//stash"),
			get_account_id_from_seed("Dave//stash"),
			get_account_id_from_seed("Eve//stash"),
			get_account_id_from_seed("Ferdie//stash"),
		]
	});

	const STASH: u128 = 1 << 20;
	const ENDOWMENT: u128 = 1 << 20;

	let mut contract_config = ContractConfig {
		transaction_base_fee: 1,
		transaction_byte_fee: 0,
		transfer_fee: 0,
		creation_fee: 0,
		contract_fee: 21,
		call_base_fee: 135,
		create_base_fee: 175,
		gas_price: 1,
		max_depth: 1024,
		block_gas_limit: 10_000_000,
		current_schedule: Default::default(),
	};
	// this should only be enabled on development chains
	contract_config.current_schedule.enable_println = enable_println;

	GenesisConfig {
		consensus: Some(ConsensusConfig {
			code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm").to_vec(),
			authorities: initial_authorities.iter().map(|x| x.2.clone()).collect(),
		}),
		system: None,
		indices: Some(IndicesConfig {
			ids: endowed_accounts.clone(),
		}),
		balances: Some(BalancesConfig {
			transaction_base_fee: 1,
			transaction_byte_fee: 0,
			existential_deposit: 500,
			transfer_fee: 0,
			creation_fee: 0,
			balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
			vesting: vec![],
		}),
		session: Some(SessionConfig {
			validators: initial_authorities.iter().map(|x| x.1.clone()).collect(),
			session_length: 10,
			keys: initial_authorities.iter().map(|x| (x.1.clone(), x.2.clone())).collect::<Vec<_>>(),
		}),
		staking: Some(StakingConfig {
			current_era: 0,
			minimum_validator_count: 1,
			validator_count: 2,
			sessions_per_era: 5,
			bonding_duration: 2 * 60 * 12,
			offline_slash: Perbill::zero(),
			session_reward: Perbill::zero(),
			current_session_reward: 0,
			offline_slash_grace: 0,
			stakers: initial_authorities.iter().map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)).collect(),
			invulnerables: initial_authorities.iter().map(|x| x.1.clone()).collect(),
		}),
		democracy: Some(DemocracyConfig {
			launch_period: 9,
			voting_period: 18,
			minimum_deposit: 10,
			public_delay: 0,
			max_lock_periods: 6,
		}),
		council_seats: Some(CouncilSeatsConfig {
			active_council: endowed_accounts.iter()
				.filter(|&endowed| initial_authorities.iter().find(|&(_, controller, _)| controller == endowed).is_none())
				.map(|a| (a.clone(), 1000000)).collect(),
			candidacy_bond: 10,
			voter_bond: 2,
			present_slash_per_voter: 1,
			carry_count: 4,
			presentation_duration: 10,
			approval_voting_period: 20,
			term_duration: 1000000,
			desired_seats: (endowed_accounts.len() / 2 - initial_authorities.len()) as u32,
			inactive_grace_period: 1,
		}),
		council_voting: Some(CouncilVotingConfig {
			cooloff_period: 75,
			voting_period: 20,
			enact_delay_period: 0,
		}),
		timestamp: Some(TimestampConfig {
			minimum_period: 2,                    // 2*2=4 second block time.
		}),
		treasury: Some(TreasuryConfig {
			proposal_bond: Permill::from_percent(5),
			proposal_bond_minimum: 1_000_000,
			spend_period: 12 * 60 * 24,
			burn: Permill::from_percent(50),
		}),
		contract: Some(contract_config),
		sudo: Some(SudoConfig {
			key: root_key,
		}),
		grandpa: Some(GrandpaConfig {
			authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(),
		}),
	}
}
/// Helper function to create GenesisConfig for testing
Helper function to create GenesisConfig for testing
Helper function to create GenesisConfig for testing
pub fn testnet_genesis(
	initial_authorities: Vec<(AccountId, AccountId, AuthorityId)>,
	root_key: AccountId,
	endowed_accounts: Option<Vec<AccountId>>,
	enable_println: bool,
) -> GenesisConfig {
	let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(|| {
		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"),
			get_account_id_from_seed("Alice//stash"),
			get_account_id_from_seed("Bob//stash"),
			get_account_id_from_seed("Charlie//stash"),
			get_account_id_from_seed("Dave//stash"),
			get_account_id_from_seed("Eve//stash"),
			get_account_id_from_seed("Ferdie//stash"),
		]
	});
	const STASH: u128 = 1 << 20;
	const ENDOWMENT: u128 = 1 << 20;
	let mut contract_config = ContractConfig {
		transaction_base_fee: 1,
		transaction_byte_fee: 0,
		transfer_fee: 0,
		creation_fee: 0,
		contract_fee: 21,
		call_base_fee: 135,
		create_base_fee: 175,
		gas_price: 1,
		max_depth: 1024,
		block_gas_limit: 10_000_000,
		current_schedule: Default::default(),
	};
	// this should only be enabled on development chains
	contract_config.current_schedule.enable_println = enable_println;
	GenesisConfig {
		consensus: Some(ConsensusConfig {
			code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm").to_vec(),
			authorities: initial_authorities.iter().map(|x| x.2.clone()).collect(),
		}),
		system: None,
		indices: Some(IndicesConfig {
			ids: endowed_accounts.clone(),
		}),
		balances: Some(BalancesConfig {
			transaction_base_fee: 1,
			transaction_byte_fee: 0,
			existential_deposit: 500,
			transfer_fee: 0,
			creation_fee: 0,
			balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
			vesting: vec![],
		}),
		session: Some(SessionConfig {
			validators: initial_authorities.iter().map(|x| x.1.clone()).collect(),
			session_length: 10,
			keys: initial_authorities.iter().map(|x| (x.1.clone(), x.2.clone())).collect::<Vec<_>>(),
		}),
		staking: Some(StakingConfig {
			current_era: 0,
			minimum_validator_count: 1,
			validator_count: 2,
			sessions_per_era: 5,
			bonding_duration: 2 * 60 * 12,
			offline_slash: Perbill::zero(),
			session_reward: Perbill::zero(),
			current_session_reward: 0,
			offline_slash_grace: 0,
			stakers: initial_authorities.iter().map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)).collect(),
			invulnerables: initial_authorities.iter().map(|x| x.1.clone()).collect(),
		}),
		democracy: Some(DemocracyConfig {
			launch_period: 9,
			voting_period: 18,
			minimum_deposit: 10,
			public_delay: 0,
			max_lock_periods: 6,
		}),
		council_seats: Some(CouncilSeatsConfig {
			active_council: endowed_accounts.iter()
				.filter(|&endowed| initial_authorities.iter().find(|&(_, controller, _)| controller == endowed).is_none())
				.map(|a| (a.clone(), 1000000)).collect(),
			candidacy_bond: 10,
			voter_bond: 2,
			present_slash_per_voter: 1,
			carry_count: 4,
			presentation_duration: 10,
			approval_voting_period: 20,
			term_duration: 1000000,
			desired_seats: (endowed_accounts.len() / 2 - initial_authorities.len()) as u32,
			inactive_grace_period: 1,
		}),
		council_voting: Some(CouncilVotingConfig {
			cooloff_period: 75,
			voting_period: 20,
			enact_delay_period: 0,
		}),
		timestamp: Some(TimestampConfig {
			minimum_period: 2,                    // 2*2=4 second block time.
		}),
		treasury: Some(TreasuryConfig {
			proposal_bond: Permill::from_percent(5),
			proposal_bond_minimum: 1_000_000,
			spend_period: 12 * 60 * 24,
			burn: Permill::from_percent(50),
		}),
		contract: Some(contract_config),
		sudo: Some(SudoConfig {
			key: root_key,
		}),
		grandpa: Some(GrandpaConfig {
			authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(),
		}),
	}
}
pub fn testnet_genesis ( initial_authorities : Vec < ( AccountId , AccountId , AuthorityId ) > , root_key : AccountId , endowed_accounts : Option < Vec < AccountId > > , enable_println : bool , ) -> GenesisConfig { let endowed_accounts : Vec < AccountId > = endowed_accounts . unwrap_or_else ( | | { vec ! [ get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) get_account_id_from_seed ( " " ) ] } ) ; const STASH : u128 = 1 << 20 ; const ENDOWMENT : u128 = 1 << 20 ; let mut contract_config = ContractConfig { transaction_base_fee : 1 , transaction_byte_fee : 0 , transfer_fee : 0 , creation_fee : 0 , contract_fee : 21 , call_base_fee : 135 , create_base_fee : 175 , gas_price : 1 , max_depth : 1024 , block_gas_limit : 10_000_000 , current_schedule : Default :: default ( ) , } ; // this should only be enabled on development chains contract_config . current_schedule . enable_println = enable_println ; GenesisConfig { consensus : Some ( ConsensusConfig { code : include_bytes ! ( " " ) . to_vec ( ) , authorities : initial_authorities . iter ( ) . map ( | x | x . 2 . clone ( ) ) . collect ( ) , } ) , system : None , indices : Some ( IndicesConfig { ids : endowed_accounts . clone ( ) , } ) , balances : Some ( BalancesConfig { transaction_base_fee : 1 , transaction_byte_fee : 0 , existential_deposit : 500 , transfer_fee : 0 , creation_fee : 0 , balances : endowed_accounts . iter ( ) . map ( | k | ( k . clone ( ) , ENDOWMENT ) ) . collect ( ) , vesting : vec ! [ ] , } ) , session : Some ( SessionConfig { validators : initial_authorities . iter ( ) . map ( | x | x . 1 . clone ( ) ) . collect ( ) , session_length : 10 , keys : initial_authorities . iter ( ) . map ( | x | ( x . 1 . clone ( ) , x . 2 . clone ( ) ) ) . collect :: < Vec < _ > > ( ) , } ) , staking : Some ( StakingConfig { current_era : 0 , minimum_validator_count : 1 , validator_count : 2 , sessions_per_era : 5 , bonding_duration : 2 * 60 * 12 , offline_slash : Perbill :: zero ( ) , session_reward : Perbill :: zero ( ) , current_session_reward : 0 , offline_slash_grace : 0 , stakers : initial_authorities . iter ( ) . map ( | x | ( x . 0 . clone ( ) , x . 1 . clone ( ) , STASH , StakerStatus :: Validator ) ) . collect ( ) , invulnerables : initial_authorities . iter ( ) . map ( | x | x . 1 . clone ( ) ) . collect ( ) , } ) , democracy : Some ( DemocracyConfig { launch_period : 9 , voting_period : 18 , minimum_deposit : 10 , public_delay : 0 , max_lock_periods : 6 , } ) , council_seats : Some ( CouncilSeatsConfig { active_council : endowed_accounts . iter ( ) . filter ( | & endowed | initial_authorities . iter ( ) . find ( | & ( _ , controller , _ ) | controller == endowed ) . is_none ( ) ) . map ( | a | ( a . clone ( ) , 1000000 ) ) . collect ( ) , candidacy_bond : 10 , voter_bond : 2 , present_slash_per_voter : 1 , carry_count : 4 , presentation_duration : 10 , approval_voting_period : 20 , term_duration : 1000000 , desired_seats : ( endowed_accounts . len ( ) / 2 - initial_authorities . len ( ) ) as u32 , inactive_grace_period : 1 , } ) , council_voting : Some ( CouncilVotingConfig { cooloff_period : 75 , voting_period : 20 , enact_delay_period : 0 , } ) , timestamp : Some ( TimestampConfig { minimum_period : 2 , // 2*2=4 second block time. } ) , treasury : Some ( TreasuryConfig { proposal_bond : Permill :: from_percent ( 5 ) , proposal_bond_minimum : 1_000_000 , spend_period : 12 * 60 * 24 , burn : Permill :: from_percent ( 50 ) , } ) , contract : Some ( contract_config ) , sudo : Some ( SudoConfig { key : root_key , } ) , grandpa : Some ( GrandpaConfig { authorities : initial_authorities . iter ( ) . map ( | x | ( x . 2 . clone ( ) , 1 ) ) . collect ( ) , } ) , } }
Helper function to create GenesisConfig for testing
Helper function to create GenesisConfig for testing
initial_authorities
Vec<(AccountId, AccountId, AuthorityId)>
root_key
AccountId
endowed_accounts
Option<Vec<AccountId>>
enable_println
bool
initial_authorities
Vec<(AccountId, AccountId, AuthorityId)>
root_key
AccountId
endowed_accounts
Option<Vec<AccountId>>
enable_println
bool