shiden_runtime/
genesis_config.rs1use crate::*;
20use astar_primitives::{evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::SHIDEN_ID};
21
22pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<Vec<u8>> {
24 let genesis = match id.as_str() {
25 "development" => default_config(SHIDEN_ID),
26 _ => return None,
27 };
28 Some(
29 serde_json::to_string(&genesis)
30 .expect("serialization to json is expected to work. qed.")
31 .into_bytes(),
32 )
33}
34
35pub fn default_config(para_id: u32) -> serde_json::Value {
37 let alice = GenesisAccount::<sr25519::Public>::from_seed("Alice");
38 let bob = GenesisAccount::<sr25519::Public>::from_seed("Bob");
39
40 let balances: Vec<(AccountId, Balance)> = vec![
41 (alice.account_id(), 1_000_000_000_000 * SDN),
42 (bob.account_id(), 1_000_000_000_000 * SDN),
43 (
44 TreasuryPalletId::get().into_account_truncating(),
45 1_000_000_000 * SDN,
46 ),
47 ];
48
49 let slots_per_tier = vec![0, 6, 10, 0];
50 let tier_rank_multipliers: Vec<u32> = vec![0, 24_000, 46_700, 0];
51
52 let authorities = vec![&alice, &bob];
53
54 let config = RuntimeGenesisConfig {
55 system: Default::default(),
56 sudo: SudoConfig {
57 key: Some(alice.account_id()),
58 },
59 parachain_info: ParachainInfoConfig {
60 parachain_id: para_id.into(),
61 ..Default::default()
62 },
63 balances: BalancesConfig {
64 balances,
65 ..Default::default()
66 },
67 vesting: VestingConfig { vesting: vec![] },
68 session: SessionConfig {
69 keys: authorities
70 .iter()
71 .map(|x| {
72 (
73 x.account_id(),
74 x.account_id(),
75 SessionKeys {
76 aura: x.pub_key().into(),
77 },
78 )
79 })
80 .collect::<Vec<_>>(),
81 ..Default::default()
82 },
83 aura: AuraConfig {
84 authorities: vec![],
85 },
86 aura_ext: Default::default(),
87 collator_selection: CollatorSelectionConfig {
88 desired_candidates: 32,
89 candidacy_bond: 32_000 * SDN,
90 invulnerables: authorities
91 .iter()
92 .map(|x| x.account_id())
93 .collect::<Vec<_>>(),
94 },
95 evm: EVMConfig {
96 accounts: Precompiles::used_addresses_h160()
99 .map(|addr| {
100 (
101 addr,
102 fp_evm::GenesisAccount {
103 nonce: Default::default(),
104 balance: Default::default(),
105 storage: Default::default(),
106 code: EVM_REVERT_CODE.into(),
107 },
108 )
109 })
110 .collect(),
111 ..Default::default()
112 },
113 ethereum: Default::default(),
114 polkadot_xcm: Default::default(),
115 assets: Default::default(),
116 parachain_system: Default::default(),
117 transaction_payment: Default::default(),
118 dapp_staking: DappStakingConfig {
119 reward_portion: vec![
120 Permill::from_percent(0),
121 Permill::from_percent(70),
122 Permill::from_percent(30),
123 Permill::from_percent(0),
124 ],
125 slot_distribution: vec![
126 Permill::from_percent(0),
127 Permill::from_parts(375_000), Permill::from_parts(625_000), Permill::from_percent(0),
130 ],
131 tier_thresholds: vec![
133 TierThreshold::FixedPercentage {
134 required_percentage: Perbill::from_parts(23_200_000), },
136 TierThreshold::FixedPercentage {
137 required_percentage: Perbill::from_parts(9_300_000), },
139 TierThreshold::FixedPercentage {
140 required_percentage: Perbill::from_parts(3_500_000), },
142 TierThreshold::FixedPercentage {
144 required_percentage: Perbill::from_parts(0), },
146 ],
147 slots_per_tier,
148 safeguard: Some(false),
149 tier_rank_multipliers,
150 ..Default::default()
151 },
152 inflation: Default::default(),
153 };
154
155 serde_json::to_value(&config).expect("Could not build genesis config.")
156}