referrerpolicy=no-referrer-when-downgrade

bridge_hub_westend_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 sp_core::storage::Storage;
18use sp_keyring::Sr25519Keyring as Keyring;
19
20// Cumulus
21use emulated_integration_tests_common::{
22	accounts, build_genesis_storage, collators, SAFE_XCM_VERSION,
23};
24use parachains_common::Balance;
25use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH};
26
27pub const PARA_ID: u32 = 1002;
28pub const ASSETHUB_PARA_ID: u32 = 1000;
29pub const ED: Balance = testnet_parachains_constants::westend::currency::EXISTENTIAL_DEPOSIT;
30
31pub fn genesis() -> Storage {
32	let genesis_config = bridge_hub_westend_runtime::RuntimeGenesisConfig {
33		system: bridge_hub_westend_runtime::SystemConfig::default(),
34		balances: bridge_hub_westend_runtime::BalancesConfig {
35			balances: accounts::init_balances().iter().cloned().map(|k| (k, ED * 4096)).collect(),
36			..Default::default()
37		},
38		parachain_info: bridge_hub_westend_runtime::ParachainInfoConfig {
39			parachain_id: PARA_ID.into(),
40			..Default::default()
41		},
42		collator_selection: bridge_hub_westend_runtime::CollatorSelectionConfig {
43			invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(),
44			candidacy_bond: ED * 16,
45			..Default::default()
46		},
47		session: bridge_hub_westend_runtime::SessionConfig {
48			keys: collators::invulnerables()
49				.into_iter()
50				.map(|(acc, aura)| {
51					(
52						acc.clone(),                                      // account id
53						acc,                                              // validator id
54						bridge_hub_westend_runtime::SessionKeys { aura }, // session keys
55					)
56				})
57				.collect(),
58			..Default::default()
59		},
60		polkadot_xcm: bridge_hub_westend_runtime::PolkadotXcmConfig {
61			safe_xcm_version: Some(SAFE_XCM_VERSION),
62			..Default::default()
63		},
64		bridge_rococo_grandpa: bridge_hub_westend_runtime::BridgeRococoGrandpaConfig {
65			owner: Some(Keyring::Bob.to_account_id()),
66			..Default::default()
67		},
68		bridge_rococo_messages: bridge_hub_westend_runtime::BridgeRococoMessagesConfig {
69			owner: Some(Keyring::Bob.to_account_id()),
70			..Default::default()
71		},
72		xcm_over_bridge_hub_rococo: bridge_hub_westend_runtime::XcmOverBridgeHubRococoConfig {
73			opened_bridges: vec![
74				// open AHW -> AHR bridge
75				(
76					Location::new(1, [Parachain(1000)]),
77					Junctions::from([
78						NetworkId::ByGenesis(ROCOCO_GENESIS_HASH).into(),
79						Parachain(1000),
80					]),
81					Some(bp_messages::LegacyLaneId([0, 0, 0, 2])),
82				),
83			],
84			..Default::default()
85		},
86		ethereum_system: bridge_hub_westend_runtime::EthereumSystemConfig {
87			para_id: PARA_ID.into(),
88			asset_hub_para_id: ASSETHUB_PARA_ID.into(),
89			..Default::default()
90		},
91		..Default::default()
92	};
93
94	build_genesis_storage(
95		&genesis_config,
96		bridge_hub_westend_runtime::WASM_BINARY
97			.expect("WASM binary was not built, please build it!"),
98	)
99}