Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pallet_xcm benchmark #2765

Merged
merged 9 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ pallet-transaction-payment-rpc-runtime-api = { version = "31.0.0", default-featu
pallet-treasury = { version = "30.0.0", default-features = false }
pallet-utility = { version = "31.0.0", default-features = false }
pallet-xcm = { version = "10.0.1", default-features = false }
pallet-xcm-benchmarks = { version = "10.0.0", default-features = false }
parachain-info = { version = "0.10.0", package = "staging-parachain-info", default-features = false }
parachains-common = { version = "10.0.0", default-features = false }
polkadot-core-primitives = { version = "10.0.0", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions modules/incentives/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ fn claim_reward_deduction_currency_works() {
#[test]
fn nominees_election_should_work() {
ExtBuilder::default().build().execute_with(|| {
OnNomineesElectionBonded::<Runtime>::handle(&(ALICE::get(), 80));
assert_ok!(OnNomineesElectionBonded::<Runtime>::handle(&(ALICE::get(), 80)));
assert_eq!(
RewardsModule::pool_infos(PoolId::NomineesElection),
PoolInfo {
Expand All @@ -1355,7 +1355,7 @@ fn nominees_election_should_work() {
(80, Default::default())
);

OnNomineesElectionUnbonded::<Runtime>::handle(&(ALICE::get(), 20));
assert_ok!(OnNomineesElectionUnbonded::<Runtime>::handle(&(ALICE::get(), 20)));
assert_eq!(
RewardsModule::pool_infos(PoolId::NomineesElection),
PoolInfo {
Expand All @@ -1368,7 +1368,7 @@ fn nominees_election_should_work() {
(60, Default::default())
);

OnNomineesElectionUnbonded::<Runtime>::handle(&(ALICE::get(), 60));
assert_ok!(OnNomineesElectionUnbonded::<Runtime>::handle(&(ALICE::get(), 60)));
assert_eq!(
RewardsModule::pool_infos(PoolId::NomineesElection),
PoolInfo { ..Default::default() }
Expand Down
3 changes: 3 additions & 0 deletions runtime/acala/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ xcm = { workspace = true }
xcm-executor = { workspace = true }
xcm-builder = { workspace = true }
pallet-xcm = { workspace = true }
pallet-xcm-benchmarks = { workspace = true, optional = true }
polkadot-runtime-common = { workspace = true }
parachains-common = { workspace = true }

Expand Down Expand Up @@ -292,7 +293,9 @@ runtime-benchmarks = [

"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"cumulus-primitives-utility/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"pallet-xcm-benchmarks/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
Expand Down
84 changes: 83 additions & 1 deletion runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,10 @@ mod benches {
[module_liquid_crowdloan, benchmarking::liquid_crowdloan]
[module_nominees_election, benchmarking::nominees_election]
);
// frame_benchmarking::define_benchmarks!(
// // XCM
// [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
// );
zjb0807 marked this conversation as resolved.
Show resolved Hide resolved
}

#[cfg(not(feature = "disable-runtime-api"))]
Expand Down Expand Up @@ -2367,6 +2371,7 @@ sp_api::impl_runtime_apis! {
use frame_benchmarking::{list_benchmark as frame_list_benchmark, Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait;
use module_nft::benchmarking::Pallet as NftBench;
// use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;

let mut list = Vec::<BenchmarkList>::new();

Expand All @@ -2381,10 +2386,87 @@ sp_api::impl_runtime_apis! {
fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark as frame_add_benchmark};
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError, add_benchmark as frame_add_benchmark};
use module_nft::benchmarking::Pallet as NftBench;
use frame_support::traits::{WhitelistedStorageKeys, TrackedStorageKey};

// const UNITS: Balance = 1_000_000_000_000;
// const CENTS: Balance = UNITS / 100;

// parameter_types! {
// pub FeeAssetId: AssetId = AssetId(Location::parent());
// pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
// }
// pub type PriceForParentDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
// FeeAssetId,
// BaseDeliveryFee,
// TransactionByteFee,
// ParachainSystem,
// >;

// use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
// impl pallet_xcm::benchmarking::Config for Runtime {
// type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
// xcm_config::XcmConfig,
// ExistentialDepositAsset,
// PriceForParentDelivery,
// >;
// fn reachable_dest() -> Option<Location> {
// Some(Parent.into())
// }

// fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
// Some((
// Asset {
// fun: Fungible(NativeTokenExistentialDeposit::get()),
// id: AssetId(Parent.into())
// },
// Parent.into(),
// ))
// }

// fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
// None
// }

// fn get_asset() -> Asset {
// Asset {
// id: AssetId(Location::parent()),
// fun: Fungible(UNITS),
// }
// }
// }

// parameter_types! {
// pub ExistentialDepositAsset: Option<Asset> = Some((
// Location::parent(),
// NativeTokenExistentialDeposit::get()
// ).into());
// }

// impl pallet_xcm_benchmarks::Config for Runtime {
// type XcmConfig = xcm_config::XcmConfig;
// type AccountIdConverter = xcm_config::LocationToAccountId;
// type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
// xcm_config::XcmConfig,
// ExistentialDepositAsset,
// PriceForParentDelivery,
// >;
// fn valid_destination() -> Result<Location, BenchmarkError> {
// Ok(Location::parent())
// }
// fn worst_case_holding(_depositable_count: u32) -> Assets {
// // just concrete assets according to relay chain.
// let assets: Vec<Asset> = vec![
// Asset {
// id: AssetId(Location::parent()),
// fun: Fungible(1_000_000 * UNITS),
// }
// ];
// assets.into()
// }
// }

let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();

// Treasury Account
Expand Down
Loading
Loading