Skip to content

Commit

Permalink
Fix and migrated benchmarking of lend-market from v1 to v2. (#1587)
Browse files Browse the repository at this point in the history
* v1, clippy failed

* bug free;v1;comments to be removed.

* Fix and migrated benchmarking of lend-market from v1 to v2.
  • Loading branch information
MJLNSN authored Jan 6, 2025
1 parent 2411c1f commit 9a9935e
Show file tree
Hide file tree
Showing 9 changed files with 2,152 additions and 1,368 deletions.
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;

0 comments on commit 9a9935e

Please sign in to comment.