Skip to content

Commit

Permalink
Lend market bench (#1043)
Browse files Browse the repository at this point in the history
* fix: 🐛 fix benchmarket

* fix: 🐛 format

* fix: 🐛 check-all
  • Loading branch information
yooml authored Sep 14, 2023
1 parent a6bedc3 commit c81ca42
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 172 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

7 changes: 6 additions & 1 deletion pallets/lend-market/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ serde = { version = "1.0.160", features = ['derive'], optional = true }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.42", default-features = false}

[dev-dependencies]
orml-oracle = "0.4.1-dev"
Expand All @@ -39,7 +40,10 @@ bifrost-currencies = { path = "../currencies", default-features = false }

[features]
default = ['std']
runtime-benchmarks = ['frame-benchmarking']
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
]
std = [
'codec/std',
'frame-support/std',
Expand All @@ -59,6 +63,7 @@ std = [
'num-traits/std',
'pallet-traits/std',
"bifrost-asset-registry/std",
"xcm-builder/std",
]
try-runtime = ['frame-support/try-runtime']

Expand Down
253 changes: 85 additions & 168 deletions pallets/lend-market/src/benchmarking.rs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pallets/lend-market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ use sp_io::hashing::blake2_256;
pub use types::{BorrowSnapshot, Deposits, EarnedSnapshot, Market, MarketState, RewardMarketState};
pub use weights::WeightInfo;

#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;

#[cfg(test)]
mod mock;
pub mod mock;
#[cfg(test)]
mod tests;

Expand Down
17 changes: 15 additions & 2 deletions pallets/lend-market/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

pub use super::*;

use bifrost_asset_registry::AssetIdMaps;
use frame_support::{
construct_runtime, parameter_types,
traits::{AsEnsureOriginWithArg, Everything, Nothing, SortedMembers},
Expand Down Expand Up @@ -56,6 +57,7 @@ construct_runtime!(
LendMarket: crate::{Pallet, Storage, Call, Event<T>},
TimestampPallet: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
Prices: pallet_prices::{Pallet, Storage, Call, Event<T>},
}
);

Expand Down Expand Up @@ -308,8 +310,19 @@ impl pallet_assets::Config for Test {
type WeightInfo = ();
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
type CallbackHandle = ();
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
// #[cfg(feature = "runtime-benchmarks")]
// type BenchmarkHelper = ();
}

impl pallet_prices::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Source = MockDataProvider;
type FeederOrigin = EnsureRoot<AccountId>;
type UpdateOrigin = EnsureRoot<AccountId>;
type RelayCurrency = RelayCurrency;
type Assets = Currencies;
type CurrencyIdConvert = AssetIdMaps<Test>;
type WeightInfo = ();
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions runtime/bifrost-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ runtime-benchmarks = [
"bifrost-slpx/runtime-benchmarks",
"bifrost-stable-pool/runtime-benchmarks",
"bifrost-vtoken-voting/runtime-benchmarks",
"lend-market/runtime-benchmarks",
]

try-runtime = [
Expand Down
1 change: 1 addition & 0 deletions runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2079,6 +2079,7 @@ mod benches {
[bifrost_slpx, Slpx]
[bifrost_stable_pool, StablePool]
[bifrost_vtoken_voting, VtokenVoting]
[lend_market, LendMarket]
);
}

Expand Down

0 comments on commit c81ca42

Please sign in to comment.