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 1.6k
XCM Benchmarks for Asset Transactor w/ Fungible Asset #3818
Merged
Merged
Changes from 27 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
cdf3e86
benchmarks for fungibles
shawntabrizi 7e4fd07
add benchmark to westend
shawntabrizi 419702f
fix hex
shawntabrizi 06c1a9d
clean up a bit
shawntabrizi 70beba3
update code doc
shawntabrizi ce4705b
fix warnings
shawntabrizi 99215ad
cargo run --quiet --release --features runtime-benchmarks -- benchmar…
26ece05
Merge branch 'master' into shawntabrizi-fungible-benchmarks
shawntabrizi cdf2b9b
use skip
shawntabrizi 9955fad
fix spelling
shawntabrizi f313d57
Merge branch 'master' into shawntabrizi-fungible-benchmarks
shawntabrizi 556dccf
Update Cargo.lock
shawntabrizi f491adf
add scale-info
shawntabrizi 386d3a5
Merge branch 'master' into shawntabrizi-fungible-benchmarks
shawntabrizi 2381dcb
Update Cargo.lock
shawntabrizi dcdc5e8
update bench
shawntabrizi 768e888
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
0515f70
weights compile
shawntabrizi cb752a9
update westend to use weights
shawntabrizi cfa4323
Merge branch 'master' into shawntabrizi-fungible-benchmarks
shawntabrizi a73f703
fmt
shawntabrizi 48dd6db
spelling fixes
shawntabrizi cb860e7
Delete pallet_xcm_benchmarks::fungible.rs
shawntabrizi 532b61c
Merge branch 'master' into shawntabrizi-fungible-benchmarks
shawntabrizi bddcb2b
Merge branch 'master' into shawntabrizi-fungible-benchmarks
shawntabrizi 11e5d7d
Apply suggestions from code review
shawntabrizi a7519b6
fix code review
shawntabrizi 007e446
Merge branch 'master' into shawntabrizi-fungible-benchmarks
shawntabrizi 161906f
update weight
shawntabrizi 3f394c0
fix report_error
shawntabrizi 7b47f5c
fix spell check
shawntabrizi 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
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 |
---|---|---|
|
@@ -49,9 +49,9 @@ use xcm::latest::prelude::*; | |
use xcm_builder::{ | ||
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, | ||
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, | ||
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, | ||
LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, | ||
TakeWeightCredit, UsingComponents, | ||
CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, LocationInverter, | ||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, | ||
UsingComponents, WeightInfoBounds, | ||
}; | ||
use xcm_executor::XcmExecutor; | ||
|
||
|
@@ -948,10 +948,6 @@ type LocalOriginConverter = ( | |
ChildSystemParachainAsSuperuser<ParaId, Origin>, | ||
); | ||
|
||
parameter_types! { | ||
pub const BaseXcmWeight: Weight = 10_000_000; | ||
} | ||
|
||
/// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our | ||
/// individual routers. | ||
pub type XcmRouter = ( | ||
|
@@ -960,8 +956,9 @@ pub type XcmRouter = ( | |
); | ||
|
||
parameter_types! { | ||
pub const Westmint: MultiLocation = Parachain(1000).into(); | ||
pub const WestendForWestmint: (MultiAssetFilter, MultiLocation) = | ||
(Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Parachain(1000).into()); | ||
(Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Westmint::get()); | ||
pub const MaxInstructions: u32 = 100; | ||
} | ||
pub type TrustedTeleporters = (xcm_builder::Case<WestendForWestmint>,); | ||
|
@@ -986,7 +983,7 @@ impl xcm_executor::Config for XcmConfig { | |
type IsTeleporter = TrustedTeleporters; | ||
type LocationInverter = LocationInverter<Ancestry>; | ||
type Barrier = Barrier; | ||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>; | ||
type Weigher = WeightInfoBounds<weights::xcm::WestendXcmWeight<Call>, Call, MaxInstructions>; | ||
type Trader = UsingComponents<WeightToFee, WndLocation, AccountId, Balances, ToAuthor<Runtime>>; | ||
type ResponseHandler = XcmPallet; | ||
type AssetTrap = XcmPallet; | ||
|
@@ -1012,7 +1009,7 @@ impl pallet_xcm::Config for Runtime { | |
type XcmExecutor = XcmExecutor<XcmConfig>; | ||
type XcmTeleportFilter = Everything; | ||
type XcmReserveTransferFilter = Everything; | ||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>; | ||
type Weigher = WeightInfoBounds<weights::xcm::WestendXcmWeight<Call>, Call, MaxInstructions>; | ||
type LocationInverter = LocationInverter<Ancestry>; | ||
type Origin = Origin; | ||
type Call = Call; | ||
|
@@ -1465,6 +1462,8 @@ sp_api::impl_runtime_apis! { | |
use pallet_offences_benchmarking::Pallet as OffencesBench; | ||
use frame_system_benchmarking::Pallet as SystemBench; | ||
|
||
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>; | ||
|
||
let mut list = Vec::<BenchmarkList>::new(); | ||
|
||
// Polkadot | ||
|
@@ -1476,6 +1475,7 @@ sp_api::impl_runtime_apis! { | |
list_benchmark!(list, extra, runtime_common::slots, Slots); | ||
list_benchmark!(list, extra, runtime_parachains::configuration, Configuration); | ||
list_benchmark!(list, extra, runtime_parachains::paras, Paras); | ||
|
||
// Substrate | ||
list_benchmark!(list, extra, pallet_bags_list, BagsList); | ||
list_benchmark!(list, extra, pallet_balances, Balances); | ||
|
@@ -1494,6 +1494,10 @@ sp_api::impl_runtime_apis! { | |
list_benchmark!(list, extra, pallet_utility, Utility); | ||
list_benchmark!(list, extra, pallet_vesting, Vesting); | ||
|
||
// XCM Benchmarks | ||
// NOTE: Make sure you point to the individual modules below. | ||
list_benchmark!(list, extra, pallet_xcm_benchmarks::fungible, XcmBalances); | ||
|
||
let storage_info = AllPalletsWithSystem::storage_info(); | ||
|
||
return (list, storage_info) | ||
|
@@ -1516,6 +1520,39 @@ sp_api::impl_runtime_apis! { | |
impl pallet_offences_benchmarking::Config for Runtime {} | ||
impl frame_system_benchmarking::Config for Runtime {} | ||
|
||
use xcm::latest::MultiAsset; | ||
|
||
impl pallet_xcm_benchmarks::Config for Runtime { | ||
type XcmConfig = XcmConfig; | ||
type AccountIdConverter = LocationConverter; | ||
fn valid_destination() -> Result<MultiLocation, sp_runtime::DispatchError> { | ||
Ok(Westmint::get()) | ||
} | ||
} | ||
|
||
parameter_types! { | ||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( | ||
Westmint::get(), | ||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) }, | ||
)); | ||
} | ||
|
||
impl pallet_xcm_benchmarks::fungible::Config for Runtime { | ||
type TransactAsset = Balances; | ||
|
||
type CheckedAccount = CheckAccount; | ||
type TrustedTeleporter = TrustedTeleporter; | ||
|
||
fn get_multi_asset() -> MultiAsset { | ||
MultiAsset { | ||
id: Concrete(WndLocation::get()), | ||
fun: Fungible(1 * UNITS), | ||
} | ||
} | ||
} | ||
|
||
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>; | ||
|
||
let whitelist: Vec<TrackedStorageKey> = vec![ | ||
// Block Number | ||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), | ||
|
@@ -1529,6 +1566,12 @@ sp_api::impl_runtime_apis! { | |
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), | ||
// Treasury Account | ||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(), | ||
// Dmp DownwardMessageQueueHeads | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. justification for whitelisting these? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can assume XCM will be used once every block, and these storage items will be updated pretty much once every block. No need to double count them everywhere. |
||
hex_literal::hex!("63f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce5").to_vec().into(), | ||
// Dmp DownwardMessageQueues | ||
hex_literal::hex!("63f78c98723ddc9073523ef3beefda0ca95dac46c07a40d91506e7637ec4ba57").to_vec().into(), | ||
// Configuration ActiveConfig | ||
hex_literal::hex!("06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385").to_vec().into(), | ||
]; | ||
|
||
let mut batches = Vec::<BenchmarkBatch>::new(); | ||
|
@@ -1543,6 +1586,7 @@ sp_api::impl_runtime_apis! { | |
add_benchmark!(params, batches, runtime_common::slots, Slots); | ||
add_benchmark!(params, batches, runtime_parachains::configuration, Configuration); | ||
add_benchmark!(params, batches, runtime_parachains::paras, Paras); | ||
|
||
// Substrate | ||
add_benchmark!(params, batches, pallet_bags_list, BagsList); | ||
add_benchmark!(params, batches, pallet_balances, Balances); | ||
|
@@ -1561,6 +1605,10 @@ sp_api::impl_runtime_apis! { | |
add_benchmark!(params, batches, pallet_utility, Utility); | ||
add_benchmark!(params, batches, pallet_vesting, Vesting); | ||
|
||
// XCM Benchmarks | ||
// NOTE: Make sure you point to the individual modules below. | ||
apopiak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
add_benchmark!(params, batches, pallet_xcm_benchmarks::fungible, XcmBalances); | ||
|
||
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } | ||
Ok(batches) | ||
} | ||
|
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
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.
DQ: Why does this return a result?
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.
There may need to be some setup required to make a destination valid, for example calling some dispatchables which sets up UMP/DMP settings, or gives a chain funds or anything. Also there may be no valid destination for a chain which doesnt communicate to anyone.