mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
Introduce XcmFeesToAccount fee manager (#1234)
Combination of paritytech/polkadot#7005, its addon PR paritytech/polkadot#7585 and its companion paritytech/cumulus#2433. This PR introduces a new XcmFeesToAccount struct which implements the `FeeManager` trait, and assigns this struct as the `FeeManager` in the XCM config for all runtimes. The struct simply deposits all fees handled by the XCM executor to a specified account. In all runtimes, the specified account is configured as the treasury account. XCM __delivery__ fees are now being introduced (unless the root origin is sending a message to a system parachain on behalf of the originating chain). # Note for reviewers Most file changes are tests that had to be modified to account for the new fees. Main changes are in: - cumulus/pallets/xcmp-queue/src/lib.rs <- To make it track the delivery fees exponential factor - polkadot/xcm/xcm-builder/src/fee_handling.rs <- Added. Has the FeeManager implementation - All runtime xcm_config files <- To add the FeeManager to the XCM configuration # Important note After this change, instructions that create and send a new XCM (Query*, Report*, ExportMessage, InitiateReserveWithdraw, InitiateTeleport, DepositReserveAsset, TransferReserveAsset, LockAsset and RequestUnlock) will require the corresponding origin account in the origin register to pay for transport delivery fees, and the onward message will fail to be sent if the origin account does not have the required amount. This delivery fee is on top of what we already collect as tx fees in pallet-xcm and XCM BuyExecution fees! Wallet UIs that want to expose the new delivery fee can do so using the formula: ``` delivery_fee_factor * (base_fee + encoded_msg_len * per_byte_fee) ``` where the delivery fee factor can be obtained from the corresponding pallet based on which transport you are using (UMP, HRMP or bridges), the base fee is a constant, the encoded message length from the message itself and the per byte fee is the same as the configured per byte fee for txs (i.e. `TransactionByteFee`). --------- Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Giles Cope <gilescope@gmail.com> Co-authored-by: command-bot <> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Liam Aharon <liam.aharon@hotmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -2072,14 +2072,29 @@ sp_api::impl_runtime_apis! {
|
||||
use sp_storage::TrackedStorageKey;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_config::{
|
||||
LocalCheckAccount, LocationConverter, AssetHub, TokenLocation, XcmConfig,
|
||||
AssetHub, LocalCheckAccount, LocationConverter, TokenLocation, XcmConfig,
|
||||
};
|
||||
|
||||
parameter_types! {
|
||||
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
|
||||
TokenLocation::get(),
|
||||
ExistentialDeposit::get()
|
||||
).into());
|
||||
pub ToParachain: ParaId = rococo_runtime_constants::system_parachain::ASSET_HUB_ID.into();
|
||||
}
|
||||
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
impl frame_benchmarking::baseline::Config for Runtime {}
|
||||
impl pallet_xcm_benchmarks::Config for Runtime {
|
||||
type XcmConfig = XcmConfig;
|
||||
type AccountIdConverter = LocationConverter;
|
||||
type DeliveryHelper = runtime_common::xcm_sender::ToParachainDeliveryHelper<
|
||||
XcmConfig,
|
||||
ExistentialDepositMultiAsset,
|
||||
xcm_config::PriceForChildParachainDelivery,
|
||||
ToParachain,
|
||||
(),
|
||||
>;
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(AssetHub::get())
|
||||
}
|
||||
@@ -2116,6 +2131,7 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
|
||||
impl pallet_xcm_benchmarks::generic::Config for Runtime {
|
||||
type TransactAsset = Balances;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
fn worst_case_response() -> (u64, Response) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use super::{
|
||||
parachains_origin, AccountId, AllPalletsWithSystem, Balances, Dmp, Fellows, ParaId, Runtime,
|
||||
RuntimeCall, RuntimeEvent, RuntimeOrigin, TransactionByteFee, WeightToFee, XcmPallet,
|
||||
RuntimeCall, RuntimeEvent, RuntimeOrigin, TransactionByteFee, Treasury, WeightToFee, XcmPallet,
|
||||
};
|
||||
|
||||
use crate::governance::StakingAdmin;
|
||||
@@ -29,7 +29,7 @@ use frame_support::{
|
||||
weights::Weight,
|
||||
};
|
||||
use frame_system::EnsureRoot;
|
||||
use rococo_runtime_constants::currency::CENTS;
|
||||
use rococo_runtime_constants::{currency::CENTS, system_parachain::*};
|
||||
use runtime_common::{
|
||||
xcm_sender::{ChildParachainRouter, ExponentialPrice},
|
||||
ToAuthor,
|
||||
@@ -43,7 +43,7 @@ use xcm_builder::{
|
||||
DescribeFamily, FixedWeightBounds, HashedDescription, IsChildSystemParachain, IsConcrete,
|
||||
MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeesToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
@@ -53,6 +53,7 @@ parameter_types! {
|
||||
pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into();
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local);
|
||||
pub TreasuryAccount: Option<AccountId> = Some(Treasury::account_id());
|
||||
}
|
||||
|
||||
pub type LocationConverter = (
|
||||
@@ -100,22 +101,22 @@ parameter_types! {
|
||||
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
||||
}
|
||||
|
||||
pub type PriceForChildParachainDelivery =
|
||||
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, Dmp>;
|
||||
|
||||
/// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our
|
||||
/// individual routers.
|
||||
pub type XcmRouter = WithUniqueTopic<(
|
||||
pub type XcmRouter = WithUniqueTopic<
|
||||
// Only one router so far - use DMP to communicate with child parachains.
|
||||
ChildParachainRouter<
|
||||
Runtime,
|
||||
XcmPallet,
|
||||
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, Dmp>,
|
||||
>,
|
||||
)>;
|
||||
ChildParachainRouter<Runtime, XcmPallet, PriceForChildParachainDelivery>,
|
||||
>;
|
||||
|
||||
parameter_types! {
|
||||
pub const Roc: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
|
||||
pub const AssetHub: MultiLocation = Parachain(1000).into_location();
|
||||
pub const Contracts: MultiLocation = Parachain(1002).into_location();
|
||||
pub const Encointer: MultiLocation = Parachain(1003).into_location();
|
||||
pub const AssetHub: MultiLocation = Parachain(ASSET_HUB_ID).into_location();
|
||||
pub const Contracts: MultiLocation = Parachain(CONTRACTS_ID).into_location();
|
||||
pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location();
|
||||
pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location();
|
||||
pub const Tick: MultiLocation = Parachain(100).into_location();
|
||||
pub const Trick: MultiLocation = Parachain(110).into_location();
|
||||
pub const Track: MultiLocation = Parachain(120).into_location();
|
||||
@@ -125,6 +126,7 @@ parameter_types! {
|
||||
pub const RocForAssetHub: (MultiAssetFilter, MultiLocation) = (Roc::get(), AssetHub::get());
|
||||
pub const RocForContracts: (MultiAssetFilter, MultiLocation) = (Roc::get(), Contracts::get());
|
||||
pub const RocForEncointer: (MultiAssetFilter, MultiLocation) = (Roc::get(), Encointer::get());
|
||||
pub const RocForBridgeHub: (MultiAssetFilter, MultiLocation) = (Roc::get(), BridgeHub::get());
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
@@ -135,6 +137,7 @@ pub type TrustedTeleporters = (
|
||||
xcm_builder::Case<RocForAssetHub>,
|
||||
xcm_builder::Case<RocForContracts>,
|
||||
xcm_builder::Case<RocForEncointer>,
|
||||
xcm_builder::Case<RocForBridgeHub>,
|
||||
);
|
||||
|
||||
match_types! {
|
||||
@@ -188,7 +191,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type SubscriptionService = XcmPallet;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type FeeManager = ();
|
||||
type FeeManager = XcmFeesToAccount<Self, SystemParachains, AccountId, TreasuryAccount>;
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = RuntimeCall;
|
||||
@@ -206,7 +209,7 @@ parameter_types! {
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parachain(ASSET_HUB_ID).into());
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
|
||||
|
||||
Reference in New Issue
Block a user