-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[pallet_xcm::reserve_transfer_assets]
NotHoldingFees
issue in case of paid XcmRouter is used
#7585
base: kckyeung/xcm-fee-manager
Are you sure you want to change the base?
Conversation
@joepetrowski @KiChjang maybe some additional runtime api which will be able to trigger just |
The CI pipeline was cancelled due to failure one of the required jobs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the intention is that any fees payable in the XCM executor can be configured via SetFeesMode
, but some of the existing code were not changed to respect the fees_mode
register, so this change LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall solution seems sound, however too much code duplication and bare logic is introduced into high-level runtime definition code which should be 99% declarative.
Something for all Frame coders to note:
The central lib.rs
files of runtimes should not contain bare logic. The point of the extensive use of traits and types in how I designed Frame is to avoid exactly this. Runtimes should ONLY CONTAIN BASIC TYPE DEFINITIONS. Any logic should be parcelled up into one or more reusable types and stashed somewhere common for everyone else to make use of too.
…aychains or parachains)
bot rebase |
…ko-kckyeung/xcm-fee-manager
Rebased |
bot rebase |
…ko-kckyeung/xcm-fee-manager
Rebased |
bot rebase |
…ko-kckyeung/xcm-fee-manager
Rebased |
bot fmt |
@bkontur https://gitlab.parity.io/parity/mirrors/polkadot/-/jobs/3404171 was started for your command Comment |
@bkontur Command |
@gavofyork I fixed and refactored those duplication like you suggested, could you please, check? I hesitate to merge without your explicit approve here (because you requested changes), thank you :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits
/// Deposits estimated fee to the origin account (if needed). | ||
/// Allows to trigger additional logic for specific `ParaId` (e.g. open HRMP channel) (if neeeded). | ||
#[cfg(feature = "runtime-benchmarks")] | ||
pub struct ToParachainDeliveryHelper< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be here or in xcm-builder
?
parameter_types! { | ||
pub Para3000: u32 = 3000; | ||
pub Para3000Location: MultiLocation = Parachain(Para3000::get()).into(); | ||
pub Para3000PaymentAmount: u128 = 1; | ||
pub Para3000PaymentMultiAssets: MultiAssets = MultiAssets::from(MultiAsset::from((Here, Para3000PaymentAmount::get()))); | ||
} | ||
/// Sender only sends to `Parachain(3000)` destination requiring payment. | ||
pub struct TestPaidForPara3000SendXcm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like these items are specific to a particular test. Why not put them in tests
rather than in mock? The test sender should be generic enough.
@@ -346,7 +348,8 @@ impl xcm_executor::Config for XcmConfig { | |||
type SubscriptionService = XcmPallet; | |||
type PalletInstancesInfo = AllPalletsWithSystem; | |||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding; | |||
type FeeManager = XcmFeesToAccount<Self, SystemParachains, AccountId, TreasuryAccount>; | |||
type FeeManager = | |||
XcmFeesToAccount<Self, (SystemParachains, HereLocation), AccountId, TreasuryAccount>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One query.
Based on PR: #7005
TL;DR: this PR:
fees_mode
fromSetFeesMode
correctly in all cases inXcmExecutor
FeeManager
with withdrawing and handling fees fortransfer_reserve_asset
Long story:
on AssetHubs we plan to set FeeManager and waive unpaid only for system parachains or relay chain
https://github.com/paritytech/cumulus/pull/2433/files#diff-9a51956f7781a349d207a9d5f54ea0061666a856fb108d1a1190bd5178eaac50R432-R437
so it means, that any user/origin will be charged for delivery, from holding register:
which seems ok, but there are several cases, when this
holding
register is not filled and is empty,for example
pallet_xcm::reserve_transfer_assets
generates instructions:SetFeesMode
-> does nothing, because it affects onlysef.take_fee(
which is used only forExportMessage / LockAsset / RequestUnlock
TransferReserveAsset
- does reserve transfer of assets and thenself.send(ReserveAssetDeposited(assets))
to destinationand here are problems with this
self.send
:holding
so thisself.send
for regular user fails onNotHoldingFees
- see test bellow without fixfee from validate_send
from user account directly or from holding register?maybe here in
fn send
is missingIF
based onjit_withdraw: true
, which is the same code asfn take_fee
does?so maybe solution is to use here
self.take_fee(
- which is working for test :)Test fails withtout changing:
orginal:
fixed to:
TODOs:
is_waived