Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove (rococo/westend)-runtime deps from testnet AssetHubs #1979

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ sp-weights = { path = "../../../../../substrate/primitives/weights", default-fea
primitive-types = { version = "0.12.1", default-features = false, features = ["codec", "scale-info", "num-traits"] }

# Polkadot
rococo-runtime = { path = "../../../../../polkadot/runtime/rococo", default-features = false }
rococo-runtime-constants = { path = "../../../../../polkadot/runtime/rococo/constants", default-features = false}
pallet-xcm = { path = "../../../../../polkadot/xcm/pallet-xcm", default-features = false}
pallet-xcm-benchmarks = { path = "../../../../../polkadot/xcm/pallet-xcm-benchmarks", default-features = false, optional = true }
Expand Down Expand Up @@ -131,7 +130,6 @@ runtime-benchmarks = [
"parachains-common/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"rococo-runtime/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
Expand Down Expand Up @@ -167,7 +165,6 @@ try-runtime = [
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
"polkadot-runtime-common/try-runtime",
"rococo-runtime/try-runtime",
"sp-runtime/try-runtime",
]
std = [
Expand Down Expand Up @@ -221,7 +218,6 @@ std = [
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"rococo-runtime-constants/std",
"rococo-runtime/std",
"scale-info/std",
"sp-api/std",
"sp-block-builder/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use parachains_common::{
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use rococo_runtime::Treasury as RococoTreasury;
use rococo_runtime_constants::system_parachain::SystemParachains;
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
use xcm::latest::prelude::*;
Expand Down Expand Up @@ -532,7 +531,7 @@ pub type ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger =
>;

parameter_types! {
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(<RococoTreasury as PalletInfoAccess>::index() as u8)).into();
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
}

pub struct RelayTreasury;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ polkadot-core-primitives = { path = "../../../../../polkadot/core-primitives", d
polkadot-parachain-primitives = { path = "../../../../../polkadot/parachain", default-features = false}
polkadot-runtime-common = { path = "../../../../../polkadot/runtime/common", default-features = false}
westend-runtime-constants = { path = "../../../../../polkadot/runtime/westend/constants", default-features = false}
westend-runtime = { path = "../../../../../polkadot/runtime/westend", default-features = false }
xcm = { package = "staging-xcm", path = "../../../../../polkadot/xcm", default-features = false}
xcm-builder = { package = "staging-xcm-builder", path = "../../../../../polkadot/xcm/xcm-builder", default-features = false}
xcm-executor = { package = "staging-xcm-executor", path = "../../../../../polkadot/xcm/xcm-executor", default-features = false}
Expand Down Expand Up @@ -117,7 +116,6 @@ runtime-benchmarks = [
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"westend-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
]
Expand Down Expand Up @@ -151,7 +149,6 @@ try-runtime = [
"parachain-info/try-runtime",
"polkadot-runtime-common/try-runtime",
"sp-runtime/try-runtime",
"westend-runtime/try-runtime",
]
std = [
"assets-common/std",
Expand Down Expand Up @@ -213,7 +210,6 @@ std = [
"sp-version/std",
"substrate-wasm-builder",
"westend-runtime-constants/std",
"westend-runtime/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use parachains_common::{
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
use westend_runtime::Treasury as WestendTreasury;
use westend_runtime_constants::system_parachain;
use xcm::latest::prelude::*;
use xcm_builder::{
Expand Down Expand Up @@ -506,7 +505,7 @@ match_types! {
}

parameter_types! {
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(<WestendTreasury as PalletInfoAccess>::index() as u8)).into();
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
}

pub struct RelayTreasury;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,23 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;

parameter_types! {
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
}

pub struct RelayTreasury;
impl Contains<MultiLocation> for RelayTreasury {
fn contains(location: &MultiLocation) -> bool {
let relay_treasury_location = RelayTreasuryLocation::get();
*location == relay_treasury_location
}
}

/// Locations that will not be charged fees in the executor,
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (RelayOrOtherSystemParachains<SystemParachains, Runtime>, RelayTreasury);
bkontur marked this conversation as resolved.
Show resolved Hide resolved

/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
/// - NativeToken with the parent Relay Chain and sibling parachains.
pub type TrustedTeleporters = ConcreteAssetFromSystem<TokenLocation>;
Expand Down Expand Up @@ -262,12 +279,7 @@ impl xcm_executor::Config for XcmConfig {
type SubscriptionService = PolkadotXcm;
type PalletInstancesInfo = AllPalletsWithSystem;
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
type FeeManager = XcmFeesToAccount<
Self,
RelayOrOtherSystemParachains<SystemParachains, Runtime>,
AccountId,
TreasuryAccount,
>;
type FeeManager = XcmFeesToAccount<Self, WaivedLocations, AccountId, TreasuryAccount>;
type MessageExporter = BridgeHubRococoOrBridgeHubWococoSwitchExporter;
type UniversalAliases = Nothing;
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
Expand Down
3 changes: 3 additions & 0 deletions polkadot/runtime/rococo/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ pub mod system_parachain {
}
}

/// Rococo Treasury pallet instance.
pub const TREASURY_PALLET_ID: u8 = 18;

#[cfg(test)]
mod tests {
use super::{
Expand Down
59 changes: 3 additions & 56 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ use governance::{
TreasurySpender,
};

#[cfg(test)]
mod tests;

mod validator_manager;

impl_runtime_weights!(rococo_runtime_constants);
Expand Down Expand Up @@ -2204,62 +2207,6 @@ sp_api::impl_runtime_apis! {
}
}

#[cfg(test)]
mod tests {
use std::collections::HashSet;

use super::*;
use frame_support::traits::WhitelistedStorageKeys;
use sp_core::hexdisplay::HexDisplay;

#[test]
fn check_whitelist() {
let whitelist: HashSet<String> = AllPalletsWithSystem::whitelisted_storage_keys()
.iter()
.map(|e| HexDisplay::from(&e.key).to_string())
.collect();

// Block number
assert!(
whitelist.contains("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac")
);
// Total issuance
assert!(
whitelist.contains("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80")
);
// Execution phase
assert!(
whitelist.contains("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a")
);
// Event count
assert!(
whitelist.contains("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850")
);
// System events
assert!(
whitelist.contains("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7")
);
// XcmPallet VersionDiscoveryQueue
assert!(
whitelist.contains("1405f2411d0af5a7ff397e7c9dc68d194a222ba0333561192e474c59ed8e30e1")
);
// XcmPallet SafeXcmVersion
assert!(
whitelist.contains("1405f2411d0af5a7ff397e7c9dc68d196323ae84c43568be0d1394d5d0d522c4")
);
}
}

#[cfg(test)]
mod encoding_tests {
use super::*;

#[test]
fn nis_hold_reason_encoding_is_correct() {
assert_eq!(RuntimeHoldReason::Nis(pallet_nis::HoldReason::NftReceipt).encode(), [38, 0]);
}
}

#[cfg(all(test, feature = "try-runtime"))]
mod remote_tests {
use super::*;
Expand Down
63 changes: 63 additions & 0 deletions polkadot/runtime/rococo/src/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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 <http://www.gnu.org/licenses/>.

//! Tests for the Rococo Runtime Configuration

use crate::*;
use std::collections::HashSet;

use frame_support::traits::WhitelistedStorageKeys;
use sp_core::hexdisplay::HexDisplay;

#[test]
fn check_whitelist() {
let whitelist: HashSet<String> = AllPalletsWithSystem::whitelisted_storage_keys()
.iter()
.map(|e| HexDisplay::from(&e.key).to_string())
.collect();

// Block number
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"));
// Total issuance
assert!(whitelist.contains("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80"));
// Execution phase
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a"));
// Event count
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850"));
// System events
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7"));
// XcmPallet VersionDiscoveryQueue
assert!(whitelist.contains("1405f2411d0af5a7ff397e7c9dc68d194a222ba0333561192e474c59ed8e30e1"));
// XcmPallet SafeXcmVersion
assert!(whitelist.contains("1405f2411d0af5a7ff397e7c9dc68d196323ae84c43568be0d1394d5d0d522c4"));
}

#[test]
fn check_treasury_pallet_id() {
assert_eq!(
<Treasury as frame_support::traits::PalletInfoAccess>::index() as u8,
rococo_runtime_constants::TREASURY_PALLET_ID
);
}

mod encoding_tests {
use super::*;

#[test]
fn nis_hold_reason_encoding_is_correct() {
assert_eq!(RuntimeHoldReason::Nis(pallet_nis::HoldReason::NftReceipt).encode(), [38, 0]);
}
}
3 changes: 3 additions & 0 deletions polkadot/runtime/westend/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ pub mod system_parachain {
}
}

/// Westend Treasury pallet instance.
pub const TREASURY_PALLET_ID: u8 = 37;

/// XCM protocol related constants.
pub mod xcm {
/// Pluralistic bodies existing within the consensus.
Expand Down
8 changes: 8 additions & 0 deletions polkadot/runtime/westend/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,11 @@ fn check_whitelist() {
// XcmPallet SafeXcmVersion
assert!(whitelist.contains("1405f2411d0af5a7ff397e7c9dc68d196323ae84c43568be0d1394d5d0d522c4"));
}

#[test]
fn check_treasury_pallet_id() {
assert_eq!(
<Treasury as frame_support::traits::PalletInfoAccess>::index() as u8,
westend_runtime_constants::TREASURY_PALLET_ID
);
}