mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 09:51:02 +00:00
002d9260f9
**Update:** Pushed additional changes based on the review comments. **This pull request fixes various spelling mistakes in this repository.** Most of the changes are contained in the first **3** commits: - `Fix spelling mistakes in comments and docs` - `Fix spelling mistakes in test names` - `Fix spelling mistakes in error messages, panic messages, logs and tracing` Other source code spelling mistakes are separated into individual commits for easier reviewing: - `Fix the spelling of 'authority'` - `Fix the spelling of 'REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY'` - `Fix the spelling of 'prev_enqueud_messages'` - `Fix the spelling of 'endpoint'` - `Fix the spelling of 'children'` - `Fix the spelling of 'PenpalSiblingSovereignAccount'` - `Fix the spelling of 'PenpalSudoAccount'` - `Fix the spelling of 'insufficient'` - `Fix the spelling of 'PalletXcmExtrinsicsBenchmark'` - `Fix the spelling of 'subtracted'` - `Fix the spelling of 'CandidatePendingAvailability'` - `Fix the spelling of 'exclusive'` - `Fix the spelling of 'until'` - `Fix the spelling of 'discriminator'` - `Fix the spelling of 'nonexistent'` - `Fix the spelling of 'subsystem'` - `Fix the spelling of 'indices'` - `Fix the spelling of 'committed'` - `Fix the spelling of 'topology'` - `Fix the spelling of 'response'` - `Fix the spelling of 'beneficiary'` - `Fix the spelling of 'formatted'` - `Fix the spelling of 'UNKNOWN_PROOF_REQUEST'` - `Fix the spelling of 'succeeded'` - `Fix the spelling of 'reopened'` - `Fix the spelling of 'proposer'` - `Fix the spelling of 'InstantiationNonce'` - `Fix the spelling of 'depositor'` - `Fix the spelling of 'expiration'` - `Fix the spelling of 'phantom'` - `Fix the spelling of 'AggregatedKeyValue'` - `Fix the spelling of 'randomness'` - `Fix the spelling of 'defendant'` - `Fix the spelling of 'AquaticMammal'` - `Fix the spelling of 'transactions'` - `Fix the spelling of 'PassingTracingSubscriber'` - `Fix the spelling of 'TxSignaturePayload'` - `Fix the spelling of 'versioning'` - `Fix the spelling of 'descendant'` - `Fix the spelling of 'overridden'` - `Fix the spelling of 'network'` Let me know if this structure is adequate. **Note:** The usage of the words `Merkle`, `Merkelize`, `Merklization`, `Merkelization`, `Merkleization`, is somewhat inconsistent but I left it as it is. ~~**Note:** In some places the term `Receival` is used to refer to message reception, IMO `Reception` is the correct word here, but I left it as it is.~~ ~~**Note:** In some places the term `Overlayed` is used instead of the more acceptable version `Overlaid` but I also left it as it is.~~ ~~**Note:** In some places the term `Applyable` is used instead of the correct version `Applicable` but I also left it as it is.~~ **Note:** Some usage of British vs American english e.g. `judgement` vs `judgment`, `initialise` vs `initialize`, `optimise` vs `optimize` etc. are both present in different places, but I suppose that's understandable given the number of contributors. ~~**Note:** There is a spelling mistake in `.github/CODEOWNERS` but it triggers errors in CI when I make changes to it, so I left it as it is.~~
191 lines
6.1 KiB
Rust
191 lines
6.1 KiB
Rust
// 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 beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId;
|
|
use frame_support::parameter_types;
|
|
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::{AccountIdConversion, IdentifyAccount, Verify},
|
|
BuildStorage, MultiSignature,
|
|
};
|
|
|
|
// Polakdot
|
|
use parachains_common::BlockNumber;
|
|
use polkadot_parachain_primitives::primitives::Sibling;
|
|
use polkadot_runtime_parachains::configuration::HostConfiguration;
|
|
|
|
// Cumulus
|
|
use parachains_common::{AccountId, AuraId};
|
|
use polkadot_primitives::{AssignmentId, ValidatorId};
|
|
|
|
pub const XCM_V2: u32 = 2;
|
|
pub const XCM_V3: u32 = 3;
|
|
pub const XCM_V4: u32 = 4;
|
|
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 = <MultiSignature as Verify>::Signer;
|
|
|
|
// This asset is added to AH as Asset and reserved transfer between Parachain and AH
|
|
pub const RESERVABLE_ASSET_ID: u32 = 1;
|
|
// This asset is added to AH as ForeignAsset and teleported between Penpal and AH
|
|
pub const TELEPORTABLE_ASSET_ID: u32 = 2;
|
|
|
|
pub const PENPAL_ID: u32 = 2000;
|
|
pub const ASSETS_PALLET_ID: u8 = 50;
|
|
|
|
parameter_types! {
|
|
pub PenpalTeleportableAssetLocation: xcm::v3::Location
|
|
= xcm::v3::Location::new(1, [
|
|
xcm::v3::Junction::Parachain(PENPAL_ID),
|
|
xcm::v3::Junction::PalletInstance(ASSETS_PALLET_ID),
|
|
xcm::v3::Junction::GeneralIndex(TELEPORTABLE_ASSET_ID.into()),
|
|
]
|
|
);
|
|
pub PenpalSiblingSovereignAccount: AccountId = Sibling::from(PENPAL_ID).into_account_truncating();
|
|
}
|
|
|
|
/// Helper function to generate a crypto pair from seed
|
|
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::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<TPublic: Public>(seed: &str) -> AccountId
|
|
where
|
|
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
|
{
|
|
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
|
}
|
|
|
|
pub fn get_host_config() -> HostConfiguration<BlockNumber> {
|
|
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 = "Ferdie";
|
|
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<AccountId> {
|
|
vec![
|
|
get_account_id_from_seed::<sr25519::Public>(ALICE),
|
|
get_account_id_from_seed::<sr25519::Public>(BOB),
|
|
get_account_id_from_seed::<sr25519::Public>(CHARLIE),
|
|
get_account_id_from_seed::<sr25519::Public>(DAVE),
|
|
get_account_id_from_seed::<sr25519::Public>(EVE),
|
|
get_account_id_from_seed::<sr25519::Public>(FERDIE),
|
|
get_account_id_from_seed::<sr25519::Public>(ALICE_STASH),
|
|
get_account_id_from_seed::<sr25519::Public>(BOB_STASH),
|
|
get_account_id_from_seed::<sr25519::Public>(CHARLIE_STASH),
|
|
get_account_id_from_seed::<sr25519::Public>(DAVE_STASH),
|
|
get_account_id_from_seed::<sr25519::Public>(EVE_STASH),
|
|
get_account_id_from_seed::<sr25519::Public>(FERDIE_STASH),
|
|
]
|
|
}
|
|
}
|
|
|
|
pub mod collators {
|
|
use super::*;
|
|
|
|
pub fn invulnerables() -> Vec<(AccountId, AuraId)> {
|
|
vec![
|
|
(
|
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
get_from_seed::<AuraId>("Alice"),
|
|
),
|
|
(get_account_id_from_seed::<sr25519::Public>("Bob"), get_from_seed::<AuraId>("Bob")),
|
|
]
|
|
}
|
|
}
|
|
|
|
pub mod validators {
|
|
use super::*;
|
|
|
|
pub fn initial_authorities() -> Vec<(
|
|
AccountId,
|
|
AccountId,
|
|
BabeId,
|
|
GrandpaId,
|
|
ValidatorId,
|
|
AssignmentId,
|
|
AuthorityDiscoveryId,
|
|
BeefyId,
|
|
)> {
|
|
let seed = "Alice";
|
|
vec![(
|
|
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
|
|
get_account_id_from_seed::<sr25519::Public>(seed),
|
|
get_from_seed::<BabeId>(seed),
|
|
get_from_seed::<GrandpaId>(seed),
|
|
get_from_seed::<ValidatorId>(seed),
|
|
get_from_seed::<AssignmentId>(seed),
|
|
get_from_seed::<AuthorityDiscoveryId>(seed),
|
|
get_from_seed::<BeefyId>(seed),
|
|
)]
|
|
}
|
|
}
|