This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 378
Transfer asset via bridge #2013
Closed
Closed
Changes from 250 commits
Commits
Show all changes
341 commits
Select commit
Hold shift + click to select a range
b8ed7e7
fmt
joepetrowski e196377
Fix for missing weight for `fn unpaid_execution()`
bkontur aea33d1
Fix - usage of `messages_processed`
bkontur 633366b
(pallet-assets/pallet-asset-tx-payment) pathched with `sv-locked-for-…
bkontur 6d534f0
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang 196ad14
Fixes
KiChjang 331b21e
Fixes
KiChjang b613a35
Fixes
KiChjang 930b988
cargo fmt
KiChjang cd1452b
Fixes
KiChjang a0865d8
Fixes
KiChjang d953b60
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang e80d39b
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang 3fdf078
Fixes
KiChjang d6d1a7d
Fixes
KiChjang 5f7f8c2
statemine progress
joepetrowski e8afde4
ForeignCreators :tada:
joepetrowski 2d4603d
Remove unused import
KiChjang 3647b74
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang c6f8c3d
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang db18833
Fixes for gav-xcm-v3 (#1835)
bkontur 61c1cdf
Fixes
KiChjang d30d218
Fixes
KiChjang 2a8678d
Fixes
KiChjang b1e8b37
Fixes
KiChjang fad4c13
Fixes
KiChjang f1e7e18
Fix tests
KiChjang 4829edb
Fixes
KiChjang e569b68
fix AssetFeeAsExistentialDepositMultiplier
joepetrowski c487586
no default instance
joepetrowski 4191a4d
instantiate statemint
joepetrowski 8afc224
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang 6057952
Add SafeCallFilter
KiChjang 33404f2
Add missing config items
KiChjang ff25026
Add TODO
KiChjang 080c7f0
Use () as the PriceForParentDelivery
KiChjang a9a359b
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang 9bad64e
Fixes
KiChjang 9ad8152
Fixes
KiChjang f366c7f
Fixes
KiChjang 92ace05
Fixes
KiChjang d2684b2
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang ffc7926
Update transact_origin to transact_origin_and_runtime_call
KiChjang cb1dd01
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang 7c25f95
Add ReachableDest config item to XCM pallet
KiChjang b144b78
Update SafeCallFilter to allow remark_with_event in runtime benchmarks
KiChjang 2719c7a
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang 06c43f5
cargo fmt
KiChjang 7f0e710
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang fef449a
Update substrate
KiChjang e3a6bc6
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
bkontur 1fcb5d5
Fix worst_case_holding
KiChjang dd74806
Fix DMQ queue unit tests
KiChjang 97d8c80
Remove unused label
KiChjang 36a767c
cargo fmt
KiChjang 1d6f7ae
Actually process incoming XCMs
KiChjang 90b7e77
Fixes
KiChjang 838656a
Fixes
KiChjang a50aed6
Fixes
KiChjang 2b2d90e
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
bkontur ccb74d9
Fixes - return back Weightless
bkontur 221d6be
Added measured benchmarks for `pallet_xcm` (#1968)
bkontur 27f9798
cargo fmt
bkontur bb821eb
Fix benchmarks
KiChjang c70a11f
Bko gav xcm v3 (#1993)
bkontur 5cf2a72
Change AllowUnpaidExecutionFrom to be explicit
KiChjang 1d53b51
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang d9d5a9d
compile tests
bkontur 4a9dec9
Init of pallet with `transfer_asset_via_bridge` call
bkontur 39ba564
Init of pallet with `transfer_asset_via_bridge` call
bkontur c675531
Box wrap inputs
bkontur e127426
Added withdraw/deposit to bridge's reserve account
bkontur a7dd1fc
TODO: temporary hack pipelines because of https://github.com/parityte…
bkontur 2f39d75
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang 5cdc48a
xcm-v3 benchmarks, weights, fixes for bridge-hubs (#2035)
bkontur 7f3727f
Merge branch 'master' into gav-xcm-v3
KiChjang e2a3354
Add event for showing the hash of an UMP sent message (#1228)
girazoki b7970c3
Merge branch 'master' into gav-xcm-v3
KiChjang 63a18c2
Fixes
KiChjang f9a0390
Fixes
KiChjang 893bc5c
Fixes
KiChjang e303fb2
Fixes
KiChjang 2ff5c4f
Allow receive bridged Xcm::Trap on Westmint
bkontur 18ad58b
Allow (temporary) Statemine send xcm messages
bkontur fe7817e
refactor TrustedBridgedNetworks
bkontur a80781e
Allow (hacky) xcm::transact for remark/remark_with_event
bkontur 0985898
Unit-test for Statemine - send_xcm_transact_with_remark_with_event_works
bkontur c3195d2
Fix for BridgedSignedAccountId32AsNative
bkontur 8fe432b
Allow explicit unpaid executions from the relay chains for system par…
KiChjang e28ef3c
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
KiChjang 87e0ea1
Allow receiving XCMs from any relay chain plurality
KiChjang 146c742
Fixes
KiChjang 3353263
don't rename pallet in runtime
joepetrowski 9e211b8
don't rename and fix tests
joepetrowski 31bc1c6
Added `allowed_target_location` + reanchored assets/destination + tests
bkontur 25c2fc5
fix benchmark helper
joepetrowski a4a581b
fix benchmark build
joepetrowski 7fbfeb3
Merge remote-tracking branch 'origin/joe-bridge-hub-westmint-assets' …
bkontur 9cd2708
more benchmark fixes
joepetrowski 23f9e4d
Merge remote-tracking branch 'origin/joe-bridge-hub-westmint-assets' …
bkontur 81e9703
fix penpal and rococo
joepetrowski d5787aa
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
bkontur 71b357b
Merge remote-tracking branch 'origin/gav-xcm-v3' into bridge-hub-base
bkontur f6e1b01
Patched dependencies (polkadot, substrate) for xcm-v3 (compiles + tes…
bkontur 4365baa
Merge branch 'bridge-hub-base' into joe-bridge-hub-westmint-assets
bkontur f2c3569
Merge remote-tracking branch 'origin/joe-bridge-hub-westmint-assets' …
bkontur 0c3f3b7
update BenchmarkHelper interface
joepetrowski c3d2108
fmt
joepetrowski 0d75123
Merge remote-tracking branch 'origin/master' into joe-bridge-hub-west…
bkontur 1d6fff4
Merge branch 'joe-bridge-hub-westmint-assets' into bko-transfer-asset…
bkontur 8d809e4
Added weight `export_message` to statemint because of `pallet_xcm.send`
bkontur 81abe45
add foreign assets to westmint
joepetrowski 0da76e0
add foreign assets to statemine
joepetrowski 57a2f00
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 1ae22a7
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur af4fe56
Governance can call `xcm:Transact` with bridges configuration management
bkontur 063fef0
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
bf2e4d3
Merge remote-tracking branch 'origin/joe-foreign-assets' into bko-tra…
bkontur 78175ba
Revert temporary disabled `scripts/ci/gitlab/pipeline/test.yml`
bkontur 761a500
Unit-test for handling `ReserveAssetDeposited` on Westmint for Foreig…
bkontur bc4664b
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
b534445
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
0590241
use updated api for ensure origin trait
muharem a1ce9b8
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
0f80e76
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
ae8cac6
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
bkontur 1b21403
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
5cb396f
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
56abaf5
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
d5b71a7
Benchmarks for pallet-bridge-assets-transfer (#2316)
svyatonik 4f70058
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
60a6089
Assets/ForeignAssets tests and fixes (#2167)
bkontur 018b800
Added `StartsWithExplicitGlobalConsensus` to ignores (#2338)
bkontur 08bfe99
Merge remote-tracking branch 'origin/joe-foreign-assets' into bko-tra…
bkontur 48b6877
Change to correct weight file for pallet_bridge_assets_transfer
bkontur c16f96d
Renamed `pallet-bridge-assets-transfer` to `pallet-bridge-transfer`
bkontur 32a09c7
from_ref_time to from_parts
bkontur 137ee81
".git/.scripts/commands/bench/bench.sh" pallet statemine assets palle…
36751ae
Added `ping_via_bridge`
bkontur b550a8e
".git/.scripts/commands/bench/bench.sh" pallet statemine assets palle…
47e0283
Merge remote-tracking branch 'origin/master' into joe-foreign-assets
a4e2b93
Fix test
bkontur ad13281
Merge remote-tracking branch 'origin/joe-foreign-assets' into bko-tra…
eff26cd
Revert not needed stuff
bkontur 65fe38b
Added test-case `can_governance_change_bridge_transfer_configuration`
bkontur bc5a3ed
Added test `initiate_transfer_asset_via_bridge_for_native_asset_works`
bkontur ec44e0d
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur abe9ad2
Fix compilation
bkontur 98c09fa
Small fixes
bkontur d712d42
Added support for paid or unpaid execution by configuration
bkontur 8dfe3b6
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur a757c38
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
a3eb549
Removed stuff
bkontur e0a27e6
Added `receive_reserve_asset_deposited_from_different_consensus_works`
bkontur 72d4010
Renamed Bridges -> AllowedExporters
bkontur 99fca26
Added `IsReserve` handling for `ReserveAssetDeposited` + benchmarks
bkontur bfaa974
Fix compile
bkontur 1c459ed
Merge branch 'master' of https://github.com/paritytech/cumulus into HEAD
3bf39cf
".git/.scripts/commands/bench/bench.sh" pallet statemine assets palle…
f76ba2b
Fix conditional benchmarking
bkontur 8bcceb6
Merge branch 'master' of https://github.com/paritytech/cumulus into HEAD
45ca89b
".git/.scripts/commands/bench/bench.sh" pallet statemine assets palle…
727b348
".git/.scripts/commands/bench/bench.sh" pallet westmint assets pallet…
a92aeb3
Change test weights
bkontur b82d6b1
Fix SafeCallFilter for westmint
bkontur 7fd80c7
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur e25e1ef
Use send_xcm and add cost to event
bkontur 77ad776
Refactor to support multiple MultiAsset + cleaning
bkontur b3edf24
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
e6bd54a
".git/.scripts/commands/bench/bench.sh" xcm westmint assets pallet_xc…
71d427f
Updated doc
bkontur 73bdbdc
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
56644eb
Address review comments
serban300 5170168
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
5c479b7
Extract runtime_para_id for test
bkontur ad2fa5c
Typos
bkontur 7bba7f0
Added helper for `execute_as_governance`
bkontur e58b442
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 2e33b87
Fix test because `UnpaidRemoteExporter` adds now `UnpaidExecution` in…
bkontur 43ee627
Use `execute_as_governance` function
bkontur bc8da2d
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 7c6d11a
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 469fe9c
Used `GlobalConsensusParachainConvertsFor` from `xcm-builder`
bkontur c167add
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur b1e9103
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 61ac4b7
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 2a9cd81
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur e2101a5
Fix target
bkontur 4280239
Fixed AssetTrapped issue
bkontur 79adea5
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur b2199fc
Fix xcm `SetTopic` vs message_hash vs message_id stuff
bkontur 0ad1c23
Sovereign account as target destination instead of bridge-hub
bkontur 7838a2a
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur b16b00e
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 322fdc6
Allow both sides
bkontur 5218d82
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur b873588
".git/.scripts/commands/bench/bench.sh" xcm statemine assets pallet_x…
4bac3e7
".git/.scripts/commands/bench/bench.sh" xcm westmint assets pallet_xc…
80c77ad
".git/.scripts/commands/bench/bench.sh" pallet statemine assets palle…
faae320
".git/.scripts/commands/bench/bench.sh" pallet westmint assets pallet…
8d024e6
Introduced AssetTransferKind + heavy refactor
bkontur bb65750
One more refactor
bkontur 9f52511
Merge remote-tracking branch 'origin/bko-transfer-asset-via-bridge' i…
bkontur 3b6c1e5
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 8a07286
Test compilation after rebase
bkontur 850fac5
Small nits
bkontur 9563e47
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur e6c4ec1
Reworked benchmarks
bkontur ed9d63f
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 8519a76
".git/.scripts/commands/bench/bench.sh" xcm statemine assets pallet_x…
50b7778
Merge branch 'master' of https://github.com/paritytech/cumulus into HEAD
c4b1e6e
".git/.scripts/commands/bench/bench.sh" xcm westmint assets pallet_xc…
0fade80
".git/.scripts/commands/bench/bench.sh" pallet statemine assets palle…
8013e38
".git/.scripts/commands/bench/bench.sh" pallet westmint assets pallet…
ed57ede
".git/.scripts/commands/bench/bench.sh" xcm asset-hub-kusama assets p…
9a833b1
Introduced `primitives` sub module
bkontur a5c14ea
Renamed const
bkontur 00d16b5
".git/.scripts/commands/bench/bench.sh" xcm asset-hub-westend assets …
e67f9f5
Merge branch 'master' of https://github.com/paritytech/cumulus into HEAD
c3e150a
".git/.scripts/commands/bench/bench.sh" pallet asset-hub-kusama asset…
36f5c1b
Moved cfg stuff to `pallet-bridge-transfer-onchain-config`
bkontur 916fe2e
More refactoring
bkontur 3f2a3ba
Another refactor
bkontur 8bef5e7
Temporary removed pallet for on-chain bridge config (will come in oth…
bkontur 2f5ea0c
Removed line
bkontur be9d74f
Merge remote-tracking branch 'origin/bko-transfer-asset-via-bridge' i…
bkontur 2ccce59
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 0962356
Added cfg to asset-hub-polkadot
bkontur c96d3d8
Fix test - ED for staking_pot
bkontur 78b4077
Allow set_storage for max fee constant
bkontur f4db99d
trivial: remove redundant method implementations
svyatonik 4b6d142
Fix benchmarks
bkontur 5adee69
Merge remote-tracking branch 'origin/bko-transfer-asset-via-bridge' i…
bkontur 49898b7
Nits
bkontur 6996284
Clippy
bkontur 9d7416f
Clippy
bkontur 6f1fca8
Benchmarks
bkontur 7460f08
Fix try-runtime
bkontur dd9d2ed
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur 27c048d
".git/.scripts/commands/bench/bench.sh" xcm asset-hub-kusama assets p…
23b0e06
Merge branch 'master' of https://github.com/paritytech/cumulus into HEAD
e7470ef
".git/.scripts/commands/bench/bench.sh" xcm asset-hub-westend assets …
40781e0
Merge branch 'master' of https://github.com/paritytech/cumulus into HEAD
26f86a3
".git/.scripts/commands/bench/bench.sh" xcm asset-hub-polkadot assets…
c58ba8e
".git/.scripts/commands/bench/bench.sh" pallet asset-hub-kusama asset…
a34bd0f
".git/.scripts/commands/bench/bench.sh" pallet asset-hub-westend asse…
6d3db81
".git/.scripts/commands/bench/bench.sh" pallet asset-hub-polkadot ass…
167fc06
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
62a1f2d
Fix README and local run scripts
bkontur d4ea7d5
Merge remote-tracking branch 'origin/master' into bko-transfer-asset-…
bkontur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[package] | ||
name = "pallet-bridge-transfer" | ||
version = "0.1.0" | ||
authors = ["Parity Technologies <admin@parity.io>"] | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
homepage = "https://docs.substrate.io/" | ||
repository = "https://github.com/paritytech/cumulus/" | ||
description = "Pallet for message transfer through bridges" | ||
readme = "README.md" | ||
|
||
[dependencies] | ||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } | ||
scale-info = { version = "2.3.0", default-features = false, features = ["derive"] } | ||
log = { version = "0.4.14", default-features = false } | ||
|
||
# Substrate | ||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } | ||
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } | ||
frame-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "master" } | ||
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "master" } | ||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } | ||
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } | ||
|
||
# Polkadot | ||
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } | ||
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } | ||
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } | ||
|
||
[dev-dependencies] | ||
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master" } | ||
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } | ||
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "master" } | ||
cumulus-pallet-xcmp-queue = { path = "../../../pallets/xcmp-queue" } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"codec/std", | ||
"log/std", | ||
"scale-info/std", | ||
"sp-std/std", | ||
"sp-runtime/std", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"xcm/std", | ||
"xcm-builder/std", | ||
"xcm-executor/std", | ||
] | ||
runtime-benchmarks = [ | ||
"frame-benchmarking/runtime-benchmarks", | ||
"frame-support/runtime-benchmarks", | ||
"frame-system-benchmarking/runtime-benchmarks", | ||
"frame-system/runtime-benchmarks", | ||
"sp-runtime/runtime-benchmarks", | ||
"xcm-builder/runtime-benchmarks", | ||
] | ||
try-runtime = ["frame-support/try-runtime"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) 2022 Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//! `BridgeTransfer` pallet benchmarks. | ||
|
||
use crate::{ | ||
AllowedExporters, AllowedReserveLocations, AllowedUniversalAliases, BenchmarkHelper, Call, | ||
Config, Event, Pallet, PingMessageBuilder, | ||
}; | ||
|
||
use frame_benchmarking::{benchmarks, BenchmarkError}; | ||
use frame_support::{ | ||
ensure, | ||
traits::{EnsureOrigin, Get}, | ||
}; | ||
use sp_std::prelude::*; | ||
use xcm::prelude::*; | ||
|
||
#[cfg(feature = "runtime-benchmarks")] | ||
impl<T: Config> Pallet<T> { | ||
#[cfg(feature = "runtime-benchmarks")] | ||
pub fn insert_universal_alias_for_benchmarks((location, junction): (MultiLocation, Junction)) { | ||
assert!(matches!( | ||
AllowedUniversalAliases::<T>::try_mutate(location, |junctions| junctions | ||
.try_insert(junction)), | ||
Ok(true) | ||
)); | ||
} | ||
} | ||
|
||
benchmarks! { | ||
transfer_asset_via_bridge { | ||
let _ = T::TransferAssetOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
// every asset has its own configuration and ledger, so there's a performance dependency | ||
// (be sure to use "worst" of assets) | ||
let max_assets_limit = T::MaxAssetsLimit::get(); | ||
ensure!(max_assets_limit > 0, "MaxAssetsLimit not set up correctly."); | ||
let (bridged_network, bridge_config) = T::BenchmarkHelper::bridge_config() | ||
.ok_or(BenchmarkError::Stop("missing `bridge_config` data"))?; | ||
let (origin, assets, destination) = T::BenchmarkHelper::prepare_asset_transfer() | ||
.ok_or(BenchmarkError::Stop("missing `prepare_asset_transfer` data"))?; | ||
let assets_count = match &assets { | ||
VersionedMultiAssets::V2(assets) => assets.len(), | ||
VersionedMultiAssets::V3(assets) => assets.len(), | ||
}; | ||
ensure!(assets_count == max_assets_limit as usize, "`assets` not set up correctly for worst case."); | ||
AllowedExporters::<T>::insert(bridged_network, bridge_config); | ||
}: _<T::RuntimeOrigin>(origin, Box::new(assets), Box::new(destination)) | ||
verify { | ||
// we don't care about message hash or sender cost here, just check that the transfer has been initiated | ||
let actual_event = frame_system::Pallet::<T>::events().pop().map(|r| r.event); | ||
let expected_event: <T as Config>::RuntimeEvent = Event::TransferInitiated { | ||
message_hash: Default::default(), | ||
sender_cost: Default::default(), | ||
}.into(); | ||
assert!(matches!(actual_event, Some(expected_event))); | ||
} | ||
|
||
ping_via_bridge { | ||
let _ = T::TransferPingOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
|
||
let (bridged_network, bridge_config) = T::BenchmarkHelper::bridge_config() | ||
.ok_or(BenchmarkError::Stop("missing `bridge_config` data"))?; | ||
AllowedExporters::<T>::insert(bridged_network, bridge_config); | ||
|
||
let (origin, destination) = T::BenchmarkHelper::prepare_ping_transfer() | ||
.ok_or(BenchmarkError::Stop("missing `prepare_ping_transfer` data"))?; | ||
|
||
let origin_location = T::TransferPingOrigin::ensure_origin(origin.clone()).map_err(|_| BenchmarkError::Stop("invalid `origin`"), | ||
)?; | ||
let (_, _, destination_location) = Pallet::<T>::ensure_remote_destination(destination.clone()).map_err(|_| | ||
BenchmarkError::Stop("invalid `destination_location`"), | ||
)?; | ||
let _ = T::PingMessageBuilder::try_build(&origin_location, &bridged_network, &destination_location).ok_or( | ||
BenchmarkError::Stop("invalid `PingMessageBuilder`"), | ||
)?; | ||
}: _<T::RuntimeOrigin>(origin, Box::new(destination)) | ||
verify { | ||
// we don't care about message hash or sender cost here, just check that the transfer has been initiated | ||
let actual_event = frame_system::Pallet::<T>::events().pop().map(|r| r.event); | ||
let expected_event: <T as Config>::RuntimeEvent = Event::TransferInitiated { | ||
message_hash: Default::default(), | ||
sender_cost: Default::default(), | ||
}.into(); | ||
assert!(matches!(actual_event, Some(expected_event))); | ||
} | ||
|
||
add_exporter_config { | ||
let origin = T::AdminOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
let (bridged_network, bridge_config) = T::BenchmarkHelper::bridge_config() | ||
.ok_or(BenchmarkError::Stop("missing `bridge_config` data"))?; | ||
}: _<T::RuntimeOrigin>(origin, bridged_network, Box::new(bridge_config.clone())) | ||
verify { | ||
assert_eq!(AllowedExporters::<T>::get(bridged_network), Some(bridge_config)); | ||
} | ||
|
||
remove_exporter_config { | ||
let origin = T::AdminOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
let (bridged_network, bridge_config) = T::BenchmarkHelper::bridge_config() | ||
.ok_or(BenchmarkError::Stop("missing `bridge_config` data"))?; | ||
AllowedExporters::<T>::insert(bridged_network, bridge_config); | ||
}: _<T::RuntimeOrigin>(origin, bridged_network) | ||
verify { | ||
assert_eq!(AllowedExporters::<T>::get(bridged_network), None); | ||
} | ||
|
||
update_exporter_config { | ||
let origin = T::AdminOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
let (bridged_network, bridge_config) = T::BenchmarkHelper::bridge_config() | ||
.ok_or(BenchmarkError::Stop("missing `bridge_config` data"))?; | ||
AllowedExporters::<T>::insert(bridged_network, bridge_config); | ||
|
||
let bridge_location_fee = None; | ||
let target_location_fee = Some(xcm::VersionedMultiAsset::V3(MultiAsset { | ||
id: Concrete(MultiLocation::parent()), | ||
fun: Fungible(1_000_0000), | ||
})); | ||
}: _<T::RuntimeOrigin>(origin, bridged_network, bridge_location_fee.clone().map(Box::new), target_location_fee.clone().map(Box::new)) | ||
verify { | ||
let exporter = AllowedExporters::<T>::get(bridged_network).unwrap(); | ||
assert_eq!(exporter.bridge_location_fee, bridge_location_fee.map(|fee| MultiAsset::try_from(fee).unwrap())); | ||
assert_eq!(exporter.max_target_location_fee, target_location_fee.map(|fee| MultiAsset::try_from(fee).unwrap())); | ||
} | ||
|
||
add_universal_alias { | ||
let origin = T::AdminOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
let (location, junction) = match T::BenchmarkHelper::universal_alias() { | ||
Some(alias) => alias, | ||
None => match T::UniversalAliasesLimit::get() > 0_u32 { | ||
true => return Err(BenchmarkError::Stop("missing `universal_alias` data")), | ||
false => return Err(BenchmarkError::Weightless), | ||
} | ||
}; | ||
}: _<T::RuntimeOrigin>(origin, Box::new(location.clone()), junction) | ||
verify { | ||
assert!(AllowedUniversalAliases::<T>::get(&location.try_as().unwrap()).contains(&junction)); | ||
} | ||
|
||
remove_universal_alias { | ||
let origin = T::AdminOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
let (location, junction) = match T::BenchmarkHelper::universal_alias() { | ||
Some(alias) => alias, | ||
None => match T::UniversalAliasesLimit::get() > 0_u32 { | ||
true => return Err(BenchmarkError::Stop("missing `universal_alias` data")), | ||
false => return Err(BenchmarkError::Weightless), | ||
} | ||
}; | ||
Pallet::<T>::insert_universal_alias_for_benchmarks((location.clone().try_into().unwrap(), junction)); | ||
}: _<T::RuntimeOrigin>(origin, Box::new(location.clone()), vec![junction.clone()]) | ||
verify { | ||
assert!(!AllowedUniversalAliases::<T>::get(&location.try_as().unwrap()).contains(&junction)); | ||
} | ||
|
||
add_reserve_location { | ||
let origin = T::AdminOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
let location = match T::BenchmarkHelper::reserve_location() { | ||
Some(location) => location, | ||
None => match T::ReserveLocationsLimit::get() > 0_u32 { | ||
true => return Err(BenchmarkError::Stop("missing `reserve_location` data")), | ||
false => return Err(BenchmarkError::Weightless), | ||
} | ||
}; | ||
}: _<T::RuntimeOrigin>(origin, Box::new(location.clone())) | ||
verify { | ||
assert!(AllowedReserveLocations::<T>::get().contains(&location.try_as().unwrap())); | ||
} | ||
|
||
remove_reserve_location { | ||
let origin = T::AdminOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
let location = match T::BenchmarkHelper::reserve_location() { | ||
Some(location) => location, | ||
None => match T::ReserveLocationsLimit::get() > 0_u32 { | ||
true => return Err(BenchmarkError::Stop("missing `reserve_location` data")), | ||
false => return Err(BenchmarkError::Weightless), | ||
} | ||
}; | ||
let multilocation: MultiLocation = location.clone().try_into().unwrap(); | ||
assert!(AllowedReserveLocations::<T>::try_mutate(|locations| locations.try_insert(multilocation)).unwrap()); | ||
}: _<T::RuntimeOrigin>(origin, vec![location.clone()]) | ||
verify { | ||
assert!(!AllowedReserveLocations::<T>::get().contains(&location.try_as().unwrap())); | ||
} | ||
|
||
impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::TestRuntime); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (C) 2023 Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use crate::{Config, Pallet}; | ||
use frame_support::traits::{Contains, ContainsPair}; | ||
use xcm::prelude::*; | ||
use xcm_builder::ExporterFor; | ||
|
||
/// `ExporterFor` implementation to check if we can transfer anything to `NetworkId` | ||
impl<T: Config> ExporterFor for Pallet<T> { | ||
fn exporter_for( | ||
network: &NetworkId, | ||
_remote_location: &InteriorMultiLocation, | ||
_message: &Xcm<()>, | ||
) -> Option<(MultiLocation, Option<MultiAsset>)> { | ||
Self::allowed_exporters(network) | ||
.map(|bridge_config| (bridge_config.bridge_location, bridge_config.bridge_location_fee)) | ||
} | ||
} | ||
|
||
/// Verifies if we have `(MultiLocation, Junction)` in allowed universal aliases. | ||
pub struct AllowedUniversalAliasesOf<T>(sp_std::marker::PhantomData<T>); | ||
impl<T: Config> Contains<(MultiLocation, Junction)> for AllowedUniversalAliasesOf<T> { | ||
fn contains((location, junction): &(MultiLocation, Junction)) -> bool { | ||
log::trace!(target: "xcm::contains", "AllowedUniversalAliasesOf location: {:?}, junction: {:?}", location, junction); | ||
Pallet::<T>::allowed_universal_aliases(location).contains(junction) | ||
} | ||
} | ||
|
||
/// Verifies if we can allow `(MultiAsset, MultiLocation)` as trusted reserve. | ||
pub struct IsAllowedReserveOf<T, F>(sp_std::marker::PhantomData<(T, F)>); | ||
impl<T: Config, F: ContainsPair<MultiAsset, MultiLocation>> ContainsPair<MultiAsset, MultiLocation> | ||
for IsAllowedReserveOf<T, F> | ||
{ | ||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { | ||
log::trace!(target: "xcm::contains", "IsAllowedReserveOf asset: {:?}, origin: {:?}", asset, origin); | ||
// first check - if we have configured origin as trusted reserve location | ||
if !Pallet::<T>::allowed_reserve_locations().contains(origin) { | ||
return false | ||
} | ||
// second check - we need to pass additional `(asset, origin)` filter | ||
F::contains(asset, origin) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that the
UnpaidRemoteExporter
throws an error ifmaybe_payment
is notNone
: https://github.com/paritytech/polkadot/blob/df61c0bf0834f650e79ddd1a74dea34081ff2b46/xcm/xcm-builder/src/universal_exports.rs#L156So
bridge_config.bridge_location_fee
seems misguiding. If someone sets it toSome(fee)
if will (unexpectedly) actually lead to failure. Would it make sense to remove it ?