Skip to content

Commit 3f6c2c7

Browse files
committed
1 parent e681609 commit 3f6c2c7

File tree

13 files changed

+150
-28
lines changed

13 files changed

+150
-28
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

relay/kusama/constants/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ sp-runtime = { default-features = false , version = "28.0.0" }
1616
sp-weights = { default-features = false , version = "24.0.0" }
1717
sp-core = { default-features = false , version = "25.0.0" }
1818

19+
xcm = { package = "staging-xcm", default-features = false , version = "4.0.0" }
20+
1921
[features]
2022
default = [ "std" ]
2123
std = [
@@ -25,4 +27,5 @@ std = [
2527
"sp-core/std",
2628
"sp-runtime/std",
2729
"sp-weights/std",
30+
"xcm/std"
2831
]

relay/kusama/constants/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,27 @@ pub mod fee {
9797
}
9898
}
9999

100+
/// System Parachains.
101+
pub mod system_parachain {
102+
use xcm::latest::prelude::*;
103+
104+
/// Asset Hub parachain ID.
105+
pub const ASSET_HUB_ID: u32 = 1000;
106+
/// Encointer parachain ID.
107+
pub const ENCOINTER_ID: u32 = 1001;
108+
/// Bridge Hub parachain ID.
109+
pub const BRIDGE_HUB_ID: u32 = 1002;
110+
111+
frame_support::match_types! {
112+
pub type SystemParachains: impl Contains<MultiLocation> = {
113+
MultiLocation { parents: 0, interior: X1(Parachain(ASSET_HUB_ID | ENCOINTER_ID | BRIDGE_HUB_ID)) }
114+
};
115+
}
116+
}
117+
118+
/// Kusama Treasury pallet instance.
119+
pub const TREASURY_PALLET_ID: u8 = 18;
120+
100121
#[cfg(test)]
101122
mod tests {
102123
use super::{

relay/kusama/src/xcm_config.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
1919
use super::{
2020
parachains_origin, AccountId, AllPalletsWithSystem, Balances, Dmp, Fellows, ParaId, Runtime,
21-
RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, TransactionByteFee, WeightToFee,
22-
XcmPallet,
21+
RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, TransactionByteFee, Treasury,
22+
WeightToFee, XcmPallet,
2323
};
2424
use frame_support::{
2525
match_types, parameter_types,
2626
traits::{Contains, Everything, Nothing},
2727
weights::Weight,
2828
};
2929
use frame_system::EnsureRoot;
30-
use kusama_runtime_constants::currency::CENTS;
30+
use kusama_runtime_constants::{currency::CENTS, system_parachain::SystemParachains};
3131
use runtime_common::{
3232
crowdloan, paras_registrar,
3333
xcm_sender::{ChildParachainRouter, ExponentialPrice},
@@ -42,7 +42,7 @@ use xcm_builder::{
4242
CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, MintLocation,
4343
OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32,
4444
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
45-
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
45+
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeesToAccount,
4646
};
4747
use xcm_executor::traits::WithOriginFilter;
4848

@@ -61,6 +61,8 @@ parameter_types! {
6161
pub CheckAccount: AccountId = XcmPallet::check_account();
6262
/// The check account that is allowed to mint assets locally.
6363
pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local);
64+
/// Account of the treasury pallet.
65+
pub TreasuryAccount: Option<AccountId> = Some(Treasury::account_id());
6466
}
6567

6668
/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to
@@ -339,7 +341,7 @@ impl xcm_executor::Config for XcmConfig {
339341
type SubscriptionService = XcmPallet;
340342
type PalletInstancesInfo = AllPalletsWithSystem;
341343
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
342-
type FeeManager = ();
344+
type FeeManager = XcmFeesToAccount<Self, SystemParachains, AccountId, TreasuryAccount>;
343345
// No bridges yet...
344346
type MessageExporter = ();
345347
type UniversalAliases = Nothing;

relay/polkadot/constants/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ sp-runtime = { default-features = false , version = "28.0.0" }
1616
sp-weights = { default-features = false , version = "24.0.0" }
1717
sp-core = { default-features = false , version = "25.0.0" }
1818

19+
xcm = { package = "staging-xcm", default-features = false , version = "4.0.0" }
20+
1921
[features]
2022
default = [ "std" ]
2123
std = [
@@ -25,4 +27,5 @@ std = [
2527
"sp-core/std",
2628
"sp-runtime/std",
2729
"sp-weights/std",
30+
"xcm/std"
2831
]

relay/polkadot/constants/src/lib.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,25 @@ pub mod xcm {
113113

114114
/// System Parachains.
115115
pub mod system_parachain {
116-
/// Statemint parachain ID.
117-
pub const STATEMINT_ID: u32 = 1000;
116+
use xcm::latest::prelude::*;
117+
118+
/// Asset Hub parachain ID.
119+
pub const ASSET_HUB_ID: u32 = 1000;
118120
/// Collectives parachain ID.
119121
pub const COLLECTIVES_ID: u32 = 1001;
122+
/// Bridge Hub parachain ID.
123+
pub const BRIDGE_HUB_ID: u32 = 1002;
124+
125+
frame_support::match_types! {
126+
pub type SystemParachains: impl Contains<MultiLocation> = {
127+
MultiLocation { parents: 0, interior: X1(Parachain(ASSET_HUB_ID | COLLECTIVES_ID | BRIDGE_HUB_ID)) }
128+
};
129+
}
120130
}
121131

132+
/// Polkadot Treasury pallet instance.
133+
pub const TREASURY_PALLET_ID: u8 = 19;
134+
122135
#[cfg(test)]
123136
mod tests {
124137
use super::{

relay/polkadot/src/xcm_config.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use super::{
2020
parachains_origin, AccountId, AllPalletsWithSystem, Balances, Dmp, FellowshipAdmin,
2121
GeneralAdmin, ParaId, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin,
22-
TransactionByteFee, WeightToFee, XcmPallet,
22+
TransactionByteFee, Treasury, WeightToFee, XcmPallet,
2323
};
2424
use frame_support::{
2525
match_types, parameter_types,
@@ -29,7 +29,9 @@ use frame_support::{
2929
use frame_system::EnsureRoot;
3030
use pallet_xcm::XcmPassthrough;
3131
use polkadot_runtime_constants::{
32-
currency::CENTS, system_parachain::*, xcm::body::FELLOWSHIP_ADMIN_INDEX,
32+
currency::CENTS,
33+
system_parachain::{SystemParachains, *},
34+
xcm::body::FELLOWSHIP_ADMIN_INDEX,
3335
};
3436
use runtime_common::{
3537
crowdloan, paras_registrar,
@@ -44,7 +46,7 @@ use xcm_builder::{
4446
ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, IsConcrete, MintLocation,
4547
OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32,
4648
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
47-
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
49+
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeesToAccount,
4850
};
4951
use xcm_executor::traits::WithOriginFilter;
5052

@@ -61,6 +63,8 @@ parameter_types! {
6163
pub CheckAccount: AccountId = XcmPallet::check_account();
6264
/// The Checking Account along with the indication that the local chain is able to mint tokens.
6365
pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local);
66+
/// Account of the treasury pallet.
67+
pub TreasuryAccount: Option<AccountId> = Some(Treasury::account_id());
6468
}
6569

6670
/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to
@@ -131,7 +135,7 @@ pub type XcmRouter = WithUniqueTopic<(
131135

132136
parameter_types! {
133137
pub const Dot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
134-
pub const StatemintLocation: MultiLocation = Parachain(STATEMINT_ID).into_location();
138+
pub const StatemintLocation: MultiLocation = Parachain(ASSET_HUB_ID).into_location();
135139
pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), StatemintLocation::get());
136140
pub const CollectivesLocation: MultiLocation = Parachain(COLLECTIVES_ID).into_location();
137141
pub const DotForCollectives: (MultiAssetFilter, MultiLocation) = (Dot::get(), CollectivesLocation::get());
@@ -340,7 +344,7 @@ impl xcm_executor::Config for XcmConfig {
340344
type SubscriptionService = XcmPallet;
341345
type PalletInstancesInfo = AllPalletsWithSystem;
342346
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
343-
type FeeManager = ();
347+
type FeeManager = XcmFeesToAccount<Self, SystemParachains, AccountId, TreasuryAccount>;
344348
// No bridges yet...
345349
type MessageExporter = ();
346350
type UniversalAliases = Nothing;

system-parachains/asset-hubs/asset-hub-kusama/src/weights/xcm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<Call> XcmWeightInfo<Call> for AssetHubKusamaXcmWeight<Call> {
6161
fn withdraw_asset(assets: &MultiAssets) -> Weight {
6262
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
6363
}
64-
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
64+
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
6565
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
6666
}
6767
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {

system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ use assets_common::{
2525
};
2626
use frame_support::{
2727
match_types, parameter_types,
28-
traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess},
28+
traits::{ConstU32, Contains, Equals, Everything, Nothing, PalletInfoAccess},
2929
};
3030
use frame_system::EnsureRoot;
3131
use pallet_xcm::XcmPassthrough;
32-
use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier};
32+
use parachains_common::{
33+
impls::ToStakingPot,
34+
xcm_config::{AssetFeeAsExistentialDepositMultiplier, RelayOrOtherSystemParachains},
35+
TREASURY_PALLET_ID,
36+
};
3337
use polkadot_parachain_primitives::primitives::Sibling;
34-
use sp_runtime::traits::ConvertInto;
38+
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
3539
use xcm::latest::prelude::*;
3640
use xcm_builder::{
3741
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
@@ -42,6 +46,7 @@ use xcm_builder::{
4246
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
4347
SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit,
4448
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
49+
XcmFeesToAccount,
4550
};
4651
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
4752

@@ -64,6 +69,8 @@ parameter_types! {
6469
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
6570
pub const GovernanceLocation: MultiLocation = MultiLocation::parent();
6671
pub const FellowshipLocation: MultiLocation = MultiLocation::parent();
72+
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(kusama_runtime_constants::TREASURY_PALLET_ID)).into();
73+
pub TreasuryAccount: Option<AccountId> = Some(TREASURY_PALLET_ID.into_account_truncating());
6774
}
6875

6976
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
@@ -468,6 +475,17 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia
468475
TrustBackedAssetsInstance,
469476
>;
470477

478+
/// Locations that will not be charged fees in the executor,
479+
/// either execution or delivery.
480+
/// We only waive fees for system functions, which these locations represent.
481+
pub type WaivedLocations = (
482+
RelayOrOtherSystemParachains<
483+
kusama_runtime_constants::system_parachain::SystemParachains,
484+
Runtime,
485+
>,
486+
Equals<RelayTreasuryLocation>,
487+
);
488+
471489
pub struct XcmConfig;
472490
impl xcm_executor::Config for XcmConfig {
473491
type RuntimeCall = RuntimeCall;
@@ -514,7 +532,7 @@ impl xcm_executor::Config for XcmConfig {
514532
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
515533
type AssetLocker = ();
516534
type AssetExchanger = ();
517-
type FeeManager = ();
535+
type FeeManager = XcmFeesToAccount<Self, WaivedLocations, AccountId, TreasuryAccount>;
518536
type MessageExporter = ();
519537
type UniversalAliases = Nothing;
520538
type CallDispatcher = WithOriginFilter<SafeCallFilter>;

system-parachains/asset-hubs/asset-hub-polkadot/src/weights/xcm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<Call> XcmWeightInfo<Call> for AssetHubPolkadotXcmWeight<Call> {
6161
fn withdraw_asset(assets: &MultiAssets) -> Weight {
6262
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
6363
}
64-
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
64+
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
6565
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
6666
}
6767
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {

0 commit comments

Comments
 (0)