Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
6663dee8
Unverified
Commit
6663dee8
authored
Apr 28, 2021
by
Gavin Wood
Committed by
GitHub
Apr 28, 2021
Browse files
Required weight is returned in case it exceeds limit. (#2952)
parent
efbc5a07
Pipeline
#136144
passed with stages
in 38 minutes and 52 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
runtime/parachains/src/ump.rs
View file @
6663dee8
...
@@ -73,7 +73,7 @@ impl<XcmExecutor: xcm::v0::ExecuteXcm<Call>, Call> UmpSink for XcmSink<XcmExecut
...
@@ -73,7 +73,7 @@ impl<XcmExecutor: xcm::v0::ExecuteXcm<Call>, Call> UmpSink for XcmSink<XcmExecut
let
xcm_location
:
MultiLocation
=
xcm_junction
.into
();
let
xcm_location
:
MultiLocation
=
xcm_junction
.into
();
match
XcmExecutor
::
execute_xcm
(
xcm_location
,
xcm_message
,
max_weight
)
{
match
XcmExecutor
::
execute_xcm
(
xcm_location
,
xcm_message
,
max_weight
)
{
Outcome
::
Complete
(
w
)
|
Outcome
::
Incomplete
(
w
,
_
)
=>
Some
(
w
),
Outcome
::
Complete
(
w
)
|
Outcome
::
Incomplete
(
w
,
_
)
=>
Some
(
w
),
Outcome
::
Error
(
XcmError
::
WeightLimitReached
)
=>
None
,
Outcome
::
Error
(
XcmError
::
WeightLimitReached
(
..
)
)
=>
None
,
Outcome
::
Error
(
_
)
=>
Some
(
0
),
Outcome
::
Error
(
_
)
=>
Some
(
0
),
}
}
}
}
...
...
xcm/src/v0/multi_location.rs
View file @
6663dee8
...
@@ -578,7 +578,7 @@ impl MultiLocation {
...
@@ -578,7 +578,7 @@ impl MultiLocation {
let
self_parents
=
self
.parent_count
();
let
self_parents
=
self
.parent_count
();
let
prefix_rest
=
prefix
.len
()
-
prefix
.parent_count
();
let
prefix_rest
=
prefix
.len
()
-
prefix
.parent_count
();
let
skipped
=
self_parents
.min
(
prefix_rest
);
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
);
return
Err
(
prefix
);
}
}
...
...
xcm/src/v0/traits.rs
View file @
6663dee8
...
@@ -43,7 +43,9 @@ pub enum Error {
...
@@ -43,7 +43,9 @@ pub enum Error {
BadOrigin
,
BadOrigin
,
ExceedsMaxMessageSize
,
ExceedsMaxMessageSize
,
FailedToTransactAsset
(
#[codec(skip)]
&
'static
str
),
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
,
Wildcard
,
/// The case where an XCM message has specified a optional weight limit and the weight required for
/// The case where an XCM message has specified a optional weight limit and the weight required for
/// processing is too great.
/// processing is too great.
...
...
xcm/xcm-executor/src/lib.rs
View file @
6663dee8
...
@@ -54,10 +54,10 @@ impl<Config: config::Config> ExecuteXcm<Config::Call> for XcmExecutor<Config> {
...
@@ -54,10 +54,10 @@ impl<Config: config::Config> ExecuteXcm<Config::Call> for XcmExecutor<Config> {
};
};
let
maximum_weight
=
match
shallow_weight
.checked_add
(
deep_weight
)
{
let
maximum_weight
=
match
shallow_weight
.checked_add
(
deep_weight
)
{
Some
(
x
)
=>
x
,
Some
(
x
)
=>
x
,
None
=>
return
Outcome
::
Error
(
XcmError
::
WeightLimitReached
),
None
=>
return
Outcome
::
Error
(
XcmError
::
Overflow
),
};
};
if
maximum_weight
>
weight_limit
{
if
maximum_weight
>
weight_limit
{
return
Outcome
::
Error
(
XcmError
::
WeightLimitReached
);
return
Outcome
::
Error
(
XcmError
::
WeightLimitReached
(
maximum_weight
)
);
}
}
let
mut
trader
=
Config
::
Trader
::
new
();
let
mut
trader
=
Config
::
Trader
::
new
();
let
result
=
Self
::
do_execute_xcm
(
origin
,
true
,
message
,
&
mut
0
,
Some
(
shallow_weight
),
&
mut
trader
);
let
result
=
Self
::
do_execute_xcm
(
origin
,
true
,
message
,
&
mut
0
,
Some
(
shallow_weight
),
&
mut
trader
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment