-
Notifications
You must be signed in to change notification settings - Fork 1.6k
XCM Benchmarks for Asset Transactor w/ Fungible Asset #3818
Conversation
/benchmark runtime custom --chain=westend-dev --pallet=pallet_xcm_benchmarks::fungible --extrinsic="*" --steps=10 --repeat=10 --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./ --execution=wasm --wasm-execution=compiled |
Benchmark Runtime Custom for branch "shawntabrizi-fungible-benchmarks" with command cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=westend-dev --pallet=pallet_xcm_benchmarks::fungible --extrinsic="*" --steps=10 --repeat=10 --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./ --execution=wasm --wasm-execution=compiled Results
|
…k --chain=westend-dev --pallet=pallet_xcm_benchmarks::fungible --extrinsic=* --steps=10 --repeat=10 --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./ --execution=wasm --wasm-execution=compiled
/benchmark runtime custom --chain=westend-dev --pallet=pallet_xcm_benchmarks::fungible --extrinsic="*" --steps=50 --repeat=20 --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./ --execution=wasm --wasm-execution=compiled |
Benchmark Runtime Custom for branch "shawntabrizi-fungible-benchmarks" with command cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=westend-dev --pallet=pallet_xcm_benchmarks::fungible --extrinsic="*" --steps=50 --repeat=20 --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./ --execution=wasm --wasm-execution=compiled Results
ERROR: Unable to commit file ./ |
/benchmark xcm westend pallet_xcm_benchmarks::fungible |
/benchmark xcm westend pallet_xcm_benchmarks::fungible |
Benchmark Westend XCM for branch "shawntabrizi-fungible-benchmarks" with command cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=pallet_xcm_benchmarks::fungible --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs Results
ERROR: Unable to commit file ./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs |
# temp | ||
pallet-xcm = { path = "../pallet-xcm" } | ||
polkadot-runtime-common = { path = "../../runtime/common" } | ||
# westend-runtime = { path = "../../runtime/westend", features = ["runtime-benchmarks"] } |
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.
TODO remove me later
const HOLDING_FUNGIBLES: u32 = 99; | ||
const HOLDING_NON_FUNGIBLES: u32 = 99; |
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.
Should go into the config of the corresponding xcm_benchmark
pallet, right?
const HOLDING_NON_FUNGIBLES: u32 = 99; | ||
|
||
pub fn worst_case_holding() -> Assets { | ||
let fungibles_amount: u128 = 100; // TODO probably update |
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.
your opinion was always sticking to ED and multiplies thereof, which should be possible here if you pass in a T
.
let instruction = Instruction::TransferReserveAsset { | ||
assets, | ||
dest: dest_location, | ||
xcm: Xcm::new() |
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.
so the cost of this nested send is already incorporated here, this is much simpler than the old scheme of order and effect.
let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap(); | ||
assert!(T::TransactAsset::balance(&dest_account).is_zero()); | ||
|
||
let mut executor = new_executor::<T>(Default::default()); |
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.
nit: might want to make it fn new_executor<T: Config>(_: MultiLocation, initial_holding: Assets)
@@ -0,0 +1,180 @@ | |||
// Copyright 2021 Parity Technologies (UK) Ltd. |
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.
not super relevant yet since this PR is only about the fungible
, but once a fungibles
has been added as well, it would be sad to see this mock almost entirely duplicated. I think one mock runtime that implements both xcm_benchamrk::fungible::Config
and xcm_benchamrk::fungibles::Config
should work fine.
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.
LGTM, most TODOs seem to be related to the next steps, I think we can leave them, try and merge this, to keep the PRs within bite-size pieces.
Co-authored-by: Kian Paimani <[email protected]>
fn report_error( | ||
_query_id: &QueryId, | ||
_dest: &MultiLocation, | ||
max_response_weight: &u64, | ||
) -> Weight { | ||
*max_response_weight | ||
} |
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.
mark this as preliminary?
the max_response_weight
is about the response, no the error itself, right?
there should probably be a XcmGeneric::<Runtime>::report_error(query_id, dest)
or similar?
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.
👍 for XCM weights/benchmarks! 🎉
Seems to me this has a few rough edges. Unclear to me whether you want to smooth those out now or in a follow up PR.
impl pallet_xcm_benchmarks::Config for Runtime { | ||
type XcmConfig = XcmConfig; | ||
type AccountIdConverter = LocationConverter; | ||
fn valid_destination() -> Result<MultiLocation, sp_runtime::DispatchError> { |
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.
} | ||
fn deposit_reserve_asset( | ||
assets: &MultiAssetFilter, | ||
_max_assets: &u32, // TODO use max assets? |
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.
100%, would be a nice reduction in weight
fn initiate_teleport( | ||
assets: &MultiAssetFilter, | ||
_dest: &MultiLocation, | ||
_xcm: &Xcm<()>, |
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 guess we're going to weigh intiate_teleport
based on the worst-case holding?
a max_assets
would be nice here as well, right?
BenchmarkError::Override( | ||
BenchmarkResult::from_weight(T::BlockWeights::get().max_block) | ||
) |
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.
what is this covering for? shouldn't this always succeed or fail loudly?
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.
What about chains who just do not support this particular XCM. it covers that scenario where you can still run benchmarks for everything else.
The resulting number screams pretty loudly.
(0..HOLDING_FUNGIBLES) | ||
.map(|i| { | ||
MultiAsset { | ||
id: Concrete(GeneralIndex(i as u128).into()), | ||
fun: Fungible(fungibles_amount * i as u128), | ||
} | ||
.into() | ||
}) | ||
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) |
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.
This means the worst case holding amount of fungibles is 100, potentially increasing to 101 if the benchmark adds a new asset.
Is that the desired setup?
pub fn new_executor<T: Config>(origin: MultiLocation) -> ExecutorOf<T> { | ||
ExecutorOf::<T>::new(origin) | ||
} |
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.
this, (or a differently named util function) might also just populate the executor with a worst-case holding on construction
pub struct AllAssetLocationsPass; | ||
impl FilterAssetLocation for AllAssetLocationsPass { | ||
fn filter_asset_location(_: &MultiAsset, _: &MultiLocation) -> bool { | ||
true | ||
} | ||
} |
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.
This seems unused?
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.
why? it is a mock function to enable tests to pass
type CheckedAccount: Get<Option<Self::AccountId>>; | ||
|
||
/// A trusted location which we allow teleports from, and the asset we allow to teleport. | ||
type TrustedTeleporter: Get<Option<(xcm::latest::MultiLocation, xcm::latest::MultiAsset)>>; |
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.
why introduce an extra asset here?, you already have get_multi_asset
below?
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.
It can be a different asset for teleports versus other xcm messages.
why are you worried about including more information?
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.
Just trying to keep the interface/config tidy.
|
||
impl crate::Config for Test { | ||
type XcmConfig = XcmConfig; | ||
type AccountIdConverter = AccountIdConverter; |
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.
Why introduce an extra AccountIdConverter
when there is the OriginConverter
in the XcmConfig
?
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight; | ||
} | ||
|
||
// TODO wild case |
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.
Todo.
I'm guessing you'll address this in a follow-up PR?
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.
Seems fine if we iron out any kinks in follow ups.
bot merge |
Waiting for commit status. |
Merge aborted: Checks failed for 7b47f5c |
https://research.web3.foundation/ is down and causing the CI failure. |
* master: (24 commits) Added multisig in Rococo (#3873) Fix bin-substrate toml (#3939) Bump tracing from 0.1.27 to 0.1.28 (#3937) XCM Benchmarks for Asset Transactor w/ Fungible Asset (#3818) Bump libc from 0.2.101 to 0.2.102 (#3933) Do not compile `wasm_api` module when not needed. (#3934) Bump syn from 1.0.76 to 1.0.77 (#3932) Fix spelling (#3845) Bump tokio from 1.11.0 to 1.12.0 (#3910) Ignore `generate-bags` by dependabot (#3930) Update logging in paras_inherent (#3927) Bump libsecp256k1 from 0.6.0 to 0.7.0 (#3909) Remove BEEFY repo dependency (#3923) Substrate Companion for rust 1.54 (#3807) Fix broken links (#3919) update BaseXcmWegiht to match Kusama (#3911) add parachains pallets to Polkadot runtime (#3815) Add a `force_unfreeze` extrinsic to the disputes module (#3906) Add new rococo chainspec (#3905) Ensure all parachain configuration extrinsics are operational (#3912) ...
This PR includes benchmarks for XCMs which use the
AssetTransactor
trait, implemented for an asset which implements theFungible
trait.