diff --git a/pallets/liquidity-mining/src/mock.rs b/pallets/liquidity-mining/src/mock.rs index 7d8630f14..698d7c4a1 100644 --- a/pallets/liquidity-mining/src/mock.rs +++ b/pallets/liquidity-mining/src/mock.rs @@ -121,6 +121,7 @@ parameter_types! { pub const TresuryPalletId: PalletId = PalletId(*b"OCEX_TRE"); pub const LMPRewardsPalletId: PalletId = PalletId(*b"OCEX_TMP"); pub const MsPerDay: u64 = 86_400_000; + pub const OBWithdrawalLimit: u32 = 50; } impl crate::pallet::Config for Test { @@ -142,6 +143,7 @@ impl ocex::Config for Test { type AuthorityId = ocex::sr25519::AuthorityId; type GovernanceOrigin = EnsureRoot; type CrowdSourceLiqudityMining = LiqudityMining; + type OBWithdrawalLimit = OBWithdrawalLimit; type WeightInfo = ocex::weights::WeightInfo; } diff --git a/pallets/ocex/src/benchmarking.rs b/pallets/ocex/src/benchmarking.rs index b0ef15e11..7a0486b8a 100644 --- a/pallets/ocex/src/benchmarking.rs +++ b/pallets/ocex/src/benchmarking.rs @@ -311,6 +311,7 @@ benchmarks! { }: _(RawOrigin::Signed(main.clone()), x as u64, main.clone()) verify { assert_last_event::(Event::WithdrawalClaimed { + snapshot_id: x as u64, main, withdrawals: vec_withdrawals, }.into()); @@ -572,7 +573,9 @@ fn create_trade_metrics() -> TradingPairMetricsMap { fn get_dummy_snapshot() -> SnapshotSummary { let mut withdrawals = Vec::new(); - for _ in 0..20 { + let pallet_account = Ocex::::get_pallet_account(); + T::NativeCurrency::deposit_creating(&pallet_account, (1000u128 * UNIT_BALANCE).saturated_into()); + for _ in 0..50 { withdrawals.push(Withdrawal { main_account: T::AccountId::decode(&mut &[0u8; 32][..]).unwrap(), amount: Decimal::one(), diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index e510939a0..7ee0a04b7 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -243,6 +243,10 @@ pub mod pallet { #[pallet::constant] type LMPRewardsPalletId: Get; + /// Orderbook withdrawal Limit + #[pallet::constant] + type OBWithdrawalLimit: Get; + /// Balances Pallet type NativeCurrency: Currency + ReservableCurrency @@ -810,9 +814,6 @@ pub mod pallet { // Anyone can claim the withdrawal for any user // This is to build services that can enable free withdrawals similar to CEXes. let _ = ensure_signed(origin)?; - // This vector will keep track of withdrawals processed already - let mut processed_withdrawals = vec![]; - let mut failed_withdrawals = vec![]; ensure!( >::contains_key(snapshot_id), Error::::InvalidWithdrawalIndex @@ -822,50 +823,28 @@ pub mod pallet { // return Err >::mutate(snapshot_id, |btree_map| { // Get mutable reference to the withdrawals vector - if let Some(withdrawal_vector) = btree_map.get_mut(&account) { - while !withdrawal_vector.is_empty() { - // Perform pop operation to ensure we do not leave any withdrawal left - // for a double spend - if let Some(withdrawal) = withdrawal_vector.pop() { - if Self::on_idle_withdrawal_processor(withdrawal.clone()) { - processed_withdrawals.push(withdrawal.to_owned()); - } else { - // Storing the failed withdrawals back into the storage item - failed_withdrawals.push(withdrawal.to_owned()); - Self::deposit_event(Event::WithdrawalFailed(withdrawal.to_owned())); - } - } else { - return Err(Error::::InvalidWithdrawalAmount); - } - } + if let Some(withdrawal_vector) = btree_map.remove(&account) { + let (failed_withdrawals, processed_withdrawals) = + Self::do_withdraw(snapshot_id, withdrawal_vector); // Not removing key from BtreeMap so that failed withdrawals can still be // tracked btree_map.insert(account.clone(), failed_withdrawals); + + if !processed_withdrawals.is_empty() { + Self::deposit_event(Event::WithdrawalClaimed { + snapshot_id, + main: account.clone(), + withdrawals: processed_withdrawals.clone(), + }); + } Ok(()) } else { // This allows us to ensure we do not have someone with an invalid account Err(Error::::InvalidWithdrawalIndex) } })?; - if !processed_withdrawals.is_empty() { - Self::deposit_event(Event::WithdrawalClaimed { - main: account.clone(), - withdrawals: processed_withdrawals.clone(), - }); - >::mutate(|onchain_events| { - onchain_events.push( - orderbook_primitives::ocex::OnChainEvents::OrderBookWithdrawalClaimed( - snapshot_id, - account.clone(), - processed_withdrawals, - ), - ); - }); - Ok(Pays::No.into()) - } else { - // If someone withdraws nothing successfully - should pay for such transaction - Ok(Pays::Yes.into()) - } + + Ok(Pays::Yes.into()) } /// Allowlist Token @@ -904,6 +883,7 @@ pub mod pallet { _signatures: Vec<(u16, ::Signature)>, ) -> DispatchResult { ensure_none(origin)?; + let snapshot_id = summary.snapshot_id; // Update the trader's performance on-chain if let Some(ref metrics) = summary.trader_metrics { Self::update_lmp_scores(metrics)?; @@ -912,17 +892,26 @@ pub mod pallet { Self::process_egress_msg(summary.egress_messages.as_ref())?; if !summary.withdrawals.is_empty() { let withdrawal_map = Self::create_withdrawal_tree(&summary.withdrawals); - >::insert(summary.snapshot_id, withdrawal_map); + let mut failed_withdrawal_map = crate::pallet::WithdrawalsMap::::new(); + for (account, withdrawals) in withdrawal_map { + let (failed_withdraws, successful_withdraws) = + Self::do_withdraw(snapshot_id, withdrawals); + if !failed_withdraws.is_empty() { + failed_withdrawal_map.insert(account.clone(), failed_withdraws); + } + if !successful_withdraws.is_empty() { + Self::deposit_event(Event::WithdrawalClaimed { + snapshot_id, + main: account.clone(), + withdrawals: successful_withdraws.clone(), + }); + } + } + if !failed_withdrawal_map.is_empty() { + >::insert(summary.snapshot_id, failed_withdrawal_map); + } let fees = summary.get_fees(); Self::settle_withdrawal_fees(fees)?; - >::mutate(|onchain_events| { - onchain_events.push( - orderbook_primitives::ocex::OnChainEvents::OrderbookWithdrawalProcessed( - summary.snapshot_id, - summary.withdrawals.clone(), - ), - ); - }); } let id = summary.snapshot_id; >::put(id); @@ -1103,6 +1092,7 @@ pub mod pallet { EnclaveCleanup(Vec), TradingPairIsNotOperational, WithdrawalClaimed { + snapshot_id: u64, main: T::AccountId, withdrawals: Vec>, }, @@ -1118,8 +1108,8 @@ pub mod pallet { TokenAllowlisted(AssetId), /// AllowlistedTokenRemoved AllowlistedTokenRemoved(AssetId), - /// Withdrawal failed - WithdrawalFailed(Withdrawal), + /// Withdrawal ready to claim + WithdrawalReady(u64, Withdrawal), /// Exchange state has been updated ExchangeStateUpdated(bool), /// DisputePeriod has been updated @@ -1318,6 +1308,32 @@ pub mod pallet { StorageValue<_, AuctionInfo>, OptionQuery>; impl crate::pallet::Pallet { + pub fn do_withdraw( + snapshot_id: u64, + mut withdrawal_vector: Vec>, + ) -> (Vec>, Vec>) { + let mut failed_withdrawals = Vec::new(); + let mut processed_withdrawals = Vec::new(); + while !withdrawal_vector.is_empty() { + // Perform pop operation to ensure we do not leave any withdrawal left + // for a double spend + if let Some(withdrawal) = withdrawal_vector.pop() { + if Self::on_idle_withdrawal_processor(withdrawal.clone()) { + processed_withdrawals.push(withdrawal.to_owned()); + } else { + // Storing the failed withdrawals back into the storage item + failed_withdrawals.push(withdrawal.to_owned()); + Self::deposit_event(Event::WithdrawalReady( + snapshot_id, + withdrawal.to_owned(), + )); + } + } + } + + (failed_withdrawals, processed_withdrawals) + } + pub fn do_claim_lmp_rewards( main: T::AccountId, epoch: u16, @@ -2144,6 +2160,10 @@ impl>> Pallet>::get(snapshot_summary.validator_set_id).validators; diff --git a/pallets/ocex/src/mock.rs b/pallets/ocex/src/mock.rs index 869e97684..9c1380fba 100644 --- a/pallets/ocex/src/mock.rs +++ b/pallets/ocex/src/mock.rs @@ -125,6 +125,7 @@ parameter_types! { pub const TreasuryPalletId: PalletId = PalletId(*b"OCEX_TRS"); //pub const TreasuryPalletId: PalletId = PalletId(*b"OCEX_CRW"); pub const MsPerDay: u64 = 86_400_000; + pub const OBWithdrawalLimit: u32 = 50; } impl pallet_lmp::pallet::Config for Test { @@ -147,6 +148,7 @@ impl Config for Test { type GovernanceOrigin = EnsureRoot; type CrowdSourceLiqudityMining = LiqudityMining; type WeightInfo = crate::weights::WeightInfo; + type OBWithdrawalLimit = OBWithdrawalLimit; } parameter_types! { diff --git a/pallets/ocex/src/tests.rs b/pallets/ocex/src/tests.rs index 9066368a3..33555c8c0 100644 --- a/pallets/ocex/src/tests.rs +++ b/pallets/ocex/src/tests.rs @@ -28,7 +28,7 @@ use std::str::FromStr; // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use crate::mock::*; use frame_support::traits::fungibles::Mutate as MutateAsset; -use frame_support::{testing_prelude::bounded_vec, BoundedVec}; +use frame_support::BoundedVec; use frame_system::EventRecord; use orderbook_primitives::ingress::{EgressMessages, IngressMessages}; use orderbook_primitives::ocex::AccountInfo; @@ -2036,16 +2036,10 @@ fn test_submit_snapshot() { assert_ok!(OCEX::submit_snapshot(RuntimeOrigin::none(), snapshot.clone(), Vec::new())); assert_eq!(Withdrawals::::contains_key(1), true); - assert_eq!(Withdrawals::::get(1), withdrawal_map.clone()); + assert_eq!(Withdrawals::::get(1), withdrawal_map); assert_eq!(Snapshots::::contains_key(1), true); assert_eq!(Snapshots::::get(1).unwrap(), snapshot.clone()); assert_eq!(SnapshotNonce::::get(), 1); - let onchain_events = - vec![orderbook_primitives::ocex::OnChainEvents::OrderbookWithdrawalProcessed( - 1, - snapshot.withdrawals.clone(), - )]; - assert_eq!(OnChainEvents::::get(), onchain_events); // Checking for redundant data inside snapshot assert_eq!(Snapshots::::get(1).unwrap().withdrawals, snapshot.withdrawals); }) @@ -2102,11 +2096,14 @@ fn test_withdrawal() { new_block(); new_block(); - assert_ok!(OCEX::claim_withdraw( - RuntimeOrigin::signed(account_id.clone().into()), - 1, - account_id.clone() - )); + assert_noop!( + OCEX::claim_withdraw( + RuntimeOrigin::signed(account_id.clone().into()), + 1, + account_id.clone() + ), + Error::::InvalidWithdrawalIndex + ); // Balances after withdrawal assert_eq!( ::NativeCurrency::free_balance(account_id.clone()), @@ -2116,13 +2113,6 @@ fn test_withdrawal() { ::NativeCurrency::free_balance(custodian_account.clone()), initial_balance - UNIT_BALANCE, // Dec ); - let withdrawal_claimed: orderbook_primitives::ocex::OnChainEvents = - orderbook_primitives::ocex::OnChainEvents::OrderBookWithdrawalClaimed( - 1, - account_id.clone().into(), - bounded_vec![snapshot.withdrawals[0].clone()], - ); - assert_eq!(OnChainEvents::::get()[1], withdrawal_claimed); }); } diff --git a/pallets/ocex/src/weights.rs b/pallets/ocex/src/weights.rs index d209e9ee7..6d25e7a0f 100644 --- a/pallets/ocex/src/weights.rs +++ b/pallets/ocex/src/weights.rs @@ -1,7 +1,7 @@ //! Autogenerated weights for `pallet_ocex_lmp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-03-05, STEPS: `100`, REPEAT: `200`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-03-11, STEPS: `100`, REPEAT: `200`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `ip-172-31-9-163`, CPU: `AMD EPYC 7571` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 @@ -41,15 +41,13 @@ impl crate::OcexWeightInfo for WeightInfo { /// Storage: `OCEX::IngressMessages` (r:1 w:1) /// Proof: `OCEX::IngressMessages` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `b` is `[0, 255]`. - fn register_main_account(b: u32, ) -> Weight { + fn register_main_account(_b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `167` // Estimated: `3632` - // Minimum execution time: 62_580_000 picoseconds. - Weight::from_parts(64_219_291, 0) + // Minimum execution time: 63_460_000 picoseconds. + Weight::from_parts(65_286_637, 0) .saturating_add(Weight::from_parts(0, 3632)) - // Standard Error: 51 - .saturating_add(Weight::from_parts(2_279, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -62,15 +60,13 @@ impl crate::OcexWeightInfo for WeightInfo { /// Storage: `OCEX::IngressMessages` (r:1 w:1) /// Proof: `OCEX::IngressMessages` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `x` is `[0, 255]`. - fn add_proxy_account(x: u32, ) -> Weight { + fn add_proxy_account(_x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `499` // Estimated: `3964` - // Minimum execution time: 77_011_000 picoseconds. - Weight::from_parts(79_608_430, 0) + // Minimum execution time: 78_230_000 picoseconds. + Weight::from_parts(80_411_838, 0) .saturating_add(Weight::from_parts(0, 3964)) - // Standard Error: 49 - .saturating_add(Weight::from_parts(160, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -81,13 +77,15 @@ impl crate::OcexWeightInfo for WeightInfo { /// Storage: `OCEX::IngressMessages` (r:1 w:1) /// Proof: `OCEX::IngressMessages` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `x` is `[1, 50000]`. - fn close_trading_pair(_x: u32, ) -> Weight { + fn close_trading_pair(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `359` // Estimated: `3824` - // Minimum execution time: 60_581_000 picoseconds. - Weight::from_parts(62_177_551, 0) + // Minimum execution time: 60_730_000 picoseconds. + Weight::from_parts(62_754_948, 0) .saturating_add(Weight::from_parts(0, 3824)) + // Standard Error: 0 + .saturating_add(Weight::from_parts(1, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -102,8 +100,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `359` // Estimated: `3824` - // Minimum execution time: 60_630_000 picoseconds. - Weight::from_parts(62_321_908, 0) + // Minimum execution time: 61_070_000 picoseconds. + Weight::from_parts(62_942_837, 0) .saturating_add(Weight::from_parts(0, 3824)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) @@ -121,8 +119,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `224` // Estimated: `6164` - // Minimum execution time: 72_580_000 picoseconds. - Weight::from_parts(74_688_581, 0) + // Minimum execution time: 73_301_000 picoseconds. + Weight::from_parts(75_404_320, 0) .saturating_add(Weight::from_parts(0, 6164)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) @@ -138,8 +136,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `3853` - // Minimum execution time: 68_600_000 picoseconds. - Weight::from_parts(70_833_615, 0) + // Minimum execution time: 69_190_000 picoseconds. + Weight::from_parts(71_151_733, 0) .saturating_add(Weight::from_parts(0, 3853)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) @@ -159,13 +157,15 @@ impl crate::OcexWeightInfo for WeightInfo { /// Storage: `OCEX::IngressMessages` (r:1 w:1) /// Proof: `OCEX::IngressMessages` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `x` is `[1, 255]`. - fn deposit(_x: u32, ) -> Weight { + fn deposit(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `773` // Estimated: `6232` - // Minimum execution time: 158_171_000 picoseconds. - Weight::from_parts(161_592_723, 0) + // Minimum execution time: 159_980_000 picoseconds. + Weight::from_parts(163_099_371, 0) .saturating_add(Weight::from_parts(0, 6232)) + // Standard Error: 81 + .saturating_add(Weight::from_parts(620, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -182,50 +182,44 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `462` // Estimated: `3927` - // Minimum execution time: 65_600_000 picoseconds. - Weight::from_parts(67_673_877, 0) + // Minimum execution time: 66_520_000 picoseconds. + Weight::from_parts(68_848_667, 0) .saturating_add(Weight::from_parts(0, 3927)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `OCEX::FinalizeLMPScore` (r:1 w:0) /// Proof: `OCEX::FinalizeLMPScore` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `System::Account` (r:1 w:1) + /// Storage: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `OCEX::OnChainEvents` (r:1 w:1) - /// Proof: `OCEX::OnChainEvents` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `OCEX::IngressMessages` (r:1 w:1) /// Proof: `OCEX::IngressMessages` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `OCEX::Withdrawals` (r:0 w:1) - /// Proof: `OCEX::Withdrawals` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `OCEX::Snapshots` (r:0 w:1) /// Proof: `OCEX::Snapshots` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `OCEX::SnapshotNonce` (r:0 w:1) /// Proof: `OCEX::SnapshotNonce` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn submit_snapshot() -> Weight { // Proof Size summary in bytes: - // Measured: `333` - // Estimated: `3798` - // Minimum execution time: 1_430_335_000 picoseconds. - Weight::from_parts(1_461_555_000, 0) - .saturating_add(Weight::from_parts(0, 3798)) + // Measured: `359` + // Estimated: `6196` + // Minimum execution time: 7_064_595_000 picoseconds. + Weight::from_parts(7_134_556_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(6)) + .saturating_add(T::DbWeight::get().writes(5)) } /// Storage: `OCEX::IngressMessages` (r:1 w:1) /// Proof: `OCEX::IngressMessages` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `OCEX::ExchangeState` (r:0 w:1) /// Proof: `OCEX::ExchangeState` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[0, 100000]`. - fn set_exchange_state(x: u32, ) -> Weight { + fn set_exchange_state(_x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `167` // Estimated: `3632` - // Minimum execution time: 38_190_000 picoseconds. - Weight::from_parts(39_450_923, 0) + // Minimum execution time: 39_121_000 picoseconds. + Weight::from_parts(40_594_450, 0) .saturating_add(Weight::from_parts(0, 3632)) - // Standard Error: 0 - .saturating_add(Weight::from_parts(1, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -235,20 +229,18 @@ impl crate::OcexWeightInfo for WeightInfo { /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(222), added: 2697, mode: `MaxEncodedLen`) /// Storage: `Assets::Account` (r:2 w:1) /// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(146), added: 2621, mode: `MaxEncodedLen`) - /// Storage: `OCEX::OnChainEvents` (r:1 w:1) - /// Proof: `OCEX::OnChainEvents` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[1, 255]`. fn claim_withdraw(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `763` // Estimated: `6232` - // Minimum execution time: 144_320_000 picoseconds. - Weight::from_parts(147_449_100, 0) + // Minimum execution time: 137_620_000 picoseconds. + Weight::from_parts(140_722_186, 0) .saturating_add(Weight::from_parts(0, 6232)) - // Standard Error: 77 - .saturating_add(Weight::from_parts(202, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + // Standard Error: 92 + .saturating_add(Weight::from_parts(674, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `OCEX::AllowlistedToken` (r:1 w:1) /// Proof: `OCEX::AllowlistedToken` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -257,8 +249,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `167` // Estimated: `1652` - // Minimum execution time: 33_740_000 picoseconds. - Weight::from_parts(35_028_116, 0) + // Minimum execution time: 34_680_000 picoseconds. + Weight::from_parts(36_072_035, 0) .saturating_add(Weight::from_parts(0, 1652)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -270,8 +262,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `205` // Estimated: `1690` - // Minimum execution time: 36_640_000 picoseconds. - Weight::from_parts(38_065_860, 0) + // Minimum execution time: 37_571_000 picoseconds. + Weight::from_parts(39_138_792, 0) .saturating_add(Weight::from_parts(0, 1690)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -282,8 +274,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_740_000 picoseconds. - Weight::from_parts(11_160_000, 0) + // Minimum execution time: 11_410_000 picoseconds. + Weight::from_parts(12_000_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -293,8 +285,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 24_290_000 picoseconds. - Weight::from_parts(25_000_000, 0) + // Minimum execution time: 25_220_000 picoseconds. + Weight::from_parts(26_080_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -304,7 +296,7 @@ impl crate::OcexWeightInfo for WeightInfo { /// Proof: `OCEX::LMPConfig` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `OCEX::TotalScores` (r:1 w:0) /// Proof: `OCEX::TotalScores` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `OCEX::TraderMetrics` (r:1 w:0) + /// Storage: `OCEX::TraderMetrics` (r:1 w:1) /// Proof: `OCEX::TraderMetrics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) @@ -312,11 +304,11 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1268` // Estimated: `6196` - // Minimum execution time: 197_880_000 picoseconds. - Weight::from_parts(199_690_000, 0) + // Minimum execution time: 198_370_000 picoseconds. + Weight::from_parts(200_581_000, 0) .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `OCEX::ExpectedLMPConfig` (r:1 w:1) /// Proof: `OCEX::ExpectedLMPConfig` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -328,8 +320,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `419` // Estimated: `3884` - // Minimum execution time: 49_100_000 picoseconds. - Weight::from_parts(49_951_000, 0) + // Minimum execution time: 49_430_000 picoseconds. + Weight::from_parts(50_431_000, 0) .saturating_add(Weight::from_parts(0, 3884)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) @@ -340,8 +332,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_680_000 picoseconds. - Weight::from_parts(12_120_000, 0) + // Minimum execution time: 12_300_000 picoseconds. + Weight::from_parts(12_940_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -353,8 +345,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `326` // Estimated: `3593` - // Minimum execution time: 81_830_000 picoseconds. - Weight::from_parts(83_280_000, 0) + // Minimum execution time: 82_880_000 picoseconds. + Weight::from_parts(83_970_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -377,8 +369,8 @@ impl crate::OcexWeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `948` // Estimated: `6384` - // Minimum execution time: 92_200_000 picoseconds. - Weight::from_parts(93_700_000, 0) + // Minimum execution time: 91_651_000 picoseconds. + Weight::from_parts(93_500_000, 0) .saturating_add(Weight::from_parts(0, 6384)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(2)) diff --git a/runtimes/mainnet/src/lib.rs b/runtimes/mainnet/src/lib.rs index b7d49be64..30a8ef0c1 100644 --- a/runtimes/mainnet/src/lib.rs +++ b/runtimes/mainnet/src/lib.rs @@ -1285,6 +1285,7 @@ parameter_types! { pub const OcexPalletId: PalletId = PalletId(*b"OCEX_LMP"); pub const LMPRewardsPalletId: PalletId = PalletId(*b"LMPREWAR"); pub const MsPerDay: u64 = 86_400_000; + pub const OBWithdrawalLimit: u32 = 50; } impl pallet_ocex_lmp::Config for Runtime { @@ -1298,6 +1299,7 @@ impl pallet_ocex_lmp::Config for Runtime { type AuthorityId = pallet_ocex_lmp::sr25519::AuthorityId; type GovernanceOrigin = EnsureRootOrHalfCouncil; type CrowdSourceLiqudityMining = (); + type OBWithdrawalLimit = OBWithdrawalLimit; type WeightInfo = pallet_ocex_lmp::weights::WeightInfo; }