referrerpolicy=no-referrer-when-downgrade

rococo_emulated_chain/
genesis.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// SPDX-License-Identifier: Apache-2.0
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// 	http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16// Substrate
17use sc_consensus_grandpa::AuthorityId as GrandpaId;
18use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
19use sp_consensus_babe::AuthorityId as BabeId;
20use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
21use sp_core::storage::Storage;
22use sp_keyring::Sr25519Keyring as Keyring;
23
24// Polkadot
25use polkadot_primitives::{AssignmentId, ValidatorId};
26
27// Cumulus
28use emulated_integration_tests_common::{
29	accounts, build_genesis_storage, get_host_config, validators,
30};
31use parachains_common::Balance;
32use rococo_runtime_constants::currency::UNITS as ROC;
33
34pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT;
35const ENDOWMENT: u128 = 1_000_000 * ROC;
36
37fn session_keys(
38	babe: BabeId,
39	grandpa: GrandpaId,
40	para_validator: ValidatorId,
41	para_assignment: AssignmentId,
42	authority_discovery: AuthorityDiscoveryId,
43	beefy: BeefyId,
44) -> rococo_runtime::SessionKeys {
45	rococo_runtime::SessionKeys {
46		babe,
47		grandpa,
48		para_validator,
49		para_assignment,
50		authority_discovery,
51		beefy,
52	}
53}
54
55pub fn genesis() -> Storage {
56	let genesis_config = rococo_runtime::RuntimeGenesisConfig {
57		system: rococo_runtime::SystemConfig::default(),
58		balances: rococo_runtime::BalancesConfig {
59			balances: accounts::init_balances().iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
60			..Default::default()
61		},
62		session: rococo_runtime::SessionConfig {
63			keys: validators::initial_authorities()
64				.iter()
65				.map(|x| {
66					(
67						x.0.clone(),
68						x.0.clone(),
69						session_keys(
70							x.2.clone(),
71							x.3.clone(),
72							x.4.clone(),
73							x.5.clone(),
74							x.6.clone(),
75							x.7.clone(),
76						),
77					)
78				})
79				.collect::<Vec<_>>(),
80			..Default::default()
81		},
82		babe: rococo_runtime::BabeConfig {
83			authorities: Default::default(),
84			epoch_config: rococo_runtime::BABE_GENESIS_EPOCH_CONFIG,
85			..Default::default()
86		},
87		sudo: rococo_runtime::SudoConfig { key: Some(Keyring::Alice.to_account_id()) },
88		configuration: rococo_runtime::ConfigurationConfig { config: get_host_config() },
89		registrar: rococo_runtime::RegistrarConfig {
90			next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
91			..Default::default()
92		},
93		..Default::default()
94	};
95
96	build_genesis_storage(&genesis_config, rococo_runtime::WASM_BINARY.unwrap())
97}