Skip to content

Commit

Permalink
Fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
maltekliemann committed Dec 3, 2024
1 parent 4cfae80 commit b17dc0b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions primitives/src/constants/base_multiples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion scripts/benchmarks/configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
26 changes: 13 additions & 13 deletions zrml/neo-swaps/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,18 @@ 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();
let market_id = create_market_and_deploy_pool::<T>(
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::<T>::new();
Expand All @@ -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::<T>::new();
Expand All @@ -322,14 +322,14 @@ mod benchmarks {
alice.clone(),
base_asset,
asset_count,
_10.saturated_into(),
(100 * _100).saturated_into(),
);
let helper = BenchmarkHelper::<T>::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];

Expand All @@ -354,7 +354,7 @@ mod benchmarks {
alice.clone(),
base_asset,
asset_count,
_10.saturated_into(),
(100 * _100).saturated_into(),
);
let helper = BenchmarkHelper::<T>::new();
helper.populate_liquidity_tree_with_abandoned_node(market_id);
Expand Down Expand Up @@ -386,7 +386,7 @@ mod benchmarks {
alice.clone(),
base_asset,
asset_count,
_10.saturated_into(),
(100 * _100).saturated_into(),
);
let helper = BenchmarkHelper::<T>::new();
helper.populate_liquidity_tree_with_free_leaf(market_id);
Expand Down Expand Up @@ -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];

Expand All @@ -449,7 +449,7 @@ mod benchmarks {
alice.clone(),
Asset::Ztg,
2u16,
_10.saturated_into(),
(100 * _100).saturated_into(),
);
let helper = BenchmarkHelper::<T>::new();
let bob = helper.accounts().next().unwrap();
Expand All @@ -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::<T>::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::<T>(market_id, fee_amount);

#[extrinsic_call]
Expand All @@ -472,7 +472,7 @@ mod benchmarks {
let base_asset = Asset::Ztg;
let asset_count = n.try_into().unwrap();
let market_id = create_market::<T>(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));
Expand Down
2 changes: 1 addition & 1 deletion zrml/prediction-markets/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<T>(true)?;
let amount = (10u128 * BASE).saturated_into();
let amount = (10_000u128 * BASE).saturated_into();

<T as pallet::Config>::AssetManager::deposit(
base_asset,
Expand Down

0 comments on commit b17dc0b

Please sign in to comment.