diff --git a/CHANGELOG.md b/CHANGELOG.md
index fdcf47ef85..48939176a2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,15 +1,26 @@
# Changelog
+## [Unreleased]
+
+### Added
+
+- Location conversion tests for relays and parachains ([polkadot-fellows/runtimes#487](https://github.com/polkadot-fellows/runtimes/pull/487))
+
Changelog for the runtimes governed by the Polkadot Fellowship.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
-## [Unreleased]
+## [1.3.4] 01.11.2024
### Changed
- Change Polkadot inflation to 120M DOT per year ([polkadot-fellows/runtimes#471](https://github.com/polkadot-fellows/runtimes/pull/471))
- Update foreign asset ids in Asset Hub Polkadot and Asset Hub Kusama from v3 to v4 locations ([polkadot-fellows/runtimes#472](https://github.com/polkadot-fellows/runtimes/pull/472))
+- Lower Parachain and Data Deposits to Encourage Experimentation on Kusama ([polkadot-fellows/runtimes#501](https://github.com/polkadot-fellows/runtimes/pull/501))
+
+### Fixed
+
+- Fix `experimental_inflation_info` in Polkadot and remove unused code (https://github.com/polkadot-fellows/runtimes/pull/497)
## [1.3.3] 01.10.2024
diff --git a/Cargo.lock b/Cargo.lock
index ef1c6afbbb..da338aa398 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4604,9 +4604,9 @@ dependencies = [
[[package]]
name = "frame-system"
-version = "36.0.1"
+version = "36.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d19f388280c14dbabcee2a817e1123c59c55847c6d07a5b5ca901b34a5910093"
+checksum = "64d6a0e7bb6503facdcc6f8e19c83cd0bfc8bbbd268522b1a50e107dfc6b972d"
dependencies = [
"cfg-if",
"docify",
@@ -8559,9 +8559,9 @@ dependencies = [
[[package]]
name = "pallet-message-queue"
-version = "39.0.0"
+version = "39.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20e65a37881d1998546254a5e50a1f768b3f82deabe774e750f4ea95aba8030c"
+checksum = "8bb779dbfd58b3a4e6a84245392fe9d8c31a746ff7c6db414e91c012663859c3"
dependencies = [
"environmental",
"frame-benchmarking",
@@ -9374,7 +9374,7 @@ checksum = "4e69bf016dc406eff7d53a7d3f7cf1c2e72c82b9088aac1118591e36dd2cd3e9"
dependencies = [
"bitcoin_hashes 0.13.0",
"rand",
- "rand_core 0.6.4",
+ "rand_core 0.5.1",
"serde",
"unicode-normalization",
]
@@ -10108,7 +10108,6 @@ dependencies = [
"pallet-nomination-pools-runtime-api",
"pallet-offences",
"pallet-offences-benchmarking",
- "pallet-parameters",
"pallet-preimage",
"pallet-proxy",
"pallet-referenda",
diff --git a/relay/common/src/lib.rs b/relay/common/src/lib.rs
index 0f0e119f25..e38d994081 100644
--- a/relay/common/src/lib.rs
+++ b/relay/common/src/lib.rs
@@ -27,6 +27,7 @@ pub mod apis {
/// Both fields should be treated as best-effort, given that the inflation rate might not be
/// fully predict-able.
#[derive(scale_info::TypeInfo, codec::Encode, codec::Decode)]
+ #[cfg_attr(feature = "std", derive(Debug))]
pub struct InflationInfo {
/// The rate of inflation estimated per annum.
pub inflation: sp_runtime::Perquintill,
diff --git a/relay/kusama/src/lib.rs b/relay/kusama/src/lib.rs
index a29936ec5e..0737a219c3 100644
--- a/relay/kusama/src/lib.rs
+++ b/relay/kusama/src/lib.rs
@@ -830,7 +830,7 @@ parameter_types! {
pub const TipCountdown: BlockNumber = DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: Balance = 100 * CENTS;
- pub const DataDepositPerByte: Balance = CENTS;
+ pub const DataDepositPerByte: Balance = CENTS / 10;
pub const MaxApprovals: u32 = 100;
pub const MaxAuthorities: u32 = 100_000;
pub const MaxKeys: u32 = 10_000;
@@ -1468,7 +1468,7 @@ impl parachains_slashing::Config for Runtime {
}
parameter_types! {
- pub const ParaDeposit: Balance = 40 * UNITS;
+ pub const ParaDeposit: Balance = 4 * UNITS;
}
impl paras_registrar::Config for Runtime {
diff --git a/relay/kusama/tests/location_conversion.rs b/relay/kusama/tests/location_conversion.rs
new file mode 100644
index 0000000000..d5c3557c32
--- /dev/null
+++ b/relay/kusama/tests/location_conversion.rs
@@ -0,0 +1,99 @@
+// Copyright (C) Parity Technologies (UK) Ltd.
+// This file is part of Polkadot.
+
+// Polkadot is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Polkadot is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Polkadot. If not, see .
+
+use polkadot_primitives::AccountId;
+use sp_core::crypto::Ss58Codec;
+use staging_kusama_runtime::xcm_config::SovereignAccountOf;
+use xcm::prelude::*;
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
+
+const ALICE: [u8; 32] = [1u8; 32];
+
+#[test]
+fn location_conversion_works() {
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Child",
+ location: Location::new(0, [Parachain(1111)]),
+ expected_account_id_str: "5Ec4AhP4h37t7TFsAZ4HhFq6k92usAAJDUC3ADSZ4H4Acru3",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Child",
+ location: Location::new(0, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5FjEBrKn3STAFsZpQF4jzwxUYHNGnNgzdZqSQfTzeJ82XKp6",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Child",
+ location: Location::new(
+ 0,
+ [
+ Parachain(1111),
+ Junction::AccountId32 { network: None, id: AccountId::from(ALICE).into() },
+ ],
+ ),
+ expected_account_id_str: "5D6CDyPd9Mya81xFN3nChiKqLvUzd8zS9fwKhfCW6FtJKjS2",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Sibling",
+ location: Location::new(
+ 0,
+ [Parachain(1111), AccountKey20 { network: None, key: [123u8; 20] }],
+ ),
+ expected_account_id_str: "5DEZsy7tsnNXB7ehLGkF8b4EUqfLQWqEzGiy2RrneC8uRNMK",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Child",
+ location: Location::new(
+ 0,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5GenE4vJgHvwYVcD6b4nBvH5HNY4pzpVHWoqwFpNMFT7a2oX",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Child",
+ location: Location::new(
+ 0,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DPgGBFTTYm1dGbtB1VWHJ3T3ScvdrskGGx6vSJZNP1WNStV",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected =
+ AccountId::from_string(tc.expected_account_id_str).expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}
diff --git a/relay/polkadot/Cargo.toml b/relay/polkadot/Cargo.toml
index ed69433257..a1b2c8bb5e 100644
--- a/relay/polkadot/Cargo.toml
+++ b/relay/polkadot/Cargo.toml
@@ -61,7 +61,6 @@ pallet-multisig = { workspace = true }
pallet-nomination-pools = { workspace = true }
pallet-nomination-pools-runtime-api = { workspace = true }
pallet-offences = { workspace = true }
-pallet-parameters = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
pallet-referenda = { workspace = true }
@@ -168,7 +167,6 @@ std = [
"pallet-nomination-pools/std",
"pallet-offences-benchmarking?/std",
"pallet-offences/std",
- "pallet-parameters/std",
"pallet-preimage/std",
"pallet-proxy/std",
"pallet-referenda/std",
@@ -247,7 +245,6 @@ runtime-benchmarks = [
"pallet-nomination-pools/runtime-benchmarks",
"pallet-offences-benchmarking/runtime-benchmarks",
"pallet-offences/runtime-benchmarks",
- "pallet-parameters/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
@@ -300,7 +297,6 @@ try-runtime = [
"pallet-multisig/try-runtime",
"pallet-nomination-pools/try-runtime",
"pallet-offences/try-runtime",
- "pallet-parameters/try-runtime",
"pallet-preimage/try-runtime",
"pallet-proxy/try-runtime",
"pallet-referenda/try-runtime",
diff --git a/relay/polkadot/src/lib.rs b/relay/polkadot/src/lib.rs
index 9e6064e5c7..82e14f18dc 100644
--- a/relay/polkadot/src/lib.rs
+++ b/relay/polkadot/src/lib.rs
@@ -31,6 +31,7 @@ use polkadot_runtime_common::{
traits::OnSwap,
BlockHashCount, BlockLength, CurrencyToVote, SlowAdjustingFeeUpdate,
};
+use relay_common::apis::InflationInfo;
use runtime_parachains::{
assigner_coretime as parachains_assigner_coretime,
@@ -60,7 +61,6 @@ use frame_election_provider_support::{
};
use frame_support::{
construct_runtime,
- dynamic_params::{dynamic_pallet_params, dynamic_params},
genesis_builder_helper::{build_state, get_preset},
parameter_types,
traits::{
@@ -85,7 +85,7 @@ use polkadot_primitives::{
GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment,
NodeFeatures, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes,
SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
- LOWEST_PUBLIC_ID, PARACHAIN_KEY_TYPE_ID,
+ PARACHAIN_KEY_TYPE_ID,
};
use sp_core::{OpaqueMetadata, H256};
use sp_runtime::{
@@ -93,7 +93,7 @@ use sp_runtime::{
traits::{
AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto,
Extrinsic as ExtrinsicT, IdentityLookup, Keccak256, OpaqueKeys, SaturatedConversion,
- Saturating, Verify,
+ Verify,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill, RuntimeDebug,
@@ -160,7 +160,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"),
impl_name: create_runtime_str!("parity-polkadot"),
authoring_version: 0,
- spec_version: 1_003_003,
+ spec_version: 1_003_004,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 26,
@@ -619,88 +619,6 @@ impl pallet_bags_list::Config for Runtime {
type Score = sp_npos_elections::VoteWeight;
}
-/// Dynamic params that can be adjusted at runtime.
-#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::)]
-pub mod dynamic_params {
- use super::*;
-
- /// Parameters used to calculate era payouts, see
- /// [`polkadot_runtime_common::impls::EraPayoutParams`].
- #[dynamic_pallet_params]
- #[codec(index = 0)]
- pub mod inflation {
- /// Minimum inflation rate used to calculate era payouts.
- #[codec(index = 0)]
- pub static MinInflation: Perquintill = Perquintill::from_rational(25u64, 1000);
-
- /// Maximum inflation rate used to calculate era payouts.
- #[codec(index = 1)]
- pub static MaxInflation: Perquintill = Perquintill::from_percent(10);
-
- /// Ideal stake ratio used to calculate era payouts.
- #[codec(index = 2)]
- pub static IdealStake: Perquintill = Perquintill::from_percent(75);
-
- /// Falloff used to calculate era payouts.
- #[codec(index = 3)]
- pub static Falloff: Perquintill = Perquintill::from_percent(5);
-
- /// Whether to use auction slots or not in the calculation of era payouts, then we subtract
- /// `num_auctioned_slots.min(60) / 300` from `ideal_stake`.
- ///
- /// That is, we assume up to 60 parachains that are leased can reduce the ideal stake by a
- /// maximum of 20%.
- ///
- /// With the move to agile-coretime, this parameter does not make much sense and should
- /// generally be set to false.
- #[codec(index = 4)]
- pub static UseAuctionSlots: bool = true;
- }
-}
-
-#[cfg(feature = "runtime-benchmarks")]
-impl Default for RuntimeParameters {
- fn default() -> Self {
- RuntimeParameters::Inflation(dynamic_params::inflation::Parameters::MinInflation(
- dynamic_params::inflation::MinInflation,
- Some(Perquintill::from_rational(25u64, 1000u64)),
- ))
- }
-}
-
-/// Defines what origin can modify which dynamic parameters.
-pub struct DynamicParameterOrigin;
-impl frame_support::traits::EnsureOriginWithArg
- for DynamicParameterOrigin
-{
- type Success = ();
-
- fn try_origin(
- origin: RuntimeOrigin,
- key: &RuntimeParametersKey,
- ) -> Result {
- use crate::RuntimeParametersKey::*;
-
- match key {
- Inflation(_) => frame_system::ensure_root(origin.clone()),
- }
- .map_err(|_| origin)
- }
-
- #[cfg(feature = "runtime-benchmarks")]
- fn try_successful_origin(_key: &RuntimeParametersKey) -> Result {
- // Provide the origin for the parameter returned by `Default`:
- Ok(RuntimeOrigin::root())
- }
-}
-
-impl pallet_parameters::Config for Runtime {
- type RuntimeEvent = RuntimeEvent;
- type RuntimeParameters = RuntimeParameters;
- type AdminOrigin = DynamicParameterOrigin;
- type WeightInfo = weights::pallet_parameters::WeightInfo;
-}
-
/// Defines how much should the inflation be for an era given its duration.
pub struct EraPayout;
impl pallet_staking::EraPayout for EraPayout {
@@ -1641,7 +1559,6 @@ construct_runtime! {
Referenda: pallet_referenda = 21,
Origins: pallet_custom_origins = 22,
Whitelist: pallet_whitelist = 23,
- Parameters: pallet_parameters = 27,
// Claims. Usable initially.
Claims: claims = 24,
@@ -2272,7 +2189,6 @@ mod benches {
);
}
-use relay_common::apis::InflationInfo;
impl Runtime {
fn impl_experimental_inflation_info() -> InflationInfo {
use pallet_staking::{ActiveEra, EraPayout, ErasTotalStake};
@@ -2281,20 +2197,6 @@ impl Runtime {
.unwrap_or((0, 0));
let stake_able_issuance = Balances::total_issuance();
- let ideal_staking_rate = dynamic_params::inflation::IdealStake::get();
- let inflation = if dynamic_params::inflation::UseAuctionSlots::get() {
- let auctioned_slots = parachains_paras::Parachains::::get()
- .into_iter()
- // all active para-ids that do not belong to a system chain is the number of
- // parachains that we should take into account for inflation.
- .filter(|i| *i >= LOWEST_PUBLIC_ID)
- .count() as u64;
- ideal_staking_rate
- .saturating_sub(Perquintill::from_rational(auctioned_slots.min(60), 300u64))
- } else {
- ideal_staking_rate
- };
-
// We assume un-delayed 24h eras.
let era_duration = 24 * (HOURS as Moment) * MILLISECS_PER_BLOCK;
let next_mint = ::EraPayout::era_payout(
@@ -2302,6 +2204,12 @@ impl Runtime {
stake_able_issuance,
era_duration,
);
+ // reverse-engineer the current inflation by looking at the total minted against the total
+ // issuance.
+ let inflation = Perquintill::from_rational(
+ (next_mint.0 + next_mint.1) * 36525 / 100,
+ stake_able_issuance,
+ );
InflationInfo { inflation, next_mint }
}
@@ -3750,9 +3658,6 @@ mod remote_tests {
// timestamp now
hex!("f0c365c3cf59d671eb72da0e7a4113c49f1f0515f462cdcf84e0f1d6045dfcbb")
.to_vec(),
- // para-ids
- hex!("cd710b30bd2eab0352ddcc26417aa1940b76934f4cc08dee01012d059e1b83ee")
- .to_vec(),
],
..Default::default()
}))
@@ -3783,13 +3688,9 @@ mod remote_tests {
log::info!(target: LOG_TARGET, "total-issuance = {:?}", token.amount(total_issuance));
log::info!(target: LOG_TARGET, "staking-rate = {:?}", Perquintill::from_rational(total_staked, total_issuance));
log::info!(target: LOG_TARGET, "era-duration = {:?}", average_era_duration_millis);
- log::info!(target: LOG_TARGET, "min-inflation = {:?}", dynamic_params::inflation::MinInflation::get());
- log::info!(target: LOG_TARGET, "max-inflation = {:?}", dynamic_params::inflation::MaxInflation::get());
- log::info!(target: LOG_TARGET, "falloff = {:?}", dynamic_params::inflation::Falloff::get());
- log::info!(target: LOG_TARGET, "useAuctionSlots = {:?}", dynamic_params::inflation::UseAuctionSlots::get());
- log::info!(target: LOG_TARGET, "idealStake = {:?}", dynamic_params::inflation::IdealStake::get());
log::info!(target: LOG_TARGET, "maxStakingRewards = {:?}", pallet_staking::MaxStakedRewards::::get());
log::info!(target: LOG_TARGET, "💰 Inflation ==> staking = {:?} / leftover = {:?}", token.amount(staking), token.amount(leftover));
+ log::info!(target: LOG_TARGET, "inflation_rate runtime API: {:?}", Runtime::impl_experimental_inflation_info());
});
}
}
diff --git a/relay/polkadot/src/weights/mod.rs b/relay/polkadot/src/weights/mod.rs
index 303bd12451..190b254db2 100644
--- a/relay/polkadot/src/weights/mod.rs
+++ b/relay/polkadot/src/weights/mod.rs
@@ -29,7 +29,6 @@ pub mod pallet_indices;
pub mod pallet_message_queue;
pub mod pallet_multisig;
pub mod pallet_nomination_pools;
-pub mod pallet_parameters;
pub mod pallet_preimage;
pub mod pallet_proxy;
pub mod pallet_referenda;
diff --git a/relay/polkadot/src/weights/pallet_message_queue.rs b/relay/polkadot/src/weights/pallet_message_queue.rs
index c604fe4ce2..1dec0176ac 100644
--- a/relay/polkadot/src/weights/pallet_message_queue.rs
+++ b/relay/polkadot/src/weights/pallet_message_queue.rs
@@ -17,24 +17,21 @@
//! Autogenerated weights for `pallet_message_queue`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
-//! DATE: 2024-08-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2024-10-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
-//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./polkadot-chain-spec.json")`, DB CACHE: 1024
+//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024
// Executed Command:
-// ./target/production/polkadot
+// frame-omni-bencher
+// v1
// benchmark
// pallet
-// --chain=./polkadot-chain-spec.json
-// --steps=50
-// --repeat=20
-// --pallet=pallet_message_queue
-// --extrinsic=*
-// --wasm-execution=compiled
-// --heap-pages=4096
-// --output=./polkadot-weights/
-// --header=./file_header.txt
+// --runtime=target/production/wbuild/polkadot-runtime/polkadot_runtime.compact.compressed.wasm
+// --pallet=pallet-message-queue
+// --extrinsic=
+// --output=relay/polkadot/src/weights/pallet_message_queue.rs
+// --header=.github/scripts/cmd/file_header.txt
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -55,8 +52,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `281`
// Estimated: `6050`
- // Minimum execution time: 15_420_000 picoseconds.
- Weight::from_parts(15_900_000, 0)
+ // Minimum execution time: 21_260_000 picoseconds.
+ Weight::from_parts(21_820_000, 0)
.saturating_add(Weight::from_parts(0, 6050))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
@@ -69,8 +66,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `281`
// Estimated: `6050`
- // Minimum execution time: 13_910_000 picoseconds.
- Weight::from_parts(14_340_000, 0)
+ // Minimum execution time: 19_380_000 picoseconds.
+ Weight::from_parts(19_750_000, 0)
.saturating_add(Weight::from_parts(0, 6050))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
@@ -81,8 +78,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `3520`
- // Minimum execution time: 4_780_000 picoseconds.
- Weight::from_parts(4_961_000, 0)
+ // Minimum execution time: 6_360_000 picoseconds.
+ Weight::from_parts(6_590_000, 0)
.saturating_add(Weight::from_parts(0, 3520))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -93,8 +90,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `115`
// Estimated: `69051`
- // Minimum execution time: 7_030_000 picoseconds.
- Weight::from_parts(7_180_000, 0)
+ // Minimum execution time: 9_390_000 picoseconds.
+ Weight::from_parts(9_580_000, 0)
.saturating_add(Weight::from_parts(0, 69051))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -105,8 +102,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `115`
// Estimated: `69051`
- // Minimum execution time: 7_170_000 picoseconds.
- Weight::from_parts(7_410_000, 0)
+ // Minimum execution time: 9_660_000 picoseconds.
+ Weight::from_parts(9_900_000, 0)
.saturating_add(Weight::from_parts(0, 69051))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -119,8 +116,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 155_692_000 picoseconds.
- Weight::from_parts(156_952_000, 0)
+ // Minimum execution time: 158_210_000 picoseconds.
+ Weight::from_parts(159_351_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -132,8 +129,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `220`
// Estimated: `3520`
- // Minimum execution time: 7_620_000 picoseconds.
- Weight::from_parts(7_960_000, 0)
+ // Minimum execution time: 11_020_000 picoseconds.
+ Weight::from_parts(11_390_000, 0)
.saturating_add(Weight::from_parts(0, 3520))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
@@ -150,8 +147,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `65714`
// Estimated: `69051`
- // Minimum execution time: 54_301_000 picoseconds.
- Weight::from_parts(54_911_000, 0)
+ // Minimum execution time: 63_110_000 picoseconds.
+ Weight::from_parts(63_761_000, 0)
.saturating_add(Weight::from_parts(0, 69051))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(4))
@@ -168,8 +165,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `65714`
// Estimated: `69051`
- // Minimum execution time: 71_631_000 picoseconds.
- Weight::from_parts(72_511_000, 0)
+ // Minimum execution time: 82_140_000 picoseconds.
+ Weight::from_parts(82_801_000, 0)
.saturating_add(Weight::from_parts(0, 69051))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(4))
@@ -186,8 +183,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `65714`
// Estimated: `69051`
- // Minimum execution time: 106_751_000 picoseconds.
- Weight::from_parts(107_831_000, 0)
+ // Minimum execution time: 118_451_000 picoseconds.
+ Weight::from_parts(119_610_000, 0)
.saturating_add(Weight::from_parts(0, 69051))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(4))
diff --git a/relay/polkadot/src/weights/pallet_parameters.rs b/relay/polkadot/src/weights/pallet_parameters.rs
deleted file mode 100644
index 4ecc2b213c..0000000000
--- a/relay/polkadot/src/weights/pallet_parameters.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md
-// for a list of specific contributors.
-// SPDX-License-Identifier: Apache-2.0
-
-//! Autogenerated weights for `pallet_parameters`
-//!
-//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
-//! DATE: 2024-04-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
-//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `runner-anb7yjbi-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
-//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polkadot-dev")`, DB CACHE: 1024
-
-// Executed Command:
-// target/production/polkadot
-// benchmark
-// pallet
-// --steps=50
-// --repeat=20
-// --extrinsic=*
-// --wasm-execution=compiled
-// --heap-pages=4096
-// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
-// --pallet=pallet_parameters
-// --chain=polkadot-dev
-// --header=./polkadot/file_header.txt
-// --output=./polkadot/runtime/polkadot/src/weights/
-
-#![cfg_attr(rustfmt, rustfmt_skip)]
-#![allow(unused_parens)]
-#![allow(unused_imports)]
-#![allow(missing_docs)]
-
-use frame_support::{traits::Get, weights::Weight};
-use core::marker::PhantomData;
-
-/// Weight functions for `pallet_parameters`.
-pub struct WeightInfo(PhantomData);
-impl pallet_parameters::WeightInfo for WeightInfo {
- /// Storage: `Parameters::Parameters` (r:1 w:1)
- /// Proof: `Parameters::Parameters` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
- fn set_parameter() -> Weight {
- // Proof Size summary in bytes:
- // Measured: `4`
- // Estimated: `3493`
- // Minimum execution time: 6_937_000 picoseconds.
- Weight::from_parts(7_242_000, 0)
- .saturating_add(Weight::from_parts(0, 3493))
- .saturating_add(T::DbWeight::get().reads(1))
- .saturating_add(T::DbWeight::get().writes(1))
- }
-}
diff --git a/relay/polkadot/tests/location_conversion.rs b/relay/polkadot/tests/location_conversion.rs
new file mode 100644
index 0000000000..bfa899bf5f
--- /dev/null
+++ b/relay/polkadot/tests/location_conversion.rs
@@ -0,0 +1,99 @@
+// Copyright (C) Parity Technologies (UK) Ltd.
+// This file is part of Polkadot.
+
+// Polkadot is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Polkadot is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Polkadot. If not, see .
+
+use polkadot_primitives::AccountId;
+use polkadot_runtime::xcm_config::SovereignAccountOf;
+use sp_core::crypto::Ss58Codec;
+use xcm::prelude::*;
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
+
+const ALICE: [u8; 32] = [1u8; 32];
+
+#[test]
+fn location_conversion_works() {
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Child",
+ location: Location::new(0, [Parachain(1111)]),
+ expected_account_id_str: "5Ec4AhP4h37t7TFsAZ4HhFq6k92usAAJDUC3ADSZ4H4Acru3",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Child",
+ location: Location::new(0, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5FjEBrKn3STAFsZpQF4jzwxUYHNGnNgzdZqSQfTzeJ82XKp6",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Child",
+ location: Location::new(
+ 0,
+ [
+ Parachain(1111),
+ Junction::AccountId32 { network: None, id: AccountId::from(ALICE).into() },
+ ],
+ ),
+ expected_account_id_str: "5D6CDyPd9Mya81xFN3nChiKqLvUzd8zS9fwKhfCW6FtJKjS2",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Child",
+ location: Location::new(
+ 0,
+ [Parachain(1111), AccountKey20 { network: None, key: [123u8; 20] }],
+ ),
+ expected_account_id_str: "5DEZsy7tsnNXB7ehLGkF8b4EUqfLQWqEzGiy2RrneC8uRNMK",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Child",
+ location: Location::new(
+ 0,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5GenE4vJgHvwYVcD6b4nBvH5HNY4pzpVHWoqwFpNMFT7a2oX",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Child",
+ location: Location::new(
+ 0,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DPgGBFTTYm1dGbtB1VWHJ3T3ScvdrskGGx6vSJZNP1WNStV",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected =
+ AccountId::from_string(tc.expected_account_id_str).expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}
diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
index 0ef1e15ccb..82e8113d34 100644
--- a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
+++ b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
@@ -121,7 +121,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
authoring_version: 1,
- spec_version: 1_003_003,
+ spec_version: 1_003_004,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 15,
@@ -137,7 +137,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
authoring_version: 1,
- spec_version: 1_003_003,
+ spec_version: 1_003_004,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 15,
diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/weights/pallet_message_queue.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/weights/pallet_message_queue.rs
index 258a5dfeb5..5e33b485b5 100644
--- a/system-parachains/asset-hubs/asset-hub-kusama/src/weights/pallet_message_queue.rs
+++ b/system-parachains/asset-hubs/asset-hub-kusama/src/weights/pallet_message_queue.rs
@@ -17,24 +17,23 @@
//! Autogenerated weights for `pallet_message_queue`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
-//! DATE: 2024-08-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2024-10-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
-//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./asset-hub-kusama-chain-spec.json")`, DB CACHE: 1024
+//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024
// Executed Command:
-// ./target/production/polkadot-parachain
+// frame-omni-bencher
+// v1
// benchmark
// pallet
-// --chain=./asset-hub-kusama-chain-spec.json
-// --steps=50
-// --repeat=20
-// --pallet=pallet_message_queue
-// --extrinsic=*
-// --wasm-execution=compiled
-// --heap-pages=4096
-// --output=./asset-hub-kusama-weights/
-// --header=./file_header.txt
+// --runtime
+// target/production/wbuild/asset-hub-kusama-runtime/asset_hub_kusama_runtime.compact.compressed.wasm
+// --pallet=pallet-message-queue
+// --extrinsic=
+// --output
+// system-parachains/asset-hubs/asset-hub-kusama/src/weights/pallet_message_queue.rs
+// --header=.github/scripts/cmd/file_header.txt
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -55,8 +54,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `260`
// Estimated: `6044`
- // Minimum execution time: 14_921_000 picoseconds.
- Weight::from_parts(15_280_000, 0)
+ // Minimum execution time: 19_600_000 picoseconds.
+ Weight::from_parts(19_990_000, 0)
.saturating_add(Weight::from_parts(0, 6044))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
@@ -69,8 +68,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `6044`
- // Minimum execution time: 13_091_000 picoseconds.
- Weight::from_parts(13_520_000, 0)
+ // Minimum execution time: 17_850_000 picoseconds.
+ Weight::from_parts(18_260_000, 0)
.saturating_add(Weight::from_parts(0, 6044))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
@@ -81,8 +80,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `3517`
- // Minimum execution time: 5_960_000 picoseconds.
- Weight::from_parts(6_170_000, 0)
+ // Minimum execution time: 7_840_000 picoseconds.
+ Weight::from_parts(8_040_000, 0)
.saturating_add(Weight::from_parts(0, 3517))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -93,8 +92,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `69050`
- // Minimum execution time: 8_190_000 picoseconds.
- Weight::from_parts(8_551_000, 0)
+ // Minimum execution time: 10_580_000 picoseconds.
+ Weight::from_parts(10_980_000, 0)
.saturating_add(Weight::from_parts(0, 69050))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -105,8 +104,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `69050`
- // Minimum execution time: 8_320_000 picoseconds.
- Weight::from_parts(8_631_000, 0)
+ // Minimum execution time: 10_830_000 picoseconds.
+ Weight::from_parts(11_060_000, 0)
.saturating_add(Weight::from_parts(0, 69050))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -119,8 +118,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 161_211_000 picoseconds.
- Weight::from_parts(162_281_000, 0)
+ // Minimum execution time: 157_500_000 picoseconds.
+ Weight::from_parts(158_551_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -132,8 +131,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `208`
// Estimated: `3517`
- // Minimum execution time: 8_820_000 picoseconds.
- Weight::from_parts(9_020_000, 0)
+ // Minimum execution time: 12_260_000 picoseconds.
+ Weight::from_parts(12_650_000, 0)
.saturating_add(Weight::from_parts(0, 3517))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
@@ -146,8 +145,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `65704`
// Estimated: `69050`
- // Minimum execution time: 59_711_000 picoseconds.
- Weight::from_parts(60_361_000, 0)
+ // Minimum execution time: 61_701_000 picoseconds.
+ Weight::from_parts(62_380_000, 0)
.saturating_add(Weight::from_parts(0, 69050))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -160,8 +159,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `65704`
// Estimated: `69050`
- // Minimum execution time: 76_311_000 picoseconds.
- Weight::from_parts(77_140_000, 0)
+ // Minimum execution time: 81_110_000 picoseconds.
+ Weight::from_parts(81_580_000, 0)
.saturating_add(Weight::from_parts(0, 69050))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -174,8 +173,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `65704`
// Estimated: `69050`
- // Minimum execution time: 111_441_000 picoseconds.
- Weight::from_parts(112_271_000, 0)
+ // Minimum execution time: 114_360_000 picoseconds.
+ Weight::from_parts(115_500_000, 0)
.saturating_add(Weight::from_parts(0, 69050))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
diff --git a/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs b/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs
index 4ae5e17a73..13907fa8e1 100644
--- a/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs
+++ b/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs
@@ -37,6 +37,7 @@ use frame_support::{assert_ok, traits::fungibles::InspectEnumerable};
use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance};
use parachains_runtimes_test_utils::SlotDurations;
use sp_consensus_aura::SlotDuration;
+use sp_core::crypto::Ss58Codec;
use sp_runtime::traits::MaybeEquivalence;
use sp_std::ops::Mul;
use system_parachains_constants::kusama::{
@@ -45,6 +46,7 @@ use system_parachains_constants::kusama::{
use xcm::latest::prelude::{Assets as XcmAssets, *};
use xcm_builder::WithLatestLocationConverter;
use xcm_executor::traits::{ConvertLocation, JustTry};
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
const ALICE: [u8; 32] = [1u8; 32];
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
@@ -1303,3 +1305,104 @@ pub mod remove_when_updated_to_stable2409 {
})
}
}
+
+#[test]
+fn location_conversion_works() {
+ let alice_32 =
+ AccountId32 { network: None, id: polkadot_core_primitives::AccountId::from(ALICE).into() };
+ let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };
+
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Parent",
+ location: Location::new(1, Here),
+ expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
+ },
+ TestCase {
+ description: "DescribeTerminus Sibling",
+ location: Location::new(1, [Parachain(1111)]),
+ expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Parent",
+ location: Location::new(1, [PalletInstance(50)]),
+ expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
+ },
+ TestCase {
+ description: "DescribePalletTerminal Sibling",
+ location: Location::new(1, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Parent",
+ location: Location::new(1, [alice_32]),
+ expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
+ },
+ TestCase {
+ description: "DescribeAccountId32Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), alice_32]),
+ expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Parent",
+ location: Location::new(1, [bob_20]),
+ expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
+ },
+ TestCase {
+ description: "DescribeAccountKey20Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), bob_20]),
+ expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
+ expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
+ },
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
+ expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
+ },
+ TestCase {
+ description: "DescribeBodyTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected = polkadot_core_primitives::AccountId::from_string(tc.expected_account_id_str)
+ .expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}
diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
index 6c42ceac92..e6760f29b0 100644
--- a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
+++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
@@ -155,7 +155,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemint"),
impl_name: create_runtime_str!("statemint"),
authoring_version: 1,
- spec_version: 1_003_003,
+ spec_version: 1_003_004,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 15,
diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/pallet_message_queue.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/pallet_message_queue.rs
index 949dddb347..08a007669a 100644
--- a/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/pallet_message_queue.rs
+++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/pallet_message_queue.rs
@@ -17,24 +17,23 @@
//! Autogenerated weights for `pallet_message_queue`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
-//! DATE: 2024-08-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2024-10-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
-//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./asset-hub-polkadot-chain-spec.json")`, DB CACHE: 1024
+//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024
// Executed Command:
-// ./target/production/polkadot-parachain
+// frame-omni-bencher
+// v1
// benchmark
// pallet
-// --chain=./asset-hub-polkadot-chain-spec.json
-// --steps=50
-// --repeat=20
-// --pallet=pallet_message_queue
-// --extrinsic=*
-// --wasm-execution=compiled
-// --heap-pages=4096
-// --output=./asset-hub-polkadot-weights/
-// --header=./file_header.txt
+// --runtime
+// target/production/wbuild/asset-hub-polkadot-runtime/asset_hub_polkadot_runtime.compact.compressed.wasm
+// --pallet=pallet-message-queue
+// --extrinsic=
+// --output
+// system-parachains/asset-hubs/asset-hub-polkadot/src/weights/pallet_message_queue.rs
+// --header=.github/scripts/cmd/file_header.txt
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -55,8 +54,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `260`
// Estimated: `6044`
- // Minimum execution time: 14_740_000 picoseconds.
- Weight::from_parts(15_120_000, 0)
+ // Minimum execution time: 19_870_000 picoseconds.
+ Weight::from_parts(20_150_000, 0)
.saturating_add(Weight::from_parts(0, 6044))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
@@ -69,8 +68,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `6044`
- // Minimum execution time: 13_030_000 picoseconds.
- Weight::from_parts(13_470_000, 0)
+ // Minimum execution time: 18_080_000 picoseconds.
+ Weight::from_parts(18_301_000, 0)
.saturating_add(Weight::from_parts(0, 6044))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
@@ -81,8 +80,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `3517`
- // Minimum execution time: 5_920_000 picoseconds.
- Weight::from_parts(6_130_000, 0)
+ // Minimum execution time: 7_820_000 picoseconds.
+ Weight::from_parts(8_070_000, 0)
.saturating_add(Weight::from_parts(0, 3517))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -93,8 +92,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `69050`
- // Minimum execution time: 8_230_000 picoseconds.
- Weight::from_parts(8_490_000, 0)
+ // Minimum execution time: 10_530_000 picoseconds.
+ Weight::from_parts(10_820_000, 0)
.saturating_add(Weight::from_parts(0, 69050))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -105,8 +104,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `69050`
- // Minimum execution time: 8_340_000 picoseconds.
- Weight::from_parts(8_600_000, 0)
+ // Minimum execution time: 10_650_000 picoseconds.
+ Weight::from_parts(11_050_000, 0)
.saturating_add(Weight::from_parts(0, 69050))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -119,8 +118,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 156_191_000 picoseconds.
- Weight::from_parts(157_371_000, 0)
+ // Minimum execution time: 161_831_000 picoseconds.
+ Weight::from_parts(162_761_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -132,8 +131,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `208`
// Estimated: `3517`
- // Minimum execution time: 8_661_000 picoseconds.
- Weight::from_parts(8_900_000, 0)
+ // Minimum execution time: 12_210_000 picoseconds.
+ Weight::from_parts(12_511_000, 0)
.saturating_add(Weight::from_parts(0, 3517))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
@@ -146,8 +145,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `65704`
// Estimated: `69050`
- // Minimum execution time: 53_740_000 picoseconds.
- Weight::from_parts(54_180_000, 0)
+ // Minimum execution time: 66_210_000 picoseconds.
+ Weight::from_parts(66_961_000, 0)
.saturating_add(Weight::from_parts(0, 69050))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -160,8 +159,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `65704`
// Estimated: `69050`
- // Minimum execution time: 71_451_000 picoseconds.
- Weight::from_parts(72_250_000, 0)
+ // Minimum execution time: 85_680_000 picoseconds.
+ Weight::from_parts(86_270_000, 0)
.saturating_add(Weight::from_parts(0, 69050))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -174,8 +173,8 @@ impl pallet_message_queue::WeightInfo for WeightInfo
// Proof Size summary in bytes:
// Measured: `65704`
// Estimated: `69050`
- // Minimum execution time: 106_120_000 picoseconds.
- Weight::from_parts(107_530_000, 0)
+ // Minimum execution time: 119_101_000 picoseconds.
+ Weight::from_parts(120_431_000, 0)
.saturating_add(Weight::from_parts(0, 69050))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs b/system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs
index 63cb71cfad..4cb83a2b0d 100644
--- a/system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs
+++ b/system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs
@@ -39,6 +39,7 @@ use parachains_common::{
};
use parachains_runtimes_test_utils::SlotDurations;
use sp_consensus_aura::SlotDuration;
+use sp_core::crypto::Ss58Codec;
use sp_runtime::traits::MaybeEquivalence;
use sp_std::ops::Mul;
use system_parachains_constants::{
@@ -47,6 +48,7 @@ use system_parachains_constants::{
use xcm::latest::prelude::{Assets as XcmAssets, *};
use xcm_builder::WithLatestLocationConverter;
use xcm_executor::traits::{ConvertLocation, JustTry};
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
const ALICE: [u8; 32] = [1u8; 32];
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
@@ -1327,3 +1329,104 @@ pub mod remove_when_updated_to_stable2409 {
})
}
}
+
+#[test]
+fn location_conversion_works() {
+ let alice_32 =
+ AccountId32 { network: None, id: polkadot_core_primitives::AccountId::from(ALICE).into() };
+ let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };
+
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Parent",
+ location: Location::new(1, Here),
+ expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
+ },
+ TestCase {
+ description: "DescribeTerminus Sibling",
+ location: Location::new(1, [Parachain(1111)]),
+ expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Parent",
+ location: Location::new(1, [PalletInstance(50)]),
+ expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
+ },
+ TestCase {
+ description: "DescribePalletTerminal Sibling",
+ location: Location::new(1, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Parent",
+ location: Location::new(1, [alice_32]),
+ expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
+ },
+ TestCase {
+ description: "DescribeAccountId32Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), alice_32]),
+ expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Parent",
+ location: Location::new(1, [bob_20]),
+ expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
+ },
+ TestCase {
+ description: "DescribeAccountKey20Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), bob_20]),
+ expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
+ expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
+ },
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
+ expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
+ },
+ TestCase {
+ description: "DescribeBodyTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected = polkadot_core_primitives::AccountId::from_string(tc.expected_account_id_str)
+ .expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}
diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs
index 805f8cb051..e2525e6d87 100644
--- a/system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs
+++ b/system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs
@@ -36,6 +36,7 @@ use codec::{Decode, Encode};
use frame_support::{dispatch::GetDispatchInfo, parameter_types, traits::ConstU8};
use parachains_common::{AccountId, AuraId, Balance};
use sp_consensus_aura::SlotDuration;
+use sp_core::crypto::Ss58Codec;
use sp_keyring::AccountKeyring::Alice;
use sp_runtime::{
generic::{Era, SignedPayload},
@@ -46,6 +47,7 @@ use system_parachains_constants::kusama::{
};
use xcm::latest::prelude::*;
use xcm_executor::traits::ConvertLocation;
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
// Para id of sibling chain used in tests.
pub const SIBLING_PARACHAIN_ID: u32 = 1000;
@@ -367,3 +369,106 @@ fn treasury_pallet_account_not_none() {
LocationToAccountId::convert_location(&RelayTreasuryLocation::get()).unwrap()
)
}
+
+#[test]
+fn location_conversion_works() {
+ let alice_32 = xcm::prelude::AccountId32 {
+ network: None,
+ id: polkadot_core_primitives::AccountId::from(Alice).into(),
+ };
+ let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };
+
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Parent",
+ location: Location::new(1, Here),
+ expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
+ },
+ TestCase {
+ description: "DescribeTerminus Sibling",
+ location: Location::new(1, [Parachain(1111)]),
+ expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Parent",
+ location: Location::new(1, [PalletInstance(50)]),
+ expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
+ },
+ TestCase {
+ description: "DescribePalletTerminal Sibling",
+ location: Location::new(1, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Parent",
+ location: Location::new(1, [alice_32]),
+ expected_account_id_str: "5EueAXd4h8u75nSbFdDJbC29cmi4Uo1YJssqEL9idvindxFL",
+ },
+ TestCase {
+ description: "DescribeAccountId32Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), alice_32]),
+ expected_account_id_str: "5Dmbuiq48fU4iW58FKYqoGbbfxFHjbAeGLMtjFg6NNCw3ssr",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Parent",
+ location: Location::new(1, [bob_20]),
+ expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
+ },
+ TestCase {
+ description: "DescribeAccountKey20Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), bob_20]),
+ expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
+ expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
+ },
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
+ expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
+ },
+ TestCase {
+ description: "DescribeBodyTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected = polkadot_core_primitives::AccountId::from_string(tc.expected_account_id_str)
+ .expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}
diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs
index c3301047cd..956604c200 100644
--- a/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs
+++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs
@@ -37,6 +37,7 @@ use codec::{Decode, Encode};
use frame_support::{dispatch::GetDispatchInfo, parameter_types, traits::ConstU8};
use parachains_common::{AccountId, AuraId, Balance};
use sp_consensus_aura::SlotDuration;
+use sp_core::crypto::Ss58Codec;
use sp_keyring::AccountKeyring::Alice;
use sp_runtime::{
generic::{Era, SignedPayload},
@@ -47,6 +48,7 @@ use system_parachains_constants::polkadot::{
};
use xcm::latest::prelude::*;
use xcm_executor::traits::ConvertLocation;
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
// Para id of sibling chain used in tests.
pub const SIBLING_PARACHAIN_ID: u32 = 1000;
@@ -368,3 +370,106 @@ fn treasury_pallet_account_not_none() {
LocationToAccountId::convert_location(&RelayTreasuryLocation::get()).unwrap()
)
}
+
+#[test]
+fn location_conversion_works() {
+ let alice_32 = xcm::prelude::AccountId32 {
+ network: None,
+ id: polkadot_core_primitives::AccountId::from(Alice).into(),
+ };
+ let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };
+
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Parent",
+ location: Location::new(1, Here),
+ expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
+ },
+ TestCase {
+ description: "DescribeTerminus Sibling",
+ location: Location::new(1, [Parachain(1111)]),
+ expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Parent",
+ location: Location::new(1, [PalletInstance(50)]),
+ expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
+ },
+ TestCase {
+ description: "DescribePalletTerminal Sibling",
+ location: Location::new(1, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Parent",
+ location: Location::new(1, [alice_32]),
+ expected_account_id_str: "5EueAXd4h8u75nSbFdDJbC29cmi4Uo1YJssqEL9idvindxFL",
+ },
+ TestCase {
+ description: "DescribeAccountId32Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), alice_32]),
+ expected_account_id_str: "5Dmbuiq48fU4iW58FKYqoGbbfxFHjbAeGLMtjFg6NNCw3ssr",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Parent",
+ location: Location::new(1, [bob_20]),
+ expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
+ },
+ TestCase {
+ description: "DescribeAccountKey20Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), bob_20]),
+ expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
+ expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
+ },
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
+ expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
+ },
+ TestCase {
+ description: "DescribeBodyTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected = polkadot_core_primitives::AccountId::from_string(tc.expected_account_id_str)
+ .expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}
diff --git a/system-parachains/collectives/collectives-polkadot/tests/location_conversion.rs b/system-parachains/collectives/collectives-polkadot/tests/location_conversion.rs
new file mode 100644
index 0000000000..21c3315916
--- /dev/null
+++ b/system-parachains/collectives/collectives-polkadot/tests/location_conversion.rs
@@ -0,0 +1,123 @@
+// Copyright (C) Parity Technologies (UK) Ltd.
+// This file is part of Polkadot.
+
+// Polkadot is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Polkadot is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Polkadot. If not, see .
+
+use collectives_polkadot_runtime::xcm_config::LocationToAccountId;
+use polkadot_core_primitives::AccountId;
+use sp_core::crypto::Ss58Codec;
+use xcm::prelude::*;
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
+
+const ALICE: [u8; 32] = [1u8; 32];
+
+#[test]
+fn location_conversion_works() {
+ let alice_32 = AccountId32 { network: None, id: AccountId::from(ALICE).into() };
+ let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };
+
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Parent",
+ location: Location::new(1, Here),
+ expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
+ },
+ TestCase {
+ description: "DescribeTerminus Sibling",
+ location: Location::new(1, [Parachain(1111)]),
+ expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Parent",
+ location: Location::new(1, [PalletInstance(50)]),
+ expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
+ },
+ TestCase {
+ description: "DescribePalletTerminal Sibling",
+ location: Location::new(1, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Parent",
+ location: Location::new(1, [alice_32]),
+ expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
+ },
+ TestCase {
+ description: "DescribeAccountId32Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), alice_32]),
+ expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Parent",
+ location: Location::new(1, [bob_20]),
+ expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
+ },
+ TestCase {
+ description: "DescribeAccountKey20Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), bob_20]),
+ expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
+ expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
+ },
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
+ expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
+ },
+ TestCase {
+ description: "DescribeBodyTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected =
+ AccountId::from_string(tc.expected_account_id_str).expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}
diff --git a/system-parachains/coretime/coretime-kusama/src/tests.rs b/system-parachains/coretime/coretime-kusama/src/tests.rs
index 0253477c2e..0ccccbdac4 100644
--- a/system-parachains/coretime/coretime-kusama/src/tests.rs
+++ b/system-parachains/coretime/coretime-kusama/src/tests.rs
@@ -16,6 +16,7 @@
use crate::{
coretime::{BrokerPalletId, CoretimeBurnAccount},
+ xcm_config::LocationToAccountId,
*,
};
use coretime::CoretimeAllocator;
@@ -29,7 +30,11 @@ use frame_support::{
use kusama_runtime_constants::system_parachain::coretime::TIMESLICE_PERIOD;
use pallet_broker::{ConfigRecordOf, RCBlockNumberOf, SaleInfo};
use parachains_runtimes_test_utils::ExtBuilder;
+use sp_core::crypto::Ss58Codec;
use sp_runtime::traits::AccountIdConversion;
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
+
+const ALICE: [u8; 32] = [1u8; 32];
fn advance_to(b: BlockNumber) {
while System::block_number() < b {
@@ -41,8 +46,6 @@ fn advance_to(b: BlockNumber) {
#[test]
fn bulk_revenue_is_burnt() {
- const ALICE: [u8; 32] = [1u8; 32];
-
ExtBuilder::::default()
.with_collators(vec![AccountId::from(ALICE)])
.with_session_keys(vec![(
@@ -110,3 +113,104 @@ fn timeslice_period_is_sane() {
#[cfg(not(feature = "fast-runtime"))]
assert_eq!(TIMESLICE_PERIOD, 80);
}
+
+#[test]
+fn location_conversion_works() {
+ let alice_32 =
+ AccountId32 { network: None, id: polkadot_core_primitives::AccountId::from(ALICE).into() };
+ let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };
+
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Parent",
+ location: Location::new(1, Here),
+ expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
+ },
+ TestCase {
+ description: "DescribeTerminus Sibling",
+ location: Location::new(1, [Parachain(1111)]),
+ expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Parent",
+ location: Location::new(1, [PalletInstance(50)]),
+ expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
+ },
+ TestCase {
+ description: "DescribePalletTerminal Sibling",
+ location: Location::new(1, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Parent",
+ location: Location::new(1, [alice_32]),
+ expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
+ },
+ TestCase {
+ description: "DescribeAccountId32Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), alice_32]),
+ expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Parent",
+ location: Location::new(1, [bob_20]),
+ expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
+ },
+ TestCase {
+ description: "DescribeAccountKey20Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), bob_20]),
+ expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
+ expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
+ },
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
+ expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
+ },
+ TestCase {
+ description: "DescribeBodyTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected = polkadot_core_primitives::AccountId::from_string(tc.expected_account_id_str)
+ .expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}
diff --git a/system-parachains/coretime/coretime-polkadot/src/tests.rs b/system-parachains/coretime/coretime-polkadot/src/tests.rs
index 3ec85da4b2..cb5a4217c6 100644
--- a/system-parachains/coretime/coretime-polkadot/src/tests.rs
+++ b/system-parachains/coretime/coretime-polkadot/src/tests.rs
@@ -16,6 +16,7 @@
use crate::{
coretime::{BrokerPalletId, CoretimeBurnAccount},
+ xcm_config::LocationToAccountId,
*,
};
use coretime::CoretimeAllocator;
@@ -29,7 +30,11 @@ use frame_support::{
use pallet_broker::{ConfigRecordOf, RCBlockNumberOf, SaleInfo};
use parachains_runtimes_test_utils::ExtBuilder;
use polkadot_runtime_constants::system_parachain::coretime::TIMESLICE_PERIOD;
+use sp_core::crypto::Ss58Codec;
use sp_runtime::traits::AccountIdConversion;
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
+
+const ALICE: [u8; 32] = [1u8; 32];
fn advance_to(b: BlockNumber) {
while System::block_number() < b {
@@ -41,8 +46,6 @@ fn advance_to(b: BlockNumber) {
#[test]
fn bulk_revenue_is_burnt() {
- const ALICE: [u8; 32] = [1u8; 32];
-
ExtBuilder::::default()
.with_collators(vec![AccountId::from(ALICE)])
.with_session_keys(vec![(
@@ -110,3 +113,104 @@ fn timeslice_period_is_sane() {
#[cfg(not(feature = "fast-runtime"))]
assert_eq!(TIMESLICE_PERIOD, 80);
}
+
+#[test]
+fn location_conversion_works() {
+ let alice_32 =
+ AccountId32 { network: None, id: polkadot_core_primitives::AccountId::from(ALICE).into() };
+ let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };
+
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Parent",
+ location: Location::new(1, Here),
+ expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
+ },
+ TestCase {
+ description: "DescribeTerminus Sibling",
+ location: Location::new(1, [Parachain(1111)]),
+ expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Parent",
+ location: Location::new(1, [PalletInstance(50)]),
+ expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
+ },
+ TestCase {
+ description: "DescribePalletTerminal Sibling",
+ location: Location::new(1, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Parent",
+ location: Location::new(1, [alice_32]),
+ expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
+ },
+ TestCase {
+ description: "DescribeAccountId32Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), alice_32]),
+ expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Parent",
+ location: Location::new(1, [bob_20]),
+ expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
+ },
+ TestCase {
+ description: "DescribeAccountKey20Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), bob_20]),
+ expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
+ expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
+ },
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
+ expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
+ },
+ TestCase {
+ description: "DescribeBodyTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected = polkadot_core_primitives::AccountId::from_string(tc.expected_account_id_str)
+ .expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}
diff --git a/system-parachains/encointer/src/lib.rs b/system-parachains/encointer/src/lib.rs
index f93906d02e..60f1054172 100644
--- a/system-parachains/encointer/src/lib.rs
+++ b/system-parachains/encointer/src/lib.rs
@@ -131,7 +131,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("encointer-parachain"),
impl_name: create_runtime_str!("encointer-parachain"),
authoring_version: 1,
- spec_version: 1_003_003,
+ spec_version: 1_003_004,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 4,
diff --git a/system-parachains/people/people-kusama/src/lib.rs b/system-parachains/people/people-kusama/src/lib.rs
index 619cd0422d..3390839256 100644
--- a/system-parachains/people/people-kusama/src/lib.rs
+++ b/system-parachains/people/people-kusama/src/lib.rs
@@ -21,6 +21,8 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
// Genesis preset configurations.
pub mod genesis_config_presets;
pub mod people;
+#[cfg(test)]
+mod tests;
mod weights;
pub mod xcm_config;
diff --git a/system-parachains/people/people-kusama/src/tests.rs b/system-parachains/people/people-kusama/src/tests.rs
new file mode 100644
index 0000000000..7b459977e6
--- /dev/null
+++ b/system-parachains/people/people-kusama/src/tests.rs
@@ -0,0 +1,123 @@
+// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md
+// for a list of specific contributors.
+// 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.
+
+use crate::xcm_config::LocationToAccountId;
+use polkadot_primitives::AccountId;
+use sp_core::crypto::Ss58Codec;
+use xcm::prelude::*;
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
+
+const ALICE: [u8; 32] = [1u8; 32];
+
+#[test]
+fn location_conversion_works() {
+ let alice_32 = AccountId32 { network: None, id: AccountId::from(ALICE).into() };
+ let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };
+
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Parent",
+ location: Location::new(1, Here),
+ expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
+ },
+ TestCase {
+ description: "DescribeTerminus Sibling",
+ location: Location::new(1, [Parachain(1111)]),
+ expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Parent",
+ location: Location::new(1, [PalletInstance(50)]),
+ expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
+ },
+ TestCase {
+ description: "DescribePalletTerminal Sibling",
+ location: Location::new(1, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Parent",
+ location: Location::new(1, [alice_32]),
+ expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
+ },
+ TestCase {
+ description: "DescribeAccountId32Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), alice_32]),
+ expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Parent",
+ location: Location::new(1, [bob_20]),
+ expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
+ },
+ TestCase {
+ description: "DescribeAccountKey20Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), bob_20]),
+ expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
+ expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
+ },
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
+ expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
+ },
+ TestCase {
+ description: "DescribeBodyTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected =
+ AccountId::from_string(tc.expected_account_id_str).expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}
diff --git a/system-parachains/people/people-polkadot/src/lib.rs b/system-parachains/people/people-polkadot/src/lib.rs
index 4dd70c027b..a439971e5f 100644
--- a/system-parachains/people/people-polkadot/src/lib.rs
+++ b/system-parachains/people/people-polkadot/src/lib.rs
@@ -21,6 +21,8 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
// Genesis preset configurations.
pub mod genesis_config_presets;
pub mod people;
+#[cfg(test)]
+mod tests;
mod weights;
pub mod xcm_config;
diff --git a/system-parachains/people/people-polkadot/src/tests.rs b/system-parachains/people/people-polkadot/src/tests.rs
new file mode 100644
index 0000000000..7e0d7d61a7
--- /dev/null
+++ b/system-parachains/people/people-polkadot/src/tests.rs
@@ -0,0 +1,123 @@
+// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md
+// for a list of specific contributors.
+// 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.
+
+use crate::xcm_config::LocationToAccountId;
+use cumulus_primitives_core::relay_chain::AccountId;
+use sp_core::crypto::Ss58Codec;
+use xcm::prelude::*;
+use xcm_runtime_apis::conversions::LocationToAccountHelper;
+
+const ALICE: [u8; 32] = [1u8; 32];
+
+#[test]
+fn location_conversion_works() {
+ let alice_32 = AccountId32 { network: None, id: AccountId::from(ALICE).into() };
+ let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };
+
+ // the purpose of hardcoded values is to catch an unintended location conversion logic change.
+ struct TestCase {
+ description: &'static str,
+ location: Location,
+ expected_account_id_str: &'static str,
+ }
+
+ let test_cases = vec![
+ // DescribeTerminus
+ TestCase {
+ description: "DescribeTerminus Parent",
+ location: Location::new(1, Here),
+ expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
+ },
+ TestCase {
+ description: "DescribeTerminus Sibling",
+ location: Location::new(1, [Parachain(1111)]),
+ expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
+ },
+ // DescribePalletTerminal
+ TestCase {
+ description: "DescribePalletTerminal Parent",
+ location: Location::new(1, [PalletInstance(50)]),
+ expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
+ },
+ TestCase {
+ description: "DescribePalletTerminal Sibling",
+ location: Location::new(1, [Parachain(1111), PalletInstance(50)]),
+ expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
+ },
+ // DescribeAccountId32Terminal
+ TestCase {
+ description: "DescribeAccountId32Terminal Parent",
+ location: Location::new(1, [alice_32]),
+ expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
+ },
+ TestCase {
+ description: "DescribeAccountId32Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), alice_32]),
+ expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
+ },
+ // DescribeAccountKey20Terminal
+ TestCase {
+ description: "DescribeAccountKey20Terminal Parent",
+ location: Location::new(1, [bob_20]),
+ expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
+ },
+ TestCase {
+ description: "DescribeAccountKey20Terminal Sibling",
+ location: Location::new(1, [Parachain(1111), bob_20]),
+ expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
+ },
+ // DescribeTreasuryVoiceTerminal
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
+ expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
+ },
+ TestCase {
+ description: "DescribeTreasuryVoiceTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
+ },
+ // DescribeBodyTerminal
+ TestCase {
+ description: "DescribeBodyTerminal Parent",
+ location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
+ expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
+ },
+ TestCase {
+ description: "DescribeBodyTerminal Sibling",
+ location: Location::new(
+ 1,
+ [Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
+ ),
+ expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
+ },
+ ];
+
+ for tc in test_cases {
+ let expected =
+ AccountId::from_string(tc.expected_account_id_str).expect("Invalid AccountId string");
+
+ let got = LocationToAccountHelper::::convert_location(
+ tc.location.into(),
+ )
+ .unwrap();
+
+ assert_eq!(got, expected, "{}", tc.description);
+ }
+}