Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix use of weight limit errors (#4358)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork authored Nov 24, 2021
1 parent f9358cc commit 49bb226
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions xcm/src/v0/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions xcm/src/v1/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion xcm/src/v2/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion xcm/xcm-builder/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ fn transacting_should_respect_max_weight_requirement() {
}]);
let weight_limit = 60;
let r = XcmExecutor::<TestConfig>::execute_xcm(Parent, message, weight_limit);
assert_eq!(r, Outcome::Incomplete(50, XcmError::TooMuchWeightRequired));
assert_eq!(r, Outcome::Incomplete(50, XcmError::MaxWeightInvalid));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion xcm/xcm-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl<Config: config::Config> XcmExecutor<Config> {
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) => {
Expand Down

0 comments on commit 49bb226

Please sign in to comment.