From b17dc0b2fb0431f813cca5de1253585c42fe139e Mon Sep 17 00:00:00 2001 From: Malte Kliemann Date: Tue, 3 Dec 2024 18:29:35 +0100 Subject: [PATCH] Fix benchmarks --- primitives/src/constants/base_multiples.rs | 1 + scripts/benchmarks/configuration.sh | 2 +- zrml/neo-swaps/src/benchmarking.rs | 26 +++++++++++----------- zrml/prediction-markets/src/benchmarks.rs | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/primitives/src/constants/base_multiples.rs b/primitives/src/constants/base_multiples.rs index 2f8c41d8e..ee7686516 100644 --- a/primitives/src/constants/base_multiples.rs +++ b/primitives/src/constants/base_multiples.rs @@ -40,6 +40,7 @@ pub const _40: u128 = 40 * _1; pub const _70: u128 = 70 * _1; pub const _80: u128 = 80 * _1; pub const _100: u128 = 100 * _1; +pub const _200: u128 = 200 * _1; pub const _101: u128 = 101 * _1; pub const _444: u128 = 444 * _1; pub const _500: u128 = 500 * _1; diff --git a/scripts/benchmarks/configuration.sh b/scripts/benchmarks/configuration.sh index f363f34ec..5dc6c0905 100644 --- a/scripts/benchmarks/configuration.sh +++ b/scripts/benchmarks/configuration.sh @@ -4,7 +4,7 @@ EXTERNAL_WEIGHTS_PATH="./runtime/common/src/weights/" # This script contains the configuration for other benchmarking scripts. export FRAME_PALLETS=( - frame_system pallet_balances pallet_bounties pallet_collective pallet_contracts \ + frame_system pallet_balances pallet_bounties pallet_collective \ pallet_democracy pallet_identity pallet_membership pallet_multisig pallet_preimage \ pallet_proxy pallet_scheduler pallet_timestamp pallet_treasury pallet_utility \ pallet_vesting \ diff --git a/zrml/neo-swaps/src/benchmarking.rs b/zrml/neo-swaps/src/benchmarking.rs index 22c0d58b2..2290dba9d 100644 --- a/zrml/neo-swaps/src/benchmarking.rs +++ b/zrml/neo-swaps/src/benchmarking.rs @@ -266,7 +266,7 @@ mod benchmarks { /// TODO(#1221): Replace hardcoded variant with `{ MAX_ASSETS as u32 }` as soon as possible. #[benchmark] - fn buy(n: Linear<2, 128>) { + fn buy(n: Linear<2, 4>) { let alice = whitelisted_caller(); let base_asset = Asset::Ztg; let asset_count = n.try_into().unwrap(); @@ -274,10 +274,10 @@ mod benchmarks { alice, base_asset, asset_count, - _10.saturated_into(), + (100 * _100).saturated_into(), ); let asset_out = Asset::CategoricalOutcome(market_id, 0); - let amount_in = _1.saturated_into(); + let amount_in = _1000.saturated_into(); let min_amount_out = 0u8.saturated_into(); let helper = BenchmarkHelper::::new(); @@ -297,10 +297,10 @@ mod benchmarks { alice, base_asset, asset_count, - _10.saturated_into(), + (100 * _100).saturated_into(), ); let asset_in = Asset::CategoricalOutcome(market_id, asset_count - 1); - let amount_in = _1.saturated_into(); + let amount_in = _100.saturated_into(); let min_amount_out = 0u8.saturated_into(); let helper = BenchmarkHelper::::new(); @@ -322,14 +322,14 @@ mod benchmarks { alice.clone(), base_asset, asset_count, - _10.saturated_into(), + (100 * _100).saturated_into(), ); let helper = BenchmarkHelper::::new(); let bob = helper.accounts().next().unwrap(); helper.populate_liquidity_tree_until_full(market_id, bob.clone()); let pool_shares_amount = _1.saturated_into(); // Due to rounding, we need to buy a little more than the pool share amount. - let complete_set_amount = _100.saturated_into(); + let complete_set_amount = _1000.saturated_into(); helper.set_up_liquidity_benchmark(market_id, bob.clone(), Some(complete_set_amount)); let max_amounts_in = vec![u128::MAX.saturated_into(); asset_count as usize]; @@ -354,7 +354,7 @@ mod benchmarks { alice.clone(), base_asset, asset_count, - _10.saturated_into(), + (100 * _100).saturated_into(), ); let helper = BenchmarkHelper::::new(); helper.populate_liquidity_tree_with_abandoned_node(market_id); @@ -386,7 +386,7 @@ mod benchmarks { alice.clone(), base_asset, asset_count, - _10.saturated_into(), + (100 * _100).saturated_into(), ); let helper = BenchmarkHelper::::new(); helper.populate_liquidity_tree_with_free_leaf(market_id); @@ -424,7 +424,7 @@ mod benchmarks { alice.clone(), base_asset, asset_count, - _10.saturated_into(), + (100 * _100).saturated_into(), ); let min_amounts_out = vec![0u8.into(); asset_count as usize]; @@ -449,7 +449,7 @@ mod benchmarks { alice.clone(), Asset::Ztg, 2u16, - _10.saturated_into(), + (100 * _100).saturated_into(), ); let helper = BenchmarkHelper::::new(); let bob = helper.accounts().next().unwrap(); @@ -459,7 +459,7 @@ mod benchmarks { // Mock up some fees. Needs to be large enough to ensure that Bob's share is not smaller // than the existential deposit. let max_node_count = LiquidityTreeOf::::max_node_count() as u128; - let fee_amount = (max_node_count * _10).saturated_into(); + let fee_amount = (max_node_count * _1000).saturated_into(); deposit_fees::(market_id, fee_amount); #[extrinsic_call] @@ -472,7 +472,7 @@ mod benchmarks { let base_asset = Asset::Ztg; let asset_count = n.try_into().unwrap(); let market_id = create_market::(alice.clone(), base_asset, asset_count); - let amount = _10.saturated_into(); + let amount = (100 * _100).saturated_into(); let total_cost = amount + T::MultiCurrency::minimum_balance(base_asset); assert_ok!(T::MultiCurrency::deposit(base_asset, &alice, total_cost)); diff --git a/zrml/prediction-markets/src/benchmarks.rs b/zrml/prediction-markets/src/benchmarks.rs index 228b86195..b1ce5e7ff 100644 --- a/zrml/prediction-markets/src/benchmarks.rs +++ b/zrml/prediction-markets/src/benchmarks.rs @@ -1293,7 +1293,7 @@ benchmarks! { let asset_count = n.try_into().unwrap(); let market_type = MarketType::Categorical(asset_count); let (caller, oracle, deadlines, metadata) = create_market_common_parameters::(true)?; - let amount = (10u128 * BASE).saturated_into(); + let amount = (10_000u128 * BASE).saturated_into(); ::AssetManager::deposit( base_asset,