diff --git a/state-chain/amm/src/common.rs b/state-chain/amm/src/common.rs index 25f6711f21..950c7bea46 100644 --- a/state-chain/amm/src/common.rs +++ b/state-chain/amm/src/common.rs @@ -395,7 +395,7 @@ pub(super) fn tick_at_sqrt_price(sqrt_price: SqrtPriceQ64F96) -> Tick { let (integer_log_2, mantissa) = { let mut _bits_remaining = sqrt_price_q64f128; - let mut most_signifcant_bit = 0u8; + let mut most_significant_bit = 0u8; // rustfmt chokes when formatting this macro. // See: https://github.com/rust-lang/rustfmt/issues/5404 @@ -403,7 +403,7 @@ pub(super) fn tick_at_sqrt_price(sqrt_price: SqrtPriceQ64F96) -> Tick { macro_rules! add_integer_bit { ($bit:literal, $lower_bits_mask:literal) => { if _bits_remaining > U256::from($lower_bits_mask) { - most_signifcant_bit |= $bit; + most_significant_bit |= $bit; _bits_remaining >>= $bit; } }; @@ -419,17 +419,17 @@ pub(super) fn tick_at_sqrt_price(sqrt_price: SqrtPriceQ64F96) -> Tick { add_integer_bit!(1u8, 0x1u128); ( - // most_signifcant_bit is the log2 of sqrt_price_q64f128 as an integer. This - // converts most_signifcant_bit to the integer log2 of sqrt_price_q64f128 as an + // most_significant_bit is the log2 of sqrt_price_q64f128 as an integer. This + // converts most_significant_bit to the integer log2 of sqrt_price_q64f128 as an // q64f128 - ((most_signifcant_bit as i16) + (-128i16)) as i8, + ((most_significant_bit as i16) + (-128i16)) as i8, // Calculate mantissa of sqrt_price_q64f128. - if most_signifcant_bit >= 128u8 { + if most_significant_bit >= 128u8 { // The bits we possibly drop when right shifting don't contribute to the log2 // above the 14th fractional bit. - sqrt_price_q64f128 >> (most_signifcant_bit - 127u8) + sqrt_price_q64f128 >> (most_significant_bit - 127u8) } else { - sqrt_price_q64f128 << (127u8 - most_signifcant_bit) + sqrt_price_q64f128 << (127u8 - most_significant_bit) } .as_u128(), // Conversion to u128 is safe as top 128 bits are always zero ) diff --git a/state-chain/amm/src/limit_orders.rs b/state-chain/amm/src/limit_orders.rs index 44c52da448..2f7343f140 100644 --- a/state-chain/amm/src/limit_orders.rs +++ b/state-chain/amm/src/limit_orders.rs @@ -170,14 +170,14 @@ impl FloatBetweenZeroAndOne { let (y_floor, shift_remainder) = Self::right_shift_mod(y_shifted_floor, negative_exponent); - let y_floor = y_floor.try_into().unwrap(); // Unwrap safe as numerator <= demoninator and therefore y cannot be greater than x + let y_floor = y_floor.try_into().unwrap(); // Unwrap safe as numerator <= denominator and therefore y cannot be greater than x ( y_floor, if div_remainder.is_zero() && shift_remainder.is_zero() { y_floor } else { - y_floor + 1 // Safe as for there to be a remainder y_floor must be atleast 1 less than x + y_floor + 1 // Safe as for there to be a remainder y_floor must be at least 1 less than x }, ) } @@ -349,8 +349,8 @@ pub(super) struct FixedPool { /// associated position but have some liquidity available, but this would likely be a very /// small amount. available: Amount, - /// This is the big product of all `1.0 - percent_used_by_swap` for all swaps that have occured - /// since this FixedPool instance was created and used liquidity from it. + /// This is the big product of all `1.0 - percent_used_by_swap` for all swaps that have + /// occurred since this FixedPool instance was created and used liquidity from it. percent_remaining: FloatBetweenZeroAndOne, } @@ -377,7 +377,7 @@ impl PoolState { /// /// This function never panics. pub(super) fn new(fee_hundredth_pips: u32) -> Result { - (fee_hundredth_pips <= MAX_LP_FEE) + Self::validate_fees(fee_hundredth_pips) .then_some(()) .ok_or(NewError::InvalidFeeAmount)?; @@ -556,7 +556,7 @@ impl PoolState { // bought_amount and fees than may exist in the pool position.amount - remaining_amount_ceil, // We under-estimate remaining liquidity so that lp's cannot burn more liquidity - // than truely exists in the pool + // than truly exists in the pool if remaining_amount_floor.is_zero() { None } else { @@ -742,7 +742,7 @@ impl PoolState { } /// Collects any earnings from the specified position. The SwapDirection determines which - /// direction of swaps the liquidity/position you're refering to is for. + /// direction of swaps the liquidity/position you're referring to is for. /// /// This function never panics. pub(super) fn collect( diff --git a/state-chain/amm/src/range_orders.rs b/state-chain/amm/src/range_orders.rs index 78c64c2b16..34891ca806 100644 --- a/state-chain/amm/src/range_orders.rs +++ b/state-chain/amm/src/range_orders.rs @@ -87,7 +87,7 @@ impl Position { /* Proof that `mul_div_floor` does not overflow: - Note position.liqiudity: u128 + Note position.liquidity: u128 U512::one() << 128 > u128::MAX */ mul_div_floor( @@ -148,7 +148,7 @@ pub struct PoolState { /// This is the highest tick that represents a strictly lower price than the /// current_sqrt_price. `current_tick` is the tick that when you swap ZeroToOne the /// `current_sqrt_price` is moving towards (going down in literal value), and will cross when - /// `current_sqrt_price` reachs it. `current_tick + 1` is the tick the price is moving towards + /// `current_sqrt_price` reaches it. `current_tick + 1` is the tick the price is moving towards /// (going up in literal value) when you swap OneToZero and will cross when /// `current_sqrt_price` reaches it, current_tick: Tick, @@ -646,7 +646,7 @@ impl PoolState { let (amounts_owed, current_liquidity_delta) = self.inner_liquidity_to_amounts::(burnt_liquidity, lower_tick, upper_tick); // Will not underflow as current_liquidity_delta must have previously been added to - // current_liquidity for it to need to be substrated now + // current_liquidity for it to need to be subtracted now self.current_liquidity -= current_liquidity_delta; if lower_delta.liquidity_gross == 0 && diff --git a/state-chain/pallets/cf-pools/src/benchmarking.rs b/state-chain/pallets/cf-pools/src/benchmarking.rs index 56b14cb770..ffe7592fe8 100644 --- a/state-chain/pallets/cf-pools/src/benchmarking.rs +++ b/state-chain/pallets/cf-pools/src/benchmarking.rs @@ -170,6 +170,53 @@ benchmarks! { ) verify {} + set_pool_fees { + let caller = new_lp_account::(); + assert_ok!(Pallet::::new_pool(T::EnsureGovernance::try_successful_origin().unwrap(), Asset::Eth, Asset::Usdc, 0, price_at_tick(0).unwrap())); + assert_ok!(T::LpBalance::try_credit_account( + &caller, + Asset::Eth, + 1_000_000, + )); + assert_ok!(T::LpBalance::try_credit_account( + &caller, + Asset::Usdc, + 1_000_000, + )); + assert_ok!(Pallet::::set_limit_order( + RawOrigin::Signed(caller.clone()).into(), + Asset::Usdc, + Asset::Eth, + 0, + Some(0), + 10_000, + )); + assert_ok!(Pallet::::set_limit_order( + RawOrigin::Signed(caller.clone()).into(), + Asset::Eth, + Asset::Usdc, + 1, + Some(0), + 10_000, + )); + assert_ok!(Pallet::::swap_with_network_fee(STABLE_ASSET, Asset::Eth, 1_000)); + let fee = 1_000; + let call = Call::::set_pool_fees { + base_asset: Asset::Eth, + pair_asset: Asset::Usdc, + fee_hundredth_pips: fee, + }; + }: { let _ = call.dispatch_bypass_filter(T::EnsureGovernance::try_successful_origin().unwrap()); } + verify { + assert_eq!( + Pallet::::pool_info(Asset::Eth, STABLE_ASSET), + Some(PoolInfo { + limit_order_fee_hundredth_pips: fee, + range_order_fee_hundredth_pips: fee, + }) + ); + } + impl_benchmark_test_suite!( Pallet, crate::mock::new_test_ext(), diff --git a/state-chain/pallets/cf-pools/src/lib.rs b/state-chain/pallets/cf-pools/src/lib.rs index d2aaec1b69..08b1cfe72d 100644 --- a/state-chain/pallets/cf-pools/src/lib.rs +++ b/state-chain/pallets/cf-pools/src/lib.rs @@ -294,7 +294,7 @@ pub mod pallet { /// Represents an amount of liquidity, either as an exact amount, or through maximum and minimum /// amounts of both assets. Internally those max/min are converted into exact liquidity amounts, - /// that is if the appropiate asset ratio can be achieved while maintaining the max/min bounds. + /// that is if the appropriate asset ratio can be achieved while maintaining the max/min bounds. #[derive( Copy, Clone, @@ -313,7 +313,7 @@ pub mod pallet { Liquidity { liquidity: Liquidity }, } - /// Indicates if an LP wishs to increase or decreease the size of an order. + /// Indicates if an LP wishes to increase or decrease the size of an order. #[derive( Copy, Clone, @@ -796,7 +796,7 @@ pub mod pallet { } /// Optionally move the order to a different tick and then increase or decrease its amount - /// of liquidity. The appropiate assets will be debited or credited from your balance as + /// of liquidity. The appropriate assets will be debited or credited from your balance as /// needed. If the order_id isn't being used at the moment you must specify a tick, /// otherwise it will not know what tick you want the order to be over. Note limit order /// order_id's are independent of range order order_id's. In addition to that, order_id's @@ -872,7 +872,7 @@ pub mod pallet { } /// Optionally move the order to a different tick and then set its amount of liquidity. The - /// appropiate assets will be debited or credited from your balance as needed. If the + /// appropriate assets will be debited or credited from your balance as needed. If the /// order_id isn't being used at the moment you must specify a tick, otherwise it will not /// know what tick you want the order to be over. Note limit order order_id's are /// independent of range order order_id's. In addition to that, order_id's for buy and sell @@ -934,7 +934,8 @@ pub mod pallet { }) } - /// Sets the Liquidirt Pool fees. The fee must be >= 50%. + /// Sets the Liquidity Pool fees. Also collect earned fees and bought amount for + /// all positions within the fee and accredit them to the liquidity provider. /// Requires governance origin. /// /// ## Events diff --git a/state-chain/pallets/cf-swapping/src/weights.rs b/state-chain/pallets/cf-swapping/src/weights.rs index e3a61e8c1a..2aadd306c5 100644 --- a/state-chain/pallets/cf-swapping/src/weights.rs +++ b/state-chain/pallets/cf-swapping/src/weights.rs @@ -2,9 +2,10 @@ //! Autogenerated weights for pallet_cf_swapping //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-04-21, STEPS: `20`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-09-27, STEPS: `20`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Roys-MacBook-Pro.local`, CPU: `` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: // ./target/release/chainflip-node @@ -24,9 +25,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions needed for pallet_cf_swapping. pub trait WeightInfo { @@ -43,169 +45,288 @@ pub trait WeightInfo { /// Weights for pallet_cf_swapping using the Substrate node and recommended hardware. pub struct PalletWeight(PhantomData); impl WeightInfo for PalletWeight { - // Storage: AccountRoles AccountRoles (r:1 w:0) - // Storage: EthereumIngressEgress AddressPool (r:1 w:0) - // Storage: EthereumIngressEgress ChannelIdCounter (r:1 w:1) - // Storage: Environment EthereumVaultAddress (r:1 w:0) - // Storage: Swapping SwapTTL (r:1 w:0) - // Storage: Swapping SwapChannelExpiries (r:1 w:1) - // Storage: EthereumIngressEgress ChannelActions (r:0 w:1) - // Storage: EthereumIngressEgress FetchParamDetails (r:0 w:1) - // Storage: EthereumIngressEgress AddressStatus (r:0 w:1) - // Storage: EthereumIngressEgress DepositAddressDetailsLookup (r:0 w:1) + /// Storage: `Environment::RuntimeSafeMode` (r:1 w:0) + /// Proof: `Environment::RuntimeSafeMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AccountRoles::AccountRoles` (r:1 w:0) + /// Proof: `AccountRoles::AccountRoles` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) + /// Storage: `Swapping::SwapTTL` (r:1 w:0) + /// Proof: `Swapping::SwapTTL` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::DepositChannelPool` (r:1 w:0) + /// Proof: `EthereumIngressEgress::DepositChannelPool` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::ChannelIdCounter` (r:1 w:1) + /// Proof: `EthereumIngressEgress::ChannelIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Environment::EthereumVaultAddress` (r:1 w:0) + /// Proof: `Environment::EthereumVaultAddress` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `EthereumChainTracking::CurrentChainState` (r:1 w:0) + /// Proof: `EthereumChainTracking::CurrentChainState` (`max_values`: Some(1), `max_size`: Some(40), added: 535, mode: `MaxEncodedLen`) + /// Storage: `Swapping::SwapChannelExpiries` (r:1 w:1) + /// Proof: `Swapping::SwapChannelExpiries` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::ChannelActions` (r:0 w:1) + /// Proof: `EthereumIngressEgress::ChannelActions` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::DepositChannelLookup` (r:0 w:1) + /// Proof: `EthereumIngressEgress::DepositChannelLookup` (`max_values`: None, `max_size`: None, mode: `Measured`) fn request_swap_deposit_address() -> Weight { - // Minimum execution time: 53_000 nanoseconds. - Weight::from_parts(55_000_000, 0) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `1031` + // Estimated: `4496` + // Minimum execution time: 47_000_000 picoseconds. + Weight::from_parts(48_000_000, 4496) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - - - // Storage: Environment CurrentSystemState (r:1 w:0) - // Storage: AccountRoles AccountRoles (r:1 w:0) - // Storage: Swapping EarnedBrokerFees (r:1 w:1) - // Storage: EthereumIngressEgress EgressIdCounter (r:1 w:1) - // Storage: EthereumIngressEgress ScheduledEgressFetchOrTransfer (r:1 w:1) + /// Storage: `Environment::RuntimeSafeMode` (r:1 w:0) + /// Proof: `Environment::RuntimeSafeMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AccountRoles::AccountRoles` (r:1 w:0) + /// Proof: `AccountRoles::AccountRoles` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) + /// Storage: `Swapping::EarnedBrokerFees` (r:1 w:1) + /// Proof: `Swapping::EarnedBrokerFees` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::EgressIdCounter` (r:1 w:1) + /// Proof: `EthereumIngressEgress::EgressIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::ScheduledEgressFetchOrTransfer` (r:1 w:1) + /// Proof: `EthereumIngressEgress::ScheduledEgressFetchOrTransfer` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn withdraw() -> Weight { - // Minimum execution time: 41_000 nanoseconds. - Weight::from_parts(42_000_000, 0) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `904` + // Estimated: `4369` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(34_000_000, 4369) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Swapping SwapIdCounter (r:1 w:1) - // Storage: Swapping SwapQueue (r:1 w:1) + /// Storage: `Environment::RuntimeSafeMode` (r:1 w:0) + /// Proof: `Environment::RuntimeSafeMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AccountRoles::SwappingEnabled` (r:1 w:0) + /// Proof: `AccountRoles::SwappingEnabled` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `AccountRoles::AccountRoles` (r:1 w:1) + /// Proof: `AccountRoles::AccountRoles` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) + fn register_as_broker() -> Weight { + // Proof Size summary in bytes: + // Measured: `680` + // Estimated: `3498` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 3498) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `Swapping::MinimumSwapAmount` (r:1 w:0) + /// Proof: `Swapping::MinimumSwapAmount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::SwapIdCounter` (r:1 w:1) + /// Proof: `Swapping::SwapIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::SwapQueue` (r:1 w:1) + /// Proof: `Swapping::SwapQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn schedule_swap_from_contract() -> Weight { - // Minimum execution time: 19_000 nanoseconds. - Weight::from_parts(20_000_000, 0) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Swapping CcmIdCounter (r:1 w:1) - // Storage: Swapping SwapIdCounter (r:1 w:1) - // Storage: Swapping SwapQueue (r:1 w:1) - // Storage: Swapping CcmOutputs (r:0 w:1) - // Storage: Swapping PendingCcms (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `208` + // Estimated: `3673` + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(18_000_000, 3673) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `Swapping::MinimumSwapAmount` (r:1 w:0) + /// Proof: `Swapping::MinimumSwapAmount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::CcmIdCounter` (r:1 w:1) + /// Proof: `Swapping::CcmIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::SwapIdCounter` (r:1 w:1) + /// Proof: `Swapping::SwapIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::SwapQueue` (r:1 w:1) + /// Proof: `Swapping::SwapQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::CcmOutputs` (r:0 w:1) + /// Proof: `Swapping::CcmOutputs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::PendingCcms` (r:0 w:1) + /// Proof: `Swapping::PendingCcms` (`max_values`: None, `max_size`: None, mode: `Measured`) fn ccm_deposit() -> Weight { - // Minimum execution time: 27_000 nanoseconds. - Weight::from_parts(28_000_000, 0) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(5)) - } - // Storage: Swapping SwapChannelExpiries (r:1 w:1) - // Storage: EthereumIngressEgress AddressStatus (r:1 w:0) - // Storage: EthereumIngressEgress DepositAddressDetailsLookup (r:1 w:1) - // Storage: EthereumIngressEgress ChannelActions (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `208` + // Estimated: `3673` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(34_000_000, 3673) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: `Swapping::SwapChannelExpiries` (r:1 w:1) + /// Proof: `Swapping::SwapChannelExpiries` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::DepositChannelLookup` (r:100 w:0) + /// Proof: `EthereumIngressEgress::DepositChannelLookup` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::ChannelActions` (r:0 w:100) + /// Proof: `EthereumIngressEgress::ChannelActions` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `a` is `[1, 100]`. fn on_initialize(a: u32, ) -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_parts(19_428_056, 0) - // Standard Error: 30_404 - .saturating_add(Weight::from_parts(14_647_491, 0).saturating_mul(a.into())) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) - .saturating_add(T::DbWeight::get().writes(1)) - .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) - } - // Storage: Swapping SwapTTL (r:0 w:1) - fn set_swap_ttl() -> Weight { - // Minimum execution time: 13_000 nanoseconds. - Weight::from_parts(14_000_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `241 + a * (105 ±0)` + // Estimated: `3706 + a * (2581 ±0)` + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(14_763_475, 3706) + // Standard Error: 11_169 + .saturating_add(Weight::from_parts(8_725_405, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 2581).saturating_mul(a.into())) } - // Storage: AccountRoles SwappingEnabled (r:1 w:0) - // Storage: AccountRoles AccountRoles (r:1 w:1) - fn register_as_broker() -> Weight { - // Minimum execution time: 20_000 nanoseconds. - Weight::from_parts(22_000_000, 0) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + /// Storage: `Swapping::SwapTTL` (r:0 w:1) + /// Proof: `Swapping::SwapTTL` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn set_swap_ttl() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(8_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - + /// Storage: `Swapping::MinimumSwapAmount` (r:0 w:1) + /// Proof: `Swapping::MinimumSwapAmount` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_minimum_swap_amount() -> Weight { - Weight::from_parts(1_000_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(9_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: AccountRoles AccountRoles (r:1 w:0) - // Storage: EthereumIngressEgress AddressPool (r:1 w:0) - // Storage: EthereumIngressEgress ChannelIdCounter (r:1 w:1) - // Storage: Environment EthereumVaultAddress (r:1 w:0) - // Storage: Swapping SwapTTL (r:1 w:0) - // Storage: Swapping SwapChannelExpiries (r:1 w:1) - // Storage: EthereumIngressEgress ChannelActions (r:0 w:1) - // Storage: EthereumIngressEgress FetchParamDetails (r:0 w:1) - // Storage: EthereumIngressEgress AddressStatus (r:0 w:1) - // Storage: EthereumIngressEgress DepositAddressDetailsLookup (r:0 w:1) + /// Storage: `Environment::RuntimeSafeMode` (r:1 w:0) + /// Proof: `Environment::RuntimeSafeMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AccountRoles::AccountRoles` (r:1 w:0) + /// Proof: `AccountRoles::AccountRoles` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) + /// Storage: `Swapping::SwapTTL` (r:1 w:0) + /// Proof: `Swapping::SwapTTL` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::DepositChannelPool` (r:1 w:0) + /// Proof: `EthereumIngressEgress::DepositChannelPool` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::ChannelIdCounter` (r:1 w:1) + /// Proof: `EthereumIngressEgress::ChannelIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Environment::EthereumVaultAddress` (r:1 w:0) + /// Proof: `Environment::EthereumVaultAddress` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `EthereumChainTracking::CurrentChainState` (r:1 w:0) + /// Proof: `EthereumChainTracking::CurrentChainState` (`max_values`: Some(1), `max_size`: Some(40), added: 535, mode: `MaxEncodedLen`) + /// Storage: `Swapping::SwapChannelExpiries` (r:1 w:1) + /// Proof: `Swapping::SwapChannelExpiries` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::ChannelActions` (r:0 w:1) + /// Proof: `EthereumIngressEgress::ChannelActions` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::DepositChannelLookup` (r:0 w:1) + /// Proof: `EthereumIngressEgress::DepositChannelLookup` (`max_values`: None, `max_size`: None, mode: `Measured`) fn request_swap_deposit_address() -> Weight { - // Minimum execution time: 53_000 nanoseconds. - Weight::from_parts(55_000_000, 0) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `1031` + // Estimated: `4496` + // Minimum execution time: 47_000_000 picoseconds. + Weight::from_parts(48_000_000, 4496) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - - - // Storage: Environment CurrentSystemState (r:1 w:0) - // Storage: AccountRoles AccountRoles (r:1 w:0) - // Storage: Swapping EarnedBrokerFees (r:1 w:1) - // Storage: EthereumIngressEgress EgressIdCounter (r:1 w:1) - // Storage: EthereumIngressEgress ScheduledEgressFetchOrTransfer (r:1 w:1) + /// Storage: `Environment::RuntimeSafeMode` (r:1 w:0) + /// Proof: `Environment::RuntimeSafeMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AccountRoles::AccountRoles` (r:1 w:0) + /// Proof: `AccountRoles::AccountRoles` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) + /// Storage: `Swapping::EarnedBrokerFees` (r:1 w:1) + /// Proof: `Swapping::EarnedBrokerFees` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::EgressIdCounter` (r:1 w:1) + /// Proof: `EthereumIngressEgress::EgressIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::ScheduledEgressFetchOrTransfer` (r:1 w:1) + /// Proof: `EthereumIngressEgress::ScheduledEgressFetchOrTransfer` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn withdraw() -> Weight { - // Minimum execution time: 41_000 nanoseconds. - Weight::from_parts(42_000_000, 0) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `904` + // Estimated: `4369` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(34_000_000, 4369) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Swapping SwapIdCounter (r:1 w:1) - // Storage: Swapping SwapQueue (r:1 w:1) + /// Storage: `Environment::RuntimeSafeMode` (r:1 w:0) + /// Proof: `Environment::RuntimeSafeMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AccountRoles::SwappingEnabled` (r:1 w:0) + /// Proof: `AccountRoles::SwappingEnabled` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `AccountRoles::AccountRoles` (r:1 w:1) + /// Proof: `AccountRoles::AccountRoles` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) + fn register_as_broker() -> Weight { + // Proof Size summary in bytes: + // Measured: `680` + // Estimated: `3498` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 3498) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `Swapping::MinimumSwapAmount` (r:1 w:0) + /// Proof: `Swapping::MinimumSwapAmount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::SwapIdCounter` (r:1 w:1) + /// Proof: `Swapping::SwapIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::SwapQueue` (r:1 w:1) + /// Proof: `Swapping::SwapQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn schedule_swap_from_contract() -> Weight { - // Minimum execution time: 19_000 nanoseconds. - Weight::from_parts(20_000_000, 0) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Swapping CcmIdCounter (r:1 w:1) - // Storage: Swapping SwapIdCounter (r:1 w:1) - // Storage: Swapping SwapQueue (r:1 w:1) - // Storage: Swapping CcmOutputs (r:0 w:1) - // Storage: Swapping PendingCcms (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `208` + // Estimated: `3673` + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(18_000_000, 3673) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `Swapping::MinimumSwapAmount` (r:1 w:0) + /// Proof: `Swapping::MinimumSwapAmount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::CcmIdCounter` (r:1 w:1) + /// Proof: `Swapping::CcmIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::SwapIdCounter` (r:1 w:1) + /// Proof: `Swapping::SwapIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::SwapQueue` (r:1 w:1) + /// Proof: `Swapping::SwapQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::CcmOutputs` (r:0 w:1) + /// Proof: `Swapping::CcmOutputs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Swapping::PendingCcms` (r:0 w:1) + /// Proof: `Swapping::PendingCcms` (`max_values`: None, `max_size`: None, mode: `Measured`) fn ccm_deposit() -> Weight { - // Minimum execution time: 27_000 nanoseconds. - Weight::from_parts(28_000_000, 0) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(5)) - } - // Storage: Swapping SwapChannelExpiries (r:1 w:1) - // Storage: EthereumIngressEgress AddressStatus (r:1 w:0) - // Storage: EthereumIngressEgress DepositAddressDetailsLookup (r:1 w:1) - // Storage: EthereumIngressEgress ChannelActions (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `208` + // Estimated: `3673` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(34_000_000, 3673) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `Swapping::SwapChannelExpiries` (r:1 w:1) + /// Proof: `Swapping::SwapChannelExpiries` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::DepositChannelLookup` (r:100 w:0) + /// Proof: `EthereumIngressEgress::DepositChannelLookup` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `EthereumIngressEgress::ChannelActions` (r:0 w:100) + /// Proof: `EthereumIngressEgress::ChannelActions` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `a` is `[1, 100]`. fn on_initialize(a: u32, ) -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_parts(19_428_056, 0) - // Standard Error: 30_404 - .saturating_add(Weight::from_parts(14_647_491, 0).saturating_mul(a.into())) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(a.into()))) - .saturating_add(RocksDbWeight::get().writes(1)) - .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(a.into()))) - } - // Storage: Swapping SwapTTL (r:0 w:1) - fn set_swap_ttl() -> Weight { - // Minimum execution time: 13_000 nanoseconds. - Weight::from_parts(14_000_000, 0) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `241 + a * (105 ±0)` + // Estimated: `3706 + a * (2581 ±0)` + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(14_763_475, 3706) + // Standard Error: 11_169 + .saturating_add(Weight::from_parts(8_725_405, 0).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 2581).saturating_mul(a.into())) } - // Storage: AccountRoles SwappingEnabled (r:1 w:0) - // Storage: AccountRoles AccountRoles (r:1 w:1) - fn register_as_broker() -> Weight { - // Minimum execution time: 20_000 nanoseconds. - Weight::from_parts(22_000_000, 0) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) + /// Storage: `Swapping::SwapTTL` (r:0 w:1) + /// Proof: `Swapping::SwapTTL` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn set_swap_ttl() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(8_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } + /// Storage: `Swapping::MinimumSwapAmount` (r:0 w:1) + /// Proof: `Swapping::MinimumSwapAmount` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_minimum_swap_amount() -> Weight { - Weight::from_parts(1_000_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(9_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } }