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

Lend market bench #1043

Merged
merged 3 commits into from
Sep 14, 2023
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
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
Loading