// Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. pub mod impls; pub mod macros; pub mod xcm_helpers; pub use xcm_emulator; // Substrate use grandpa::AuthorityId as GrandpaId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; use sp_core::{sr25519, storage::Storage, Pair, Public}; use sp_runtime::{ traits::{IdentifyAccount, Verify}, BuildStorage, MultiSignature, }; // Polakdot use parachains_common::BlockNumber; use polkadot_runtime_parachains::configuration::HostConfiguration; use xcm; // Cumulus use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId}; use polkadot_primitives::{AssignmentId, ValidatorId}; use polkadot_service::chain_spec::get_authority_keys_from_seed_no_beefy; pub const XCM_V2: u32 = 2; pub const XCM_V3: u32 = 3; pub const REF_TIME_THRESHOLD: u64 = 33; pub const PROOF_SIZE_THRESHOLD: u64 = 33; /// The default XCM version to set in genesis config. pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; type AccountPublic = ::Signer; /// Helper function to generate a crypto pair from seed pub fn get_from_seed(seed: &str) -> ::Public { TPublic::Pair::from_string(&format!("//{}", seed), None) .expect("static values are valid; qed") .public() } /// Helper function to generate an account ID from seed. pub fn get_account_id_from_seed(seed: &str) -> AccountId where AccountPublic: From<::Public>, { AccountPublic::from(get_from_seed::(seed)).into_account() } pub fn get_host_config() -> HostConfiguration { HostConfiguration { max_upward_queue_count: 10, max_upward_queue_size: 51200, max_upward_message_size: 51200, max_upward_message_num_per_candidate: 10, max_downward_message_size: 51200, hrmp_sender_deposit: 0, hrmp_recipient_deposit: 0, hrmp_channel_max_capacity: 1000, hrmp_channel_max_message_size: 102400, hrmp_channel_max_total_size: 102400, hrmp_max_parachain_outbound_channels: 30, hrmp_max_parachain_inbound_channels: 30, ..Default::default() } } /// Helper function used in tests to build the genesis storage using given RuntimeGenesisConfig and /// code Used in `legacy_vs_json_check` submods to verify storage building with JSON patch against /// building with RuntimeGenesisConfig struct. pub fn build_genesis_storage(builder: &dyn BuildStorage, code: &[u8]) -> Storage { let mut storage = builder.build_storage().unwrap(); storage .top .insert(sp_core::storage::well_known_keys::CODE.to_vec(), code.into()); storage } pub mod accounts { use super::*; pub const ALICE: &str = "Alice"; pub const BOB: &str = "Bob"; pub const CHARLIE: &str = "Charlie"; pub const DAVE: &str = "Dave"; pub const EVE: &str = "Eve"; pub const FERDIE: &str = "Ferdei"; pub const ALICE_STASH: &str = "Alice//stash"; pub const BOB_STASH: &str = "Bob//stash"; pub const CHARLIE_STASH: &str = "Charlie//stash"; pub const DAVE_STASH: &str = "Dave//stash"; pub const EVE_STASH: &str = "Eve//stash"; pub const FERDIE_STASH: &str = "Ferdie//stash"; pub const FERDIE_BEEFY: &str = "Ferdie//stash"; pub fn init_balances() -> Vec { 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), ] } } pub mod collators { use super::*; pub fn invulnerables_asset_hub_polkadot() -> Vec<(AccountId, AssetHubPolkadotAuraId)> { vec![ ( get_account_id_from_seed::("Alice"), get_from_seed::("Alice"), ), ( get_account_id_from_seed::("Bob"), get_from_seed::("Bob"), ), ] } pub fn invulnerables() -> Vec<(AccountId, AuraId)> { vec![ ( get_account_id_from_seed::("Alice"), get_from_seed::("Alice"), ), (get_account_id_from_seed::("Bob"), get_from_seed::("Bob")), ] } } pub mod validators { use super::*; pub fn initial_authorities() -> Vec<( AccountId, AccountId, BabeId, GrandpaId, ValidatorId, AssignmentId, AuthorityDiscoveryId, )> { vec![get_authority_keys_from_seed_no_beefy("Alice")] } }