From c699ca9c7b4de46917aff3aedbf423a34b2d20d2 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Wed, 24 Nov 2021 13:26:33 +0100 Subject: [PATCH] Fix use of weight limit errors (#4358) --- polkadot/xcm/src/v0/traits.rs | 6 +++--- polkadot/xcm/src/v1/traits.rs | 6 +++--- polkadot/xcm/src/v2/traits.rs | 2 +- polkadot/xcm/xcm-builder/src/tests.rs | 2 +- polkadot/xcm/xcm-executor/src/lib.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/polkadot/xcm/src/v0/traits.rs b/polkadot/xcm/src/v0/traits.rs index 3263fda4ac..cfbc6a2e6a 100644 --- a/polkadot/xcm/src/v0/traits.rs +++ b/polkadot/xcm/src/v0/traits.rs @@ -56,12 +56,12 @@ pub enum Error { /// An asset wildcard was passed where it was not expected (e.g. as the asset to withdraw in a /// `WithdrawAsset` XCM). Wildcard, - /// The case where an XCM message has specified a optional weight limit and the weight required for - /// processing is too great. + /// The case where an XCM message has specified a weight limit on an interior call and this + /// limit is too low. /// /// Used by: /// - `Transact` - TooMuchWeightRequired, + MaxWeightInvalid, /// The fees specified by the XCM message were not found in the holding account. /// /// Used by: diff --git a/polkadot/xcm/src/v1/traits.rs b/polkadot/xcm/src/v1/traits.rs index d95d9e1eb8..33b60455b0 100644 --- a/polkadot/xcm/src/v1/traits.rs +++ b/polkadot/xcm/src/v1/traits.rs @@ -57,12 +57,12 @@ pub enum Error { /// An asset wildcard was passed where it was not expected (e.g. as the asset to withdraw in a /// `WithdrawAsset` XCM). Wildcard, - /// The case where an XCM message has specified a optional weight limit and the weight required for - /// processing is too great. + /// The case where an XCM message has specified a weight limit on an interior call and this + /// limit is too low. /// /// Used by: /// - `Transact` - TooMuchWeightRequired, + MaxWeightInvalid, /// The fees specified by the XCM message were not found in the holding register. /// /// Used by: diff --git a/polkadot/xcm/src/v2/traits.rs b/polkadot/xcm/src/v2/traits.rs index d1e1381f4d..12ffd0e853 100644 --- a/polkadot/xcm/src/v2/traits.rs +++ b/polkadot/xcm/src/v2/traits.rs @@ -82,7 +82,7 @@ pub enum Error { FailedToDecode, /// Used by `Transact` to indicate that the given weight limit could be breached by the functor. #[codec(index = 18)] - TooMuchWeightRequired, + MaxWeightInvalid, /// Used by `BuyExecution` when the Holding Register does not contain payable fees. #[codec(index = 19)] NotHoldingFees, diff --git a/polkadot/xcm/xcm-builder/src/tests.rs b/polkadot/xcm/xcm-builder/src/tests.rs index 0e5c078604..2b154f4f00 100644 --- a/polkadot/xcm/xcm-builder/src/tests.rs +++ b/polkadot/xcm/xcm-builder/src/tests.rs @@ -598,7 +598,7 @@ fn transacting_should_respect_max_weight_requirement() { }]); let weight_limit = 60; let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); - assert_eq!(r, Outcome::Incomplete(50, XcmError::TooMuchWeightRequired)); + assert_eq!(r, Outcome::Incomplete(50, XcmError::MaxWeightInvalid)); } #[test] diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 00cc84c4e5..cd6060aebb 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -344,7 +344,7 @@ impl XcmExecutor { let dispatch_origin = Config::OriginConverter::convert_origin(origin, origin_type) .map_err(|_| XcmError::BadOrigin)?; let weight = message_call.get_dispatch_info().weight; - ensure!(weight <= require_weight_at_most, XcmError::TooMuchWeightRequired); + ensure!(weight <= require_weight_at_most, XcmError::MaxWeightInvalid); let actual_weight = match message_call.dispatch(dispatch_origin) { Ok(post_info) => post_info.actual_weight, Err(error_and_info) => {