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

Fix and migrated benchmarking of lend-market from v1 to v2. #1587

Merged
merged 3 commits into from
Jan 6, 2025
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
697 changes: 513 additions & 184 deletions pallets/lend-market/src/benchmarking.rs

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions pallets/lend-market/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,36 @@ pub const ACTIVE_MARKET_MOCK: Market<Balance> = {
market.state = MarketState::Active;
market
};

pub struct ExtBuilder {
balances: Vec<(AccountId, Balance)>,
}

impl Default for ExtBuilder {
fn default() -> Self {
Self { balances: vec![] }
}
}

impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default()
.build_storage()
.unwrap();

pallet_balances::GenesisConfig::<Test> {
balances: self.balances.into_iter().collect::<Vec<_>>(),
}
.assimilate_storage(&mut t)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
}
}

#[cfg(feature = "runtime-benchmarks")]
pub fn new_test_ext_benchmark() -> sp_io::TestExternalities {
ExtBuilder::default().build()
}
1,644 changes: 462 additions & 1,182 deletions pallets/lend-market/src/weights.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,7 @@ impl lend_market::Config for Runtime {
type OraclePriceProvider = Prices;
type ReserveOrigin = TechAdminOrCouncil;
type UpdateOrigin = TechAdminOrCouncil;
type WeightInfo = lend_market::weights::BifrostWeight<Runtime>;
type WeightInfo = weights::lend_market::BifrostWeight<Runtime>;
type UnixTime = Timestamp;
type Assets = Currencies;
type RewardAssetId = NativeCurrencyId;
Expand Down
570 changes: 570 additions & 0 deletions runtime/bifrost-kusama/src/weights/lend_market.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions runtime/bifrost-kusama/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub mod bifrost_vstoken_conversion;
pub mod bifrost_vtoken_minting;
pub mod bifrost_vtoken_voting;
pub mod bifrost_xcm_interface;
pub mod lend_market;
pub mod orml_oracle;
pub mod orml_tokens;
pub mod pallet_xcm;
2 changes: 1 addition & 1 deletion runtime/bifrost-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ impl lend_market::Config for Runtime {
type OraclePriceProvider = Prices;
type ReserveOrigin = TechAdminOrCouncil;
type UpdateOrigin = TechAdminOrCouncil;
type WeightInfo = lend_market::weights::BifrostWeight<Runtime>;
type WeightInfo = weights::lend_market::BifrostWeight<Runtime>;
type UnixTime = Timestamp;
type Assets = Currencies;
type RewardAssetId = NativeCurrencyId;
Expand Down
570 changes: 570 additions & 0 deletions runtime/bifrost-polkadot/src/weights/lend_market.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions runtime/bifrost-polkadot/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub mod bifrost_vstoken_conversion;
pub mod bifrost_vtoken_minting;
pub mod bifrost_vtoken_voting;
pub mod bifrost_xcm_interface;
pub mod lend_market;
pub mod orml_oracle;
pub mod orml_tokens;
pub mod pallet_xcm;