Skip to content
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

Merged

Conversation

jpserrat
Copy link
Contributor

@jpserrat jpserrat commented Aug 14, 2024

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 the FeeManager from the xcm::executor::FeeManager as this one is used to check if the fee can be waived on the charge fees method.

@jpserrat jpserrat requested review from athei and a team as code owners August 14, 2024 13:10
@@ -292,6 +292,9 @@ pub mod pallet {

/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;

/// Configure the fees.
type FeeManager: FeeManager;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable 1/3
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7201111

@acatangiu acatangiu added the T6-XCM This PR/Issue is related to XCM. label Oct 12, 2024
Copy link
Contributor

@acatangiu acatangiu left a 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.

Comment on lines 2428 to 2430
if !is_waived {
message.0.insert(0, DescendOrigin(interior));
}
Copy link
Contributor

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:

Suggested change
if !is_waived {
message.0.insert(0, DescendOrigin(interior));
}
if interior != Junctions::Here {
message.0.insert(0, DescendOrigin(interior));
}

@@ -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();
Copy link
Contributor

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.

Suggested change
let origin_dest = interior.clone().into();
let local_origin = interior.clone().into();

Comment on lines 2433 to 2435
if !is_waived {
Self::charge_fees(origin_dest, price).map_err(|_| SendError::Fees)?;
}
Copy link
Contributor

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

Suggested change
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)?;
}

Comment on lines 319 to 324
pub struct WaivedLocations;
impl Contains<Location> for WaivedLocations {
fn contains(location: &Location) -> bool {
*location == Location::here()
}
}
Copy link
Contributor

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:

Suggested change
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.

@acatangiu
Copy link
Contributor

You also need to add a prdoc/pr_5363.prdoc new file and describe the change.

Here is an example prdoc file

In this file you should add a clear:

🚨 Warning: 🚨 pallet-xcm::send() no longer implicitly waives transport fees for the local root location, but instead relies on xcm_executor::Config::FeeManager to determine whether certain locations have free transport.
If your chain relies on free transport for local root, please make sure to add Location::here() to the waived-fee locations in your configured xcm_executor::Config::FeeManager.

it should also do major bump to pallet-xcm because of the change in behavior:

crates:
  - name: pallet-xcm
    bump: major

polkadot/xcm/pallet-xcm/src/lib.rs Outdated Show resolved Hide resolved
@acatangiu
Copy link
Contributor

/cmd fmt

Copy link

Command "fmt" has started 🚀 See logs here

Copy link

Command "fmt" has finished ✅ See logs here

@acatangiu acatangiu added this pull request to the merge queue Nov 11, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 11, 2024
@acatangiu acatangiu added this pull request to the merge queue Nov 11, 2024
Merged via the queue into paritytech:master with commit dd9514f Nov 11, 2024
193 of 197 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T6-XCM This PR/Issue is related to XCM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pallet-xcm: waive transport fees based on XcmConfig
6 participants