-
Notifications
You must be signed in to change notification settings - Fork 690
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
add FeeManager to pallet xcm #5363
add FeeManager to pallet xcm #5363
Conversation
polkadot/xcm/pallet-xcm/src/lib.rs
Outdated
@@ -292,6 +292,9 @@ pub mod pallet { | |||
|
|||
/// Weight information for extrinsics in this pallet. | |||
type WeightInfo: WeightInfo; | |||
|
|||
/// Configure the fees. | |||
type FeeManager: FeeManager; |
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 am in favor of re-exposing FeeManager
from XcmExecutor
type instead of creating yet another configuration type here.
I don't see why pallet-xcm
would be configured with fee manager different than the xcm-executor
. The benefit outweighs the overhead cost of configuring it twice and thus also the risk of misconfiguring it.
type XcmExecutor
here can take a trait FeeManager
bound.
xcm-executor
implementation can impl FeeManager
where it would simply re-expose its inner configured type FeeManager
.
This will help with ergonomics and allow most runtimes to ingest this change with no breakages and needs to adjust configs.
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.
Done!
…rrat/use-is-waived-on-send-xcm
…rrat/use-is-waived-on-send-xcm
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.
@jpserrat sorry this fell off my radar for a while.
Changes look mostly good, a couple of comments you need to address and rebase this against latest master.
polkadot/xcm/pallet-xcm/src/lib.rs
Outdated
if !is_waived { | ||
message.0.insert(0, DescendOrigin(interior)); | ||
} |
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.
This is not really what we want.
Whether or not DescendOrigin(interior)
is inserted is orthogonal to whether fees are paid; it should depend on the same condition as before:
if !is_waived { | |
message.0.insert(0, DescendOrigin(interior)); | |
} | |
if interior != Junctions::Here { | |
message.0.insert(0, DescendOrigin(interior)); | |
} |
polkadot/xcm/pallet-xcm/src/lib.rs
Outdated
@@ -2421,17 +2422,16 @@ impl<T: Config> Pallet<T> { | |||
mut message: Xcm<()>, | |||
) -> Result<XcmHash, SendError> { | |||
let interior = interior.into(); | |||
let origin_dest = interior.clone().into(); |
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.
This is the origin
as seen by the local chain, relative to Here
.
let origin_dest = interior.clone().into(); | |
let local_origin = interior.clone().into(); |
polkadot/xcm/pallet-xcm/src/lib.rs
Outdated
if !is_waived { | ||
Self::charge_fees(origin_dest, price).map_err(|_| SendError::Fees)?; | ||
} |
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.
This condition is good! 👍
Just rename the var
if !is_waived { | |
Self::charge_fees(origin_dest, price).map_err(|_| SendError::Fees)?; | |
} | |
if !is_waived { | |
Self::charge_fees(local_origin, price).map_err(|_| SendError::Fees)?; | |
} |
pub struct WaivedLocations; | ||
impl Contains<Location> for WaivedLocations { | ||
fn contains(location: &Location) -> bool { | ||
*location == Location::here() | ||
} | ||
} |
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.
There is already something you can use here:
pub struct WaivedLocations; | |
impl Contains<Location> for WaivedLocations { | |
fn contains(location: &Location) -> bool { | |
*location == Location::here() | |
} | |
} | |
pub type WaivedLocations = Equals<RootLocation>; |
Also please make sure all the other system chain runtimes have Equals<RootLocation>
part of their WaivedLocations
so as not to break functionality.
Hint: they currently do not, for example collectives-westend has it, make sure the others do too.
You also need to add a In this file you should add a clear:
it should also do
|
…rrat/use-is-waived-on-send-xcm
/cmd fmt |
Command "fmt" has started 🚀 See logs here |
Command "fmt" has finished ✅ See logs here |
dd9514f
Closes #2082
change send xcm to use
xcm::executor::FeeManager
to determine if the sender should be charged.I had to change the
FeeManager
of the penpal config to ensure the same test behaviour as before. For the other tests, I'm using theFeeManager
from thexcm::executor::FeeManager
as this one is used to check if the fee can be waived on the charge fees method.