mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +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:
@@ -73,7 +73,10 @@ mod types {
|
||||
/// Common constants of parachains.
|
||||
mod constants {
|
||||
use super::types::BlockNumber;
|
||||
use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight};
|
||||
use frame_support::{
|
||||
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
|
||||
PalletId,
|
||||
};
|
||||
use sp_runtime::Perbill;
|
||||
/// This determines the average expected block time that we are targeting. Blocks will be
|
||||
/// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by
|
||||
@@ -101,6 +104,9 @@ mod constants {
|
||||
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
|
||||
polkadot_primitives::MAX_POV_SIZE as u64,
|
||||
);
|
||||
|
||||
/// Treasury pallet id of the local chain, used to convert into AccountId
|
||||
pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
|
||||
}
|
||||
|
||||
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
use crate::impls::AccountIdOf;
|
||||
use cumulus_primitives_core::{IsSystem, ParaId};
|
||||
use frame_support::{
|
||||
traits::{fungibles::Inspect, tokens::ConversionToAssetBalance, ContainsPair},
|
||||
traits::{fungibles::Inspect, tokens::ConversionToAssetBalance, Contains, ContainsPair},
|
||||
weights::Weight,
|
||||
};
|
||||
use log;
|
||||
use sp_runtime::traits::Get;
|
||||
use sp_std::marker::PhantomData;
|
||||
use xcm::latest::prelude::*;
|
||||
@@ -80,6 +79,27 @@ impl<Location: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation>
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RelayOrOtherSystemParachains<
|
||||
SystemParachainMatcher: Contains<MultiLocation>,
|
||||
Runtime: parachain_info::Config,
|
||||
> {
|
||||
_runtime: PhantomData<(SystemParachainMatcher, Runtime)>,
|
||||
}
|
||||
impl<SystemParachainMatcher: Contains<MultiLocation>, Runtime: parachain_info::Config>
|
||||
Contains<MultiLocation> for RelayOrOtherSystemParachains<SystemParachainMatcher, Runtime>
|
||||
{
|
||||
fn contains(l: &MultiLocation) -> bool {
|
||||
let self_para_id: u32 = parachain_info::Pallet::<Runtime>::get().into();
|
||||
if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l {
|
||||
if *para_id == self_para_id {
|
||||
return false
|
||||
}
|
||||
}
|
||||
matches!(l, MultiLocation { parents: 1, interior: Here }) ||
|
||||
SystemParachainMatcher::contains(l)
|
||||
}
|
||||
}
|
||||
|
||||
/// Accepts an asset if it is a concrete asset from the system (Relay Chain or system parachain).
|
||||
pub struct ConcreteAssetFromSystem<AssetLocation>(PhantomData<AssetLocation>);
|
||||
impl<AssetLocation: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation>
|
||||
|
||||
Reference in New Issue
Block a user