Skip to content

Commit

Permalink
fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Jul 24, 2024
1 parent 127e983 commit d44ca37
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pallets/investments/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ where

#[cfg(test)]
crate::mock::MockAccountant::mock_bench_default_investment_id(|_| {
crate::mock::InvestmentId::default()
cfg_primitives::InvestmentId::default()
});

T::Accountant::bench_create_funded_pool(pool_id, &pool_admin);
Expand Down
17 changes: 6 additions & 11 deletions pallets/pool-registry/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@

//! Module provides benchmarking for Loan Pallet
use cfg_primitives::PoolEpochId;
use cfg_traits::{
benchmarking::PoolFeesBenchmarkHelper, fee::PoolFeeBucket, investments::TrancheCurrency as _,
};
use cfg_types::{
pools::TrancheMetadata,
tokens::{CurrencyId, TrancheCurrency},
};
use cfg_traits::{benchmarking::PoolFeesBenchmarkHelper, fee::PoolFeeBucket};
use cfg_types::{pools::TrancheMetadata, tokens::CurrencyId};
use frame_benchmarking::benchmarks;
use frame_support::traits::fungibles::Inspect;
use frame_system::RawOrigin;
Expand Down Expand Up @@ -61,7 +56,7 @@ benchmarks! {
<PoolId = u64,
TrancheId = [u8; 16],
Balance = u128,
CurrencyId = CurrencyId> + pallet_investments::Config<InvestmentId = TrancheCurrency, Amount = u128>,
CurrencyId = CurrencyId> + pallet_investments::Config<InvestmentId = (u64, [u8; 16]), Amount = u128>,
T: pallet_pool_system::Config<PoolId = u64,
TrancheId = [u8; 16],
Balance = u128,
Expand Down Expand Up @@ -136,7 +131,7 @@ benchmarks! {
let amount = MAX_RESERVE / 2;
let investor = create_investor::<T>(0, TRANCHE, Some(amount))?;
let locator = get_tranche_id::<T>(TRANCHE);
pallet_investments::Pallet::<T>::update_redeem_order(RawOrigin::Signed(investor.clone()).into(), TrancheCurrency::generate(POOL, locator), amount)?;
pallet_investments::Pallet::<T>::update_redeem_order(RawOrigin::Signed(investor.clone()).into(), (POOL, locator), amount)?;


let changes = PoolChanges {
Expand Down Expand Up @@ -202,12 +197,12 @@ benchmarks! {
let investor = create_investor::<T>(0, TRANCHE, Some(1))?;
let locator = get_tranche_id::<T>(TRANCHE);
// Submit redemption order so the update isn't immediately executed
pallet_investments::Pallet::<T>::update_redeem_order(RawOrigin::Signed(investor.clone()).into(), TrancheCurrency::generate(POOL, locator), 1)?;
pallet_investments::Pallet::<T>::update_redeem_order(RawOrigin::Signed(investor.clone()).into(), (POOL, locator), 1)?;

update_pool::<T>(changes.clone())?;

// Withdraw redeem order so the update can be executed after that
pallet_investments::Pallet::<T>::update_redeem_order(RawOrigin::Signed(investor.clone()).into(), TrancheCurrency::generate(POOL, locator), 0)?;
pallet_investments::Pallet::<T>::update_redeem_order(RawOrigin::Signed(investor.clone()).into(), (POOL, locator), 0)?;
}: execute_update(RawOrigin::Signed(admin), POOL)
verify {
let pool = get_pool::<T>();
Expand Down
13 changes: 6 additions & 7 deletions pallets/pool-system/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ use cfg_primitives::PoolEpochId;
use cfg_traits::{
benchmarking::PoolFeesBenchmarkHelper,
fee::{PoolFeeBucket, PoolFeesInspect},
investments::TrancheCurrency as _,
UpdateState,
};
use cfg_types::{
pools::{PoolFeeInfo, TrancheMetadata},
tokens::{CurrencyId, CustomMetadata, TrancheCurrency},
tokens::{CurrencyId, CustomMetadata},
};
use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite};
use frame_support::traits::Currency;
Expand Down Expand Up @@ -54,7 +53,7 @@ benchmarks! {
Balance = u128,
CurrencyId = CurrencyId,
EpochId = PoolEpochId>
+ pallet_investments::Config<InvestmentId = TrancheCurrency, Amount = u128>,
+ pallet_investments::Config<InvestmentId = (u64, T::TrancheId), Amount = u128>,
<T as pallet_investments::Config>::Tokens: Inspect<T::AccountId, AssetId = CurrencyId, Balance = u128>,
T::AccountId: EncodeLike<<T as frame_system::Config>::AccountId>,
<<T as frame_system::Config>::Lookup as sp_runtime::traits::StaticLookup>::Source:
Expand Down Expand Up @@ -109,7 +108,7 @@ benchmarks! {
let investment = MAX_RESERVE * 2;
let investor = create_investor::<T>(0, TRANCHE, None)?;
let origin = RawOrigin::Signed(investor.clone()).into();
pallet_investments::Pallet::<T>::update_invest_order(origin, TrancheCurrency::generate(POOL, get_tranche_id::<T>(TRANCHE)), investment)?;
pallet_investments::Pallet::<T>::update_invest_order(origin, (POOL, get_tranche_id::<T>(TRANCHE)), investment)?;
}: close_epoch(RawOrigin::Signed(admin.clone()), POOL)
verify {
assert_eq!(get_pool::<T>().epoch.last_executed, 0);
Expand All @@ -129,7 +128,7 @@ benchmarks! {
let investment = MAX_RESERVE / 2;
let investor = create_investor::<T>(0, TRANCHE, None)?;
let origin = RawOrigin::Signed(investor.clone()).into();
pallet_investments::Pallet::<T>::update_invest_order(origin, TrancheCurrency::generate(POOL, get_tranche_id::<T>(TRANCHE)), investment)?;
pallet_investments::Pallet::<T>::update_invest_order(origin, (POOL, get_tranche_id::<T>(TRANCHE)), investment)?;
}: close_epoch(RawOrigin::Signed(admin.clone()), POOL)
verify {
assert_eq!(get_pool::<T>().epoch.last_executed, 1);
Expand All @@ -149,7 +148,7 @@ benchmarks! {
let investment = MAX_RESERVE * 2;
let investor = create_investor::<T>(0, TRANCHE, None)?;
let origin = RawOrigin::Signed(investor.clone()).into();
pallet_investments::Pallet::<T>::update_invest_order(origin, TrancheCurrency::generate(POOL, get_tranche_id::<T>(TRANCHE)), investment)?;
pallet_investments::Pallet::<T>::update_invest_order(origin, (POOL, get_tranche_id::<T>(TRANCHE)), investment)?;

let admin_origin = RawOrigin::Signed(admin.clone()).into();
Pallet::<T>::close_epoch(admin_origin, POOL)?;
Expand Down Expand Up @@ -180,7 +179,7 @@ benchmarks! {
let investment = MAX_RESERVE * 2;
let investor = create_investor::<T>(0, TRANCHE, None)?;
let origin = RawOrigin::Signed(investor.clone()).into();
pallet_investments::Pallet::<T>::update_invest_order(origin, TrancheCurrency::generate(POOL, get_tranche_id::<T>(TRANCHE)), investment)?;
pallet_investments::Pallet::<T>::update_invest_order(origin, (POOL, get_tranche_id::<T>(TRANCHE)), investment)?;

let admin_origin = RawOrigin::Signed(admin.clone()).into();
Pallet::<T>::close_epoch(admin_origin, POOL)?;
Expand Down

0 comments on commit d44ca37

Please sign in to comment.