Required weight is returned in case it exceeds limit. (#2952)

This commit is contained in:
Gavin Wood
2021-04-28 18:24:39 +02:00
committed by GitHub
parent 9c60982989
commit c0bf7e3d8c
4 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -578,7 +578,7 @@ impl MultiLocation {
let self_parents = self.parent_count();
let prefix_rest = prefix.len() - prefix.parent_count();
let skipped = self_parents.min(prefix_rest);
if self.len() + prefix.len() - 2 * skipped > 4 {
if self.len() + prefix.len() - 2 * skipped > 8 {
return Err(prefix);
}
+3 -1
View File
@@ -43,7 +43,9 @@ pub enum Error {
BadOrigin,
ExceedsMaxMessageSize,
FailedToTransactAsset(#[codec(skip)] &'static str),
WeightLimitReached,
/// Execution of the XCM would potentially result in a greater weight used than the pre-specified
/// weight limit. The amount that is potentially required is the parameter.
WeightLimitReached(Weight),
Wildcard,
/// The case where an XCM message has specified a optional weight limit and the weight required for
/// processing is too great.
+2 -2
View File
@@ -54,10 +54,10 @@ impl<Config: config::Config> ExecuteXcm<Config::Call> for XcmExecutor<Config> {
};
let maximum_weight = match shallow_weight.checked_add(deep_weight) {
Some(x) => x,
None => return Outcome::Error(XcmError::WeightLimitReached),
None => return Outcome::Error(XcmError::Overflow),
};
if maximum_weight > weight_limit {
return Outcome::Error(XcmError::WeightLimitReached);
return Outcome::Error(XcmError::WeightLimitReached(maximum_weight));
}
let mut trader = Config::Trader::new();
let result = Self::do_execute_xcm(origin, true, message, &mut 0, Some(shallow_weight), &mut trader);