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
6f16b93b
Unverified
Commit
6f16b93b
authored
Aug 05, 2021
by
Gavin Wood
Committed by
GitHub
Aug 05, 2021
Browse files
Introduce hard limit on XCM assets (#3579)
parent
4165c7f8
Pipeline
#151450
passed with stages
in 42 minutes and 13 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
xcm/pallet-xcm/src/lib.rs
View file @
6f16b93b
...
...
@@ -81,6 +81,9 @@ pub mod pallet {
type
LocationInverter
:
InvertLocation
;
}
/// The maximum number of distinct assets allowed to be transferred in a single helper extrinsic.
const
MAX_ASSETS_FOR_TRANSFER
:
usize
=
2
;
#[pallet::event]
#[pallet::generate_deposit(pub(super)
fn
deposit_event)]
pub
enum
Event
<
T
:
Config
>
{
...
...
@@ -100,6 +103,8 @@ pub mod pallet {
Empty
,
/// Could not reanchor the assets to declare the fees for the destination chain.
CannotReanchor
,
/// Too many assets have been attempted for transfer.
TooManyAssets
,
}
#[pallet::hooks]
...
...
@@ -152,6 +157,7 @@ pub mod pallet {
dest_weight
:
Weight
,
)
->
DispatchResult
{
let
origin_location
=
T
::
ExecuteXcmOrigin
::
ensure_origin
(
origin
)
?
;
ensure!
(
assets
.len
()
<=
MAX_ASSETS_FOR_TRANSFER
,
Error
::
<
T
>
::
TooManyAssets
);
let
value
=
(
origin_location
,
assets
);
ensure!
(
T
::
XcmTeleportFilter
::
contains
(
&
value
),
Error
::
<
T
>
::
Filtered
);
let
(
origin_location
,
assets
)
=
value
;
...
...
@@ -214,6 +220,7 @@ pub mod pallet {
dest_weight
:
Weight
,
)
->
DispatchResult
{
let
origin_location
=
T
::
ExecuteXcmOrigin
::
ensure_origin
(
origin
)
?
;
ensure!
(
assets
.len
()
<=
MAX_ASSETS_FOR_TRANSFER
,
Error
::
<
T
>
::
TooManyAssets
);
let
value
=
(
origin_location
,
assets
);
ensure!
(
T
::
XcmReserveTransferFilter
::
contains
(
&
value
),
Error
::
<
T
>
::
Filtered
);
let
(
origin_location
,
assets
)
=
value
;
...
...
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