From 6b808da85ad7af9e48d01b05c5da43539b0c4739 Mon Sep 17 00:00:00 2001 From: Francisco Valentim Castilho Date: Thu, 23 May 2024 23:22:46 -0300 Subject: [PATCH 1/7] Fix: Benchmarks --- INV4/pallet-inv4/Cargo.toml | 5 +- INV4/pallet-inv4/src/benchmarking.rs | 69 ++++++++++++------------- OCIF/staking/Cargo.toml | 5 ++ OCIF/staking/src/benchmarking.rs | 75 ++++++++++++---------------- pallet-checked-inflation/Cargo.toml | 6 ++- pallet-rings/Cargo.toml | 3 ++ pallet-rings/src/benchmarking.rs | 9 ++-- 7 files changed, 83 insertions(+), 89 deletions(-) diff --git a/INV4/pallet-inv4/Cargo.toml b/INV4/pallet-inv4/Cargo.toml index 20e7ff20..0ac6d557 100644 --- a/INV4/pallet-inv4/Cargo.toml +++ b/INV4/pallet-inv4/Cargo.toml @@ -10,8 +10,9 @@ version = '0.1.0-dev' [dependencies] serde = { workspace = true, optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ - "derive", "max-encoded-len" +codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = [ + "derive", + "max-encoded-len", ] } sp-runtime = { workspace = true, default-features = false } sp-arithmetic = { workspace = true, default-features = false } diff --git a/INV4/pallet-inv4/src/benchmarking.rs b/INV4/pallet-inv4/src/benchmarking.rs index 53da3019..2e0bb5db 100644 --- a/INV4/pallet-inv4/src/benchmarking.rs +++ b/INV4/pallet-inv4/src/benchmarking.rs @@ -5,7 +5,6 @@ use crate::{ fee_handling::FeeAsset, multisig::MAX_SIZE, origin::{INV4Origin, MultisigInternalOrigin}, - util::derive_core_account, voting::{Tally, Vote}, BalanceOf, }; @@ -38,18 +37,21 @@ fn perbill_one() -> Perbill { Perbill::one() } -fn derive_account(core_id: T::CoreId) -> T::AccountId { - derive_core_account::(core_id) +fn derive_account(core_id: T::CoreId) -> T::AccountId +where + T: Config, + T::AccountId: From<[u8; 32]>, +{ + INV4::::derive_core_account(core_id) } fn mock_core() -> DispatchResultWithPostInfo where - Result< - INV4Origin::CoreId, ::AccountId>, - ::RuntimeOrigin, - >: From<::RuntimeOrigin>, + Result, ::RuntimeOrigin>: + From<::RuntimeOrigin>, <::Currency as Currency<::AccountId>>::Balance: Sum, + T::AccountId: From<[u8; 32]>, { T::Currency::make_free_balance_be( &whitelisted_caller(), @@ -61,20 +63,18 @@ where vec![].try_into().unwrap(), perbill_one(), perbill_one(), - FeeAsset::TNKR, + FeeAsset::Native, ) } fn mock_mint() -> Result<(), DispatchError> where - Result< - INV4Origin::CoreId, ::AccountId>, - ::RuntimeOrigin, - >: From<::RuntimeOrigin>, + Result, ::RuntimeOrigin>: + From<::RuntimeOrigin>, <::Currency as Currency<::AccountId>>::Balance: Sum, - ::RuntimeOrigin: - From::CoreId, ::AccountId>>, + ::RuntimeOrigin: From>, + T::AccountId: From<[u8; 32]>, { INV4::::token_mint( INV4Origin::Multisig(MultisigInternalOrigin::new(0u32.into())).into(), @@ -85,14 +85,12 @@ where fn mock_mint_2() -> Result<(), DispatchError> where - Result< - INV4Origin::CoreId, ::AccountId>, - ::RuntimeOrigin, - >: From<::RuntimeOrigin>, + Result, ::RuntimeOrigin>: + From<::RuntimeOrigin>, <::Currency as Currency<::AccountId>>::Balance: Sum, - ::RuntimeOrigin: - From::CoreId, ::AccountId>>, + ::RuntimeOrigin: From>, + T::AccountId: From<[u8; 32]>, { INV4::::token_mint( INV4Origin::Multisig(MultisigInternalOrigin::new(0u32.into())).into(), @@ -103,34 +101,30 @@ where fn mock_call() -> Result> where - Result< - INV4Origin::CoreId, ::AccountId>, - ::RuntimeOrigin, - >: From<::RuntimeOrigin>, + Result, ::RuntimeOrigin>: + From<::RuntimeOrigin>, <::Currency as Currency<::AccountId>>::Balance: Sum, - ::RuntimeOrigin: - From::CoreId, ::AccountId>>, + ::RuntimeOrigin: From>, + T::AccountId: From<[u8; 32]>, { INV4::::operate_multisig( SystemOrigin::Signed(whitelisted_caller()).into(), 0u32.into(), None, - FeeAsset::TNKR, + FeeAsset::Native, Box::new(frame_system::Call::::remark { remark: vec![0] }.into()), ) } fn mock_vote() -> Result> where - Result< - INV4Origin::CoreId, ::AccountId>, - ::RuntimeOrigin, - >: From<::RuntimeOrigin>, + Result, ::RuntimeOrigin>: + From<::RuntimeOrigin>, <::Currency as Currency<::AccountId>>::Balance: Sum, - ::RuntimeOrigin: - From::CoreId, ::AccountId>>, + ::RuntimeOrigin: From>, + T::AccountId: From<[u8; 32]>, { let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![0] }.into(); @@ -149,11 +143,12 @@ benchmarks! { where_clause { where Result< - INV4Origin::CoreId, ::AccountId>, + INV4Origin, ::RuntimeOrigin, >: From<::RuntimeOrigin>, <::Currency as Currency<::AccountId>>::Balance: Sum, - ::RuntimeOrigin: From::CoreId, ::AccountId>>, + ::RuntimeOrigin: From>, + T::AccountId: From<[u8; 32]>, } create_core { @@ -163,7 +158,7 @@ benchmarks! { let caller = whitelisted_caller(); let minimum_support = perbill_one(); let required_approval = perbill_one(); - let creation_fee_asset = FeeAsset::TNKR; + let creation_fee_asset = FeeAsset::Native; T::Currency::make_free_balance_be(&caller, T::CoreCreationFee::get() + T::CoreCreationFee::get()); }: _(SystemOrigin::Signed(caller.clone()), metadata.clone(), minimum_support, required_approval, creation_fee_asset) @@ -244,7 +239,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let core_id: T::CoreId = 0u32.into(); let call_hash = <::Hashing as Hash>::hash_of(&call.clone()); - let fee_asset = FeeAsset::TNKR; + let fee_asset = FeeAsset::Native; }: _(SystemOrigin::Signed(caller.clone()), core_id, Some(metadata), fee_asset, Box::new(call.clone())) verify { diff --git a/OCIF/staking/Cargo.toml b/OCIF/staking/Cargo.toml index ea865a42..0deea8b1 100644 --- a/OCIF/staking/Cargo.toml +++ b/OCIF/staking/Cargo.toml @@ -52,9 +52,12 @@ std = [ "sp-std/std", "frame-support/std", "frame-system/std", + "frame-benchmarking?/std", + "xcm/std", "pallet-balances/std", "pallet-session/std", "pallet-timestamp/std", + "pallet-inv4/std", "sp-staking/std", "orml-traits/std", "orml-tokens/std", @@ -63,5 +66,7 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "frame-system/runtime-benchmarks", + "pallet-inv4/runtime-benchmarks", + ] try-runtime = ["frame-support/try-runtime"] diff --git a/OCIF/staking/src/benchmarking.rs b/OCIF/staking/src/benchmarking.rs index a3a4eafc..21fffc2f 100644 --- a/OCIF/staking/src/benchmarking.rs +++ b/OCIF/staking/src/benchmarking.rs @@ -10,8 +10,8 @@ use frame_support::{ }; use frame_system::{Pallet as System, RawOrigin}; use pallet_inv4::{ + account_derivation::CoreAccountDerivation, origin::{INV4Origin, MultisigInternalOrigin}, - util::derive_core_account, }; use sp_runtime::traits::{Bounded, One}; use sp_std::vec; @@ -20,19 +20,19 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } -fn derive_account( - core_id: ::CoreId, -) -> T::AccountId { - derive_core_account::::CoreId, T::AccountId>(core_id) +fn derive_account(core_id: ::CoreId) -> T::AccountId +where + T: pallet_inv4::Config, + T::AccountId: From<[u8; 32]>, +{ + as CoreAccountDerivation>::derive_core_account(core_id) } fn advance_to_era(n: Era) { while OcifStaking::::current_era() < n { - as OnFinalize<::BlockNumber>>::on_finalize( - System::::block_number(), - ); + as OnFinalize>>::on_finalize(System::::block_number()); System::::set_block_number(System::::block_number() + One::one()); - as OnInitialize<::BlockNumber>>::on_initialize( + as OnInitialize>>::on_initialize( System::::block_number(), ); } @@ -40,12 +40,10 @@ fn advance_to_era(n: Era) { fn mock_register() -> DispatchResultWithPostInfo where - Result< - INV4Origin::CoreId, ::AccountId>, - ::RuntimeOrigin, - >: From<::RuntimeOrigin>, - ::RuntimeOrigin: - From::CoreId, ::AccountId>>, + Result, ::RuntimeOrigin>: + From<::RuntimeOrigin>, + ::RuntimeOrigin: From>, + T::AccountId: From<[u8; 32]>, { ::Currency::make_free_balance_be( &derive_account::(0u32.into()), @@ -62,12 +60,10 @@ where fn mock_register_2() -> DispatchResultWithPostInfo where - Result< - INV4Origin::CoreId, ::AccountId>, - ::RuntimeOrigin, - >: From<::RuntimeOrigin>, - ::RuntimeOrigin: - From::CoreId, ::AccountId>>, + Result, ::RuntimeOrigin>: + From<::RuntimeOrigin>, + ::RuntimeOrigin: From>, + T::AccountId: From<[u8; 32]>, { ::Currency::make_free_balance_be( &derive_account::(1u32.into()), @@ -84,16 +80,14 @@ where fn mock_stake() -> DispatchResultWithPostInfo where - Result< - INV4Origin::CoreId, ::AccountId>, - ::RuntimeOrigin, - >: From<::RuntimeOrigin>, - ::RuntimeOrigin: - From::CoreId, ::AccountId>>, + Result, ::RuntimeOrigin>: + From<::RuntimeOrigin>, + ::RuntimeOrigin: From>, + T::AccountId: From<[u8; 32]>, { ::Currency::make_free_balance_be( &whitelisted_caller(), - BalanceOf::::max_value(), + pallet::BalanceOf::::max_value(), ); OcifStaking::::stake( @@ -105,12 +99,10 @@ where fn mock_unstake() -> DispatchResultWithPostInfo where - Result< - INV4Origin::CoreId, ::AccountId>, - ::RuntimeOrigin, - >: From<::RuntimeOrigin>, - ::RuntimeOrigin: - From::CoreId, ::AccountId>>, + Result, ::RuntimeOrigin>: + From<::RuntimeOrigin>, + ::RuntimeOrigin: From>, + T::AccountId: From<[u8; 32]>, { OcifStaking::::unstake( RawOrigin::Signed(whitelisted_caller()).into(), @@ -123,14 +115,11 @@ benchmarks! { where_clause { where Result< - INV4Origin< - T, - ::CoreId, - ::AccountId, - >, + INV4Origin, ::RuntimeOrigin, >: From<::RuntimeOrigin>, - ::RuntimeOrigin: From::CoreId, ::AccountId>>, + ::RuntimeOrigin: From>, + T::AccountId: From<[u8; 32]>, } @@ -195,7 +184,7 @@ benchmarks! { let staker = whitelisted_caller(); let amount = T::StakeThresholdForActiveCore::get() + T::StakeThresholdForActiveCore::get(); - ::Currency::make_free_balance_be(&staker, BalanceOf::::max_value()); + ::Currency::make_free_balance_be(&staker, pallet::BalanceOf::::max_value()); }: _(RawOrigin::Signed(staker.clone()), 0u32.into(), amount) verify { assert_last_event::(Event::::Staked { @@ -246,7 +235,7 @@ benchmarks! { let staker: T::AccountId = whitelisted_caller(); let amount = T::StakeThresholdForActiveCore::get() + T::StakeThresholdForActiveCore::get(); - let core_stake_info = OcifStaking::::core_stake_info::<::CoreId, Era>(0u32.into(), 0u32).unwrap(); + let core_stake_info = OcifStaking::::core_stake_info::<::CoreId, Era>(0u32.into(), 0u32).unwrap(); let era_info = OcifStaking::::general_era_info::(0u32).unwrap(); let (_, reward) = OcifStaking::::core_stakers_split(&core_stake_info, &era_info); @@ -269,7 +258,7 @@ benchmarks! { let staker: T::AccountId = whitelisted_caller(); let amount = T::StakeThresholdForActiveCore::get() + T::StakeThresholdForActiveCore::get(); - let core_stake_info = OcifStaking::::core_stake_info::<::CoreId, Era>(0u32.into(), 0u32).unwrap(); + let core_stake_info = OcifStaking::::core_stake_info::<::CoreId, Era>(0u32.into(), 0u32).unwrap(); let era_info = OcifStaking::::general_era_info::(0u32).unwrap(); let (reward, _) = OcifStaking::::core_stakers_split(&core_stake_info, &era_info); diff --git a/pallet-checked-inflation/Cargo.toml b/pallet-checked-inflation/Cargo.toml index b4eaca0c..495ff357 100644 --- a/pallet-checked-inflation/Cargo.toml +++ b/pallet-checked-inflation/Cargo.toml @@ -46,13 +46,15 @@ std = [ "sp-std/std", "frame-support/std", "frame-system/std", + "frame-benchmarking?/std", "pallet-session/std", "sp-staking/std", - "pallet-balances/std", + "pallet-balances/std", + ] -try-runtime = ["frame-support/try-runtime"] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "frame-system/runtime-benchmarks", ] +try-runtime = ["frame-support/try-runtime"] diff --git a/pallet-rings/Cargo.toml b/pallet-rings/Cargo.toml index fe031647..572f654d 100644 --- a/pallet-rings/Cargo.toml +++ b/pallet-rings/Cargo.toml @@ -79,5 +79,8 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "frame-system/runtime-benchmarks", + "pallet-inv4/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallet-rings/src/benchmarking.rs b/pallet-rings/src/benchmarking.rs index 3aed5000..540c0a57 100644 --- a/pallet-rings/src/benchmarking.rs +++ b/pallet-rings/src/benchmarking.rs @@ -16,10 +16,7 @@ benchmarks! { where Result< INV4Origin< - T, - ::CoreId, - ::AccountId, - >, + T>, ::RuntimeOrigin, >: From<::RuntimeOrigin>, @@ -28,7 +25,9 @@ benchmarks! { [u8; 32]: From<::AccountId>, ::RuntimeOrigin: - From::CoreId, ::AccountId>>, + From>, + + T::AccountId: From<[u8; 32]>, } set_maintenance_status { From 317329355250f6aca1c2344d9959e58d7c544871 Mon Sep 17 00:00:00 2001 From: Francisco Valentim Castilho Date: Mon, 27 May 2024 12:30:47 -0300 Subject: [PATCH 2/7] Fix: cargo features + new weights --- INV4/pallet-inv4/src/weights.rs | 621 ++++++++-------- OCIF/staking/src/weights.rs | 897 ++++++++++++------------ pallet-checked-inflation/src/lib.rs | 8 +- pallet-checked-inflation/src/weights.rs | 137 ++-- pallet-rings/Cargo.toml | 1 + pallet-rings/src/benchmarking.rs | 7 +- 6 files changed, 847 insertions(+), 824 deletions(-) diff --git a/INV4/pallet-inv4/src/weights.rs b/INV4/pallet-inv4/src/weights.rs index 4f82a055..d58ce1c5 100644 --- a/INV4/pallet-inv4/src/weights.rs +++ b/INV4/pallet-inv4/src/weights.rs @@ -2,26 +2,25 @@ //! Autogenerated weights for `pallet_inv4` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-05-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Gabriels-MacBook-Pro-3.local`, CPU: `` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! HOSTNAME: `anny.local`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: - // ./target/release/tinkernet-collator - // benchmark - // pallet - // --chain=dev - // --execution=wasm - // --wasm-execution=compiled - // --pallet=pallet_inv4 - // --extrinsic=* - // --steps - // 50 - // --repeat - // 20 - // --output=../../InvArch-Frames/INV4/pallet-inv4/src/weights.rs - // --template=../weights-template.hbs +// ./target/release/tinkernet-collator +// benchmark +// pallet +// --chain=dev +// --wasm-execution=compiled +// --pallet=pallet_inv4 +// --extrinsic=* +// --steps +// 50 +// --repeat +// 20 +// --output=../../InvArch-Frames/INV4/pallet-inv4/src/weights.rs +// --template=../weights-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -33,291 +32,307 @@ use core::marker::PhantomData; /// Weight functions needed for `pallet_inv4`. pub trait WeightInfo { - fn create_core(m: u32, ) -> Weight; - fn set_parameters(m: u32, ) -> Weight; - fn token_mint() -> Weight; - fn token_burn() -> Weight; - fn operate_multisig(m: u32, z: u32, ) -> Weight; - fn vote_multisig() -> Weight; - fn withdraw_vote_multisig() -> Weight; - fn cancel_multisig_proposal() -> Weight; - } + fn create_core(m: u32, ) -> Weight; + fn set_parameters(m: u32, ) -> Weight; + fn token_mint() -> Weight; + fn token_burn() -> Weight; + fn operate_multisig(m: u32, z: u32, ) -> Weight; + fn vote_multisig() -> Weight; + fn withdraw_vote_multisig() -> Weight; + fn cancel_multisig_proposal() -> Weight; +} - /// Weights for `pallet_inv4` using the Substrate node and recommended hardware. - pub struct SubstrateWeight(PhantomData); - impl WeightInfo for SubstrateWeight { - /// Storage: INV4 NextCoreId (r:1 w:1) - /// Proof: INV4 NextCoreId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: CoreAssets Accounts (r:1 w:1) - /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: CoreAssets TotalIssuance (r:1 w:1) - /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: INV4 CoreByAccount (r:0 w:1) - /// Proof: INV4 CoreByAccount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) - /// Storage: INV4 CoreStorage (r:0 w:1) - /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) - /// Storage: INV4 CoreMembers (r:0 w:1) - /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) - /// The range of component `m` is `[0, 10000]`. - fn create_core(m: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `273` - // Estimated: `6196` - // Minimum execution time: 84_000_000 picoseconds. - Weight::from_parts(85_462_672, 6196) - // Standard Error: 16 - .saturating_add(Weight::from_parts(781, 0).saturating_mul(m.into())) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) - } - /// Storage: INV4 CoreStorage (r:1 w:1) - /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) - /// The range of component `m` is `[0, 10000]`. - fn set_parameters(m: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `234` - // Estimated: `13528` - // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(12_279_117, 13528) - // Standard Error: 6 - .saturating_add(Weight::from_parts(717, 0).saturating_mul(m.into())) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: CoreAssets Accounts (r:1 w:1) - /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: CoreAssets TotalIssuance (r:1 w:1) - /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: INV4 CoreMembers (r:0 w:1) - /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) - fn token_mint() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `3593` - // Minimum execution time: 34_000_000 picoseconds. - Weight::from_parts(35_000_000, 3593) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: CoreAssets Accounts (r:1 w:1) - /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: CoreAssets TotalIssuance (r:1 w:1) - /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: INV4 CoreMembers (r:0 w:1) - /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) - fn token_burn() -> Weight { - // Proof Size summary in bytes: - // Measured: `438` - // Estimated: `3593` - // Minimum execution time: 36_000_000 picoseconds. - Weight::from_parts(37_000_000, 3593) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: CoreAssets Accounts (r:1 w:0) - /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: INV4 CoreStorage (r:1 w:0) - /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) - /// Storage: CoreAssets TotalIssuance (r:1 w:0) - /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - /// Storage: INV4 Multisig (r:1 w:1) - /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) - /// The range of component `m` is `[0, 10000]`. - /// The range of component `z` is `[0, 51190]`. - fn operate_multisig(m: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `498` - // Estimated: `554807` - // Minimum execution time: 29_000_000 picoseconds. - Weight::from_parts(25_808_010, 554807) - // Standard Error: 21 - .saturating_add(Weight::from_parts(313, 0).saturating_mul(m.into())) - // Standard Error: 4 - .saturating_add(Weight::from_parts(1_643, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: INV4 Multisig (r:1 w:1) - /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) - /// Storage: CoreAssets Accounts (r:1 w:0) - /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: INV4 CoreStorage (r:1 w:0) - /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) - /// Storage: CoreAssets TotalIssuance (r:1 w:0) - /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - fn vote_multisig() -> Weight { - // Proof Size summary in bytes: - // Measured: `749` - // Estimated: `554807` - // Minimum execution time: 27_000_000 picoseconds. - Weight::from_parts(28_000_000, 554807) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: INV4 Multisig (r:1 w:1) - /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) - fn withdraw_vote_multisig() -> Weight { - // Proof Size summary in bytes: - // Measured: `445` - // Estimated: `554807` - // Minimum execution time: 15_000_000 picoseconds. - Weight::from_parts(16_000_000, 554807) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: INV4 Multisig (r:0 w:1) - /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) - fn cancel_multisig_proposal() -> Weight { - // 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)) - } - } +/// Weights for `pallet_inv4` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `INV4::NextCoreId` (r:1 w:1) + /// Proof: `INV4::NextCoreId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::Accounts` (r:1 w:1) + /// Proof: `CoreAssets::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::TotalIssuance` (r:1 w:1) + /// Proof: `CoreAssets::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreByAccount` (r:0 w:1) + /// Proof: `INV4::CoreByAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreStorage` (r:0 w:1) + /// Proof: `INV4::CoreStorage` (`max_values`: None, `max_size`: Some(10063), added: 12538, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreMembers` (r:0 w:1) + /// Proof: `INV4::CoreMembers` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + /// The range of component `m` is `[0, 10000]`. + fn create_core(m: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `304` + // Estimated: `6196` + // Minimum execution time: 61_000_000 picoseconds. + Weight::from_parts(61_957_455, 6196) + // Standard Error: 17 + .saturating_add(Weight::from_parts(769, 0).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) + } + /// Storage: `INV4::CoreStorage` (r:1 w:1) + /// Proof: `INV4::CoreStorage` (`max_values`: None, `max_size`: Some(10063), added: 12538, mode: `MaxEncodedLen`) + /// The range of component `m` is `[0, 10000]`. + fn set_parameters(m: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `234` + // Estimated: `13528` + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(8_995_089, 13528) + // Standard Error: 5 + .saturating_add(Weight::from_parts(684, 0).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `CoreAssets::Accounts` (r:1 w:1) + /// Proof: `CoreAssets::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::TotalIssuance` (r:1 w:1) + /// Proof: `CoreAssets::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreMembers` (r:0 w:1) + /// Proof: `INV4::CoreMembers` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + fn token_mint() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `3593` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(26_000_000, 3593) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `CoreAssets::Accounts` (r:1 w:1) + /// Proof: `CoreAssets::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::TotalIssuance` (r:1 w:1) + /// Proof: `CoreAssets::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreMembers` (r:0 w:1) + /// Proof: `INV4::CoreMembers` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + fn token_burn() -> Weight { + // Proof Size summary in bytes: + // Measured: `438` + // Estimated: `3593` + // Minimum execution time: 27_000_000 picoseconds. + Weight::from_parts(28_000_000, 3593) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `CoreAssets::Accounts` (r:1 w:0) + /// Proof: `CoreAssets::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreStorage` (r:1 w:0) + /// Proof: `INV4::CoreStorage` (`max_values`: None, `max_size`: Some(10063), added: 12538, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::TotalIssuance` (r:1 w:0) + /// Proof: `CoreAssets::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `INV4::Multisig` (r:1 w:1) + /// Proof: `INV4::Multisig` (`max_values`: None, `max_size`: Some(551342), added: 553817, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// The range of component `m` is `[0, 10000]`. + /// The range of component `z` is `[0, 51190]`. + fn operate_multisig(m: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `529` + // Estimated: `554807` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(21_624_412, 554807) + // Standard Error: 15 + .saturating_add(Weight::from_parts(397, 0).saturating_mul(m.into())) + // Standard Error: 3 + .saturating_add(Weight::from_parts(1_514, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `INV4::Multisig` (r:1 w:1) + /// Proof: `INV4::Multisig` (`max_values`: None, `max_size`: Some(551342), added: 553817, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::Accounts` (r:1 w:0) + /// Proof: `CoreAssets::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreStorage` (r:1 w:0) + /// Proof: `INV4::CoreStorage` (`max_values`: None, `max_size`: Some(10063), added: 12538, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::TotalIssuance` (r:1 w:0) + /// Proof: `CoreAssets::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn vote_multisig() -> Weight { + // Proof Size summary in bytes: + // Measured: `780` + // Estimated: `554807` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(26_000_000, 554807) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `INV4::Multisig` (r:1 w:1) + /// Proof: `INV4::Multisig` (`max_values`: None, `max_size`: Some(551342), added: 553817, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn withdraw_vote_multisig() -> Weight { + // Proof Size summary in bytes: + // Measured: `514` + // Estimated: `554807` + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(14_000_000, 554807) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `INV4::Multisig` (r:0 w:1) + /// Proof: `INV4::Multisig` (`max_values`: None, `max_size`: Some(551342), added: 553817, mode: `MaxEncodedLen`) + fn cancel_multisig_proposal() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_000_000 picoseconds. + Weight::from_parts(7_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} - // For backwards compatibility and tests. - impl WeightInfo for () { - /// Storage: INV4 NextCoreId (r:1 w:1) - /// Proof: INV4 NextCoreId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: CoreAssets Accounts (r:1 w:1) - /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: CoreAssets TotalIssuance (r:1 w:1) - /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: INV4 CoreByAccount (r:0 w:1) - /// Proof: INV4 CoreByAccount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) - /// Storage: INV4 CoreStorage (r:0 w:1) - /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) - /// Storage: INV4 CoreMembers (r:0 w:1) - /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) - /// The range of component `m` is `[0, 10000]`. - fn create_core(m: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `273` - // Estimated: `6196` - // Minimum execution time: 84_000_000 picoseconds. - Weight::from_parts(85_462_672, 6196) - // Standard Error: 16 - .saturating_add(Weight::from_parts(781, 0).saturating_mul(m.into())) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) - } - /// Storage: INV4 CoreStorage (r:1 w:1) - /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) - /// The range of component `m` is `[0, 10000]`. - fn set_parameters(m: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `234` - // Estimated: `13528` - // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(12_279_117, 13528) - // Standard Error: 6 - .saturating_add(Weight::from_parts(717, 0).saturating_mul(m.into())) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: CoreAssets Accounts (r:1 w:1) - /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: CoreAssets TotalIssuance (r:1 w:1) - /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: INV4 CoreMembers (r:0 w:1) - /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) - fn token_mint() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `3593` - // Minimum execution time: 34_000_000 picoseconds. - Weight::from_parts(35_000_000, 3593) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: CoreAssets Accounts (r:1 w:1) - /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: CoreAssets TotalIssuance (r:1 w:1) - /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: INV4 CoreMembers (r:0 w:1) - /// Proof: INV4 CoreMembers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) - fn token_burn() -> Weight { - // Proof Size summary in bytes: - // Measured: `438` - // Estimated: `3593` - // Minimum execution time: 36_000_000 picoseconds. - Weight::from_parts(37_000_000, 3593) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: CoreAssets Accounts (r:1 w:0) - /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: INV4 CoreStorage (r:1 w:0) - /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) - /// Storage: CoreAssets TotalIssuance (r:1 w:0) - /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - /// Storage: INV4 Multisig (r:1 w:1) - /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) - /// The range of component `m` is `[0, 10000]`. - /// The range of component `z` is `[0, 51190]`. - fn operate_multisig(m: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `498` - // Estimated: `554807` - // Minimum execution time: 29_000_000 picoseconds. - Weight::from_parts(25_808_010, 554807) - // Standard Error: 21 - .saturating_add(Weight::from_parts(313, 0).saturating_mul(m.into())) - // Standard Error: 4 - .saturating_add(Weight::from_parts(1_643, 0).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: INV4 Multisig (r:1 w:1) - /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) - /// Storage: CoreAssets Accounts (r:1 w:0) - /// Proof: CoreAssets Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: INV4 CoreStorage (r:1 w:0) - /// Proof: INV4 CoreStorage (max_values: None, max_size: Some(10063), added: 12538, mode: MaxEncodedLen) - /// Storage: CoreAssets TotalIssuance (r:1 w:0) - /// Proof: CoreAssets TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - fn vote_multisig() -> Weight { - // Proof Size summary in bytes: - // Measured: `749` - // Estimated: `554807` - // Minimum execution time: 27_000_000 picoseconds. - Weight::from_parts(28_000_000, 554807) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: INV4 Multisig (r:1 w:1) - /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) - fn withdraw_vote_multisig() -> Weight { - // Proof Size summary in bytes: - // Measured: `445` - // Estimated: `554807` - // Minimum execution time: 15_000_000 picoseconds. - Weight::from_parts(16_000_000, 554807) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: INV4 Multisig (r:0 w:1) - /// Proof: INV4 Multisig (max_values: None, max_size: Some(551342), added: 553817, mode: MaxEncodedLen) - fn cancel_multisig_proposal() -> Weight { - // 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)) - } - } +// For backwards compatibility and tests. +impl WeightInfo for () { + /// Storage: `INV4::NextCoreId` (r:1 w:1) + /// Proof: `INV4::NextCoreId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::Accounts` (r:1 w:1) + /// Proof: `CoreAssets::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::TotalIssuance` (r:1 w:1) + /// Proof: `CoreAssets::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreByAccount` (r:0 w:1) + /// Proof: `INV4::CoreByAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreStorage` (r:0 w:1) + /// Proof: `INV4::CoreStorage` (`max_values`: None, `max_size`: Some(10063), added: 12538, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreMembers` (r:0 w:1) + /// Proof: `INV4::CoreMembers` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + /// The range of component `m` is `[0, 10000]`. + fn create_core(m: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `304` + // Estimated: `6196` + // Minimum execution time: 61_000_000 picoseconds. + Weight::from_parts(61_957_455, 6196) + // Standard Error: 17 + .saturating_add(Weight::from_parts(769, 0).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + } + /// Storage: `INV4::CoreStorage` (r:1 w:1) + /// Proof: `INV4::CoreStorage` (`max_values`: None, `max_size`: Some(10063), added: 12538, mode: `MaxEncodedLen`) + /// The range of component `m` is `[0, 10000]`. + fn set_parameters(m: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `234` + // Estimated: `13528` + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(8_995_089, 13528) + // Standard Error: 5 + .saturating_add(Weight::from_parts(684, 0).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `CoreAssets::Accounts` (r:1 w:1) + /// Proof: `CoreAssets::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::TotalIssuance` (r:1 w:1) + /// Proof: `CoreAssets::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreMembers` (r:0 w:1) + /// Proof: `INV4::CoreMembers` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + fn token_mint() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `3593` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(26_000_000, 3593) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `CoreAssets::Accounts` (r:1 w:1) + /// Proof: `CoreAssets::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::TotalIssuance` (r:1 w:1) + /// Proof: `CoreAssets::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreMembers` (r:0 w:1) + /// Proof: `INV4::CoreMembers` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + fn token_burn() -> Weight { + // Proof Size summary in bytes: + // Measured: `438` + // Estimated: `3593` + // Minimum execution time: 27_000_000 picoseconds. + Weight::from_parts(28_000_000, 3593) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `CoreAssets::Accounts` (r:1 w:0) + /// Proof: `CoreAssets::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreStorage` (r:1 w:0) + /// Proof: `INV4::CoreStorage` (`max_values`: None, `max_size`: Some(10063), added: 12538, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::TotalIssuance` (r:1 w:0) + /// Proof: `CoreAssets::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `INV4::Multisig` (r:1 w:1) + /// Proof: `INV4::Multisig` (`max_values`: None, `max_size`: Some(551342), added: 553817, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// The range of component `m` is `[0, 10000]`. + /// The range of component `z` is `[0, 51190]`. + fn operate_multisig(m: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `529` + // Estimated: `554807` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(21_624_412, 554807) + // Standard Error: 15 + .saturating_add(Weight::from_parts(397, 0).saturating_mul(m.into())) + // Standard Error: 3 + .saturating_add(Weight::from_parts(1_514, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `INV4::Multisig` (r:1 w:1) + /// Proof: `INV4::Multisig` (`max_values`: None, `max_size`: Some(551342), added: 553817, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::Accounts` (r:1 w:0) + /// Proof: `CoreAssets::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `INV4::CoreStorage` (r:1 w:0) + /// Proof: `INV4::CoreStorage` (`max_values`: None, `max_size`: Some(10063), added: 12538, mode: `MaxEncodedLen`) + /// Storage: `CoreAssets::TotalIssuance` (r:1 w:0) + /// Proof: `CoreAssets::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn vote_multisig() -> Weight { + // Proof Size summary in bytes: + // Measured: `780` + // Estimated: `554807` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(26_000_000, 554807) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `INV4::Multisig` (r:1 w:1) + /// Proof: `INV4::Multisig` (`max_values`: None, `max_size`: Some(551342), added: 553817, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn withdraw_vote_multisig() -> Weight { + // Proof Size summary in bytes: + // Measured: `514` + // Estimated: `554807` + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(14_000_000, 554807) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `INV4::Multisig` (r:0 w:1) + /// Proof: `INV4::Multisig` (`max_values`: None, `max_size`: Some(551342), added: 553817, mode: `MaxEncodedLen`) + fn cancel_multisig_proposal() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_000_000 picoseconds. + Weight::from_parts(7_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/OCIF/staking/src/weights.rs b/OCIF/staking/src/weights.rs index bb53e10f..28e48e00 100644 --- a/OCIF/staking/src/weights.rs +++ b/OCIF/staking/src/weights.rs @@ -2,26 +2,25 @@ //! Autogenerated weights for `pallet_ocif_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-05-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Gabriels-MacBook-Pro-3.local`, CPU: `` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! HOSTNAME: `anny.local`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: - // ./target/release/tinkernet-collator - // benchmark - // pallet - // --chain=dev - // --execution=wasm - // --wasm-execution=compiled - // --pallet=pallet_ocif_staking - // --extrinsic=* - // --steps - // 50 - // --repeat - // 20 - // --output=../../InvArch-Frames/OCIF/staking/src/weights.rs - // --template=../weights-template.hbs +// ./target/release/tinkernet-collator +// benchmark +// pallet +// --chain=dev +// --wasm-execution=compiled +// --pallet=pallet-ocif-staking +// --extrinsic=* +// --steps +// 50 +// --repeat +// 20 +// --output=../../InvArch-Frames/OCIF/staking/src/weights.rs +// --template=../weights-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -33,431 +32,443 @@ use core::marker::PhantomData; /// Weight functions needed for `pallet_ocif_staking`. pub trait WeightInfo { - fn register_core(n: u32, d: u32, i: u32, ) -> Weight; - fn change_core_metadata(n: u32, d: u32, i: u32, ) -> Weight; - fn unregister_core() -> Weight; - fn stake() -> Weight; - fn unstake() -> Weight; - fn withdraw_unstaked() -> Weight; - fn staker_claim_rewards() -> Weight; - fn core_claim_rewards() -> Weight; - fn halt_unhalt_pallet() -> Weight; - fn move_stake() -> Weight; - } + fn register_core(n: u32, d: u32, i: u32, ) -> Weight; + fn change_core_metadata(n: u32, d: u32, i: u32, ) -> Weight; + fn unregister_core() -> Weight; + fn stake() -> Weight; + fn unstake() -> Weight; + fn withdraw_unstaked() -> Weight; + fn staker_claim_rewards() -> Weight; + fn core_claim_rewards() -> Weight; + fn halt_unhalt_pallet() -> Weight; + fn move_stake() -> Weight; +} - /// Weights for `pallet_ocif_staking` using the Substrate node and recommended hardware. - pub struct SubstrateWeight(PhantomData); - impl WeightInfo for SubstrateWeight { - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:1) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// The range of component `n` is `[0, 20]`. - /// The range of component `d` is `[0, 300]`. - /// The range of component `i` is `[0, 100]`. - fn register_core(_n: u32, d: u32, i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `144` - // Estimated: `3942` - // Minimum execution time: 28_000_000 picoseconds. - Weight::from_parts(28_865_871, 3942) - // Standard Error: 170 - .saturating_add(Weight::from_parts(1_142, 0).saturating_mul(d.into())) - // Standard Error: 509 - .saturating_add(Weight::from_parts(3_348, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:1) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// The range of component `n` is `[0, 20]`. - /// The range of component `d` is `[0, 300]`. - /// The range of component `i` is `[0, 100]`. - fn change_core_metadata(n: u32, d: u32, i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `86` - // Estimated: `3942` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(14_052_844, 3942) - // Standard Error: 1_584 - .saturating_add(Weight::from_parts(6_072, 0).saturating_mul(n.into())) - // Standard Error: 108 - .saturating_add(Weight::from_parts(2_023, 0).saturating_mul(d.into())) - // Standard Error: 324 - .saturating_add(Weight::from_parts(2_933, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:1) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralStakerInfo (r:1 w:0) - /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn unregister_core() -> Weight { - // Proof Size summary in bytes: - // Measured: `268` - // Estimated: `3942` - // Minimum execution time: 35_000_000 picoseconds. - Weight::from_parts(36_000_000, 3942) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:0) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// Storage: OcifStaking Ledger (r:1 w:1) - /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking CoreEraStake (r:1 w:1) - /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) - /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - fn stake() -> Weight { - // Proof Size summary in bytes: - // Measured: `86` - // Estimated: `4764` - // Minimum execution time: 47_000_000 picoseconds. - Weight::from_parts(48_000_000, 4764) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:0) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) - /// Storage: OcifStaking CoreEraStake (r:1 w:1) - /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: OcifStaking Ledger (r:1 w:1) - /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) - /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) - fn unstake() -> Weight { - // Proof Size summary in bytes: - // Measured: `397` - // Estimated: `4764` - // Minimum execution time: 45_000_000 picoseconds. - Weight::from_parts(46_000_000, 4764) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking Ledger (r:1 w:1) - /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) - /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) - fn withdraw_unstaked() -> Weight { - // Proof Size summary in bytes: - // Measured: `449` - // Estimated: `4764` - // Minimum execution time: 63_000_000 picoseconds. - Weight::from_parts(69_000_000, 4764) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking CoreEraStake (r:1 w:0) - /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralEraInfo (r:1 w:0) - /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) - fn staker_claim_rewards() -> Weight { - // Proof Size summary in bytes: - // Measured: `374` - // Estimated: `3734` - // Minimum execution time: 24_000_000 picoseconds. - Weight::from_parts(26_000_000, 3734) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking CoreEraStake (r:1 w:1) - /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralEraInfo (r:1 w:0) - /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) - fn core_claim_rewards() -> Weight { - // Proof Size summary in bytes: - // Measured: `308` - // Estimated: `3557` - // Minimum execution time: 22_000_000 picoseconds. - Weight::from_parts(22_000_000, 3557) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:1) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - fn halt_unhalt_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `4` - // Estimated: `1486` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(9_000_000, 1486) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:0) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralStakerInfo (r:2 w:2) - /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) - /// Storage: OcifStaking CoreEraStake (r:2 w:2) - /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - fn move_stake() -> Weight { - // Proof Size summary in bytes: - // Measured: `302` - // Estimated: `6478` - // Minimum execution time: 32_000_000 picoseconds. - Weight::from_parts(33_000_000, 6478) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - } +/// Weights for `pallet_ocif_staking` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:1) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `n` is `[0, 20]`. + /// The range of component `d` is `[0, 300]`. + /// The range of component `i` is `[0, 100]`. + fn register_core(_n: u32, d: u32, i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `213` + // Estimated: `3942` + // Minimum execution time: 22_000_000 picoseconds. + Weight::from_parts(23_127_348, 3942) + // Standard Error: 152 + .saturating_add(Weight::from_parts(526, 0).saturating_mul(d.into())) + // Standard Error: 456 + .saturating_add(Weight::from_parts(395, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:1) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// The range of component `n` is `[0, 20]`. + /// The range of component `d` is `[0, 300]`. + /// The range of component `i` is `[0, 100]`. + fn change_core_metadata(n: u32, d: u32, i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `86` + // Estimated: `3942` + // Minimum execution time: 9_000_000 picoseconds. + Weight::from_parts(9_729_396, 3942) + // Standard Error: 1_581 + .saturating_add(Weight::from_parts(5_533, 0).saturating_mul(n.into())) + // Standard Error: 108 + .saturating_add(Weight::from_parts(788, 0).saturating_mul(d.into())) + // Standard Error: 324 + .saturating_add(Weight::from_parts(947, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:1) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralStakerInfo` (r:1 w:0) + /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn unregister_core() -> Weight { + // Proof Size summary in bytes: + // Measured: `337` + // Estimated: `3942` + // Minimum execution time: 27_000_000 picoseconds. + Weight::from_parts(28_000_000, 3942) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:0) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::Ledger` (r:1 w:1) + /// Proof: `OcifStaking::Ledger` (`max_values`: None, `max_size`: Some(265), added: 2740, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:1 w:1) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralStakerInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + fn stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `86` + // Estimated: `4764` + // Minimum execution time: 34_000_000 picoseconds. + Weight::from_parts(35_000_000, 4764) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:0) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralStakerInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:1 w:1) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::Ledger` (r:1 w:1) + /// Proof: `OcifStaking::Ledger` (`max_values`: None, `max_size`: Some(265), added: 2740, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn unstake() -> Weight { + // Proof Size summary in bytes: + // Measured: `397` + // Estimated: `4764` + // Minimum execution time: 35_000_000 picoseconds. + Weight::from_parts(36_000_000, 4764) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::Ledger` (r:1 w:1) + /// Proof: `OcifStaking::Ledger` (`max_values`: None, `max_size`: Some(265), added: 2740, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn withdraw_unstaked() -> Weight { + // Proof Size summary in bytes: + // Measured: `449` + // Estimated: `4764` + // Minimum execution time: 32_000_000 picoseconds. + Weight::from_parts(34_000_000, 4764) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralStakerInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:1 w:0) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:0) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn staker_claim_rewards() -> Weight { + // Proof Size summary in bytes: + // Measured: `374` + // Estimated: `3734` + // Minimum execution time: 19_000_000 picoseconds. + Weight::from_parts(20_000_000, 3734) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:1 w:1) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:0) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn core_claim_rewards() -> Weight { + // Proof Size summary in bytes: + // Measured: `377` + // Estimated: `3557` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 3557) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:1) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + fn halt_unhalt_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `4` + // Estimated: `1486` + // Minimum execution time: 5_000_000 picoseconds. + Weight::from_parts(6_000_000, 1486) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:0) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralStakerInfo` (r:2 w:2) + /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:2 w:2) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + fn move_stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `302` + // Estimated: `6478` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(26_000_000, 6478) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } +} - // For backwards compatibility and tests. - impl WeightInfo for () { - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:1) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// The range of component `n` is `[0, 20]`. - /// The range of component `d` is `[0, 300]`. - /// The range of component `i` is `[0, 100]`. - fn register_core(_n: u32, d: u32, i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `144` - // Estimated: `3942` - // Minimum execution time: 28_000_000 picoseconds. - Weight::from_parts(28_865_871, 3942) - // Standard Error: 170 - .saturating_add(Weight::from_parts(1_142, 0).saturating_mul(d.into())) - // Standard Error: 509 - .saturating_add(Weight::from_parts(3_348, 0).saturating_mul(i.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:1) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// The range of component `n` is `[0, 20]`. - /// The range of component `d` is `[0, 300]`. - /// The range of component `i` is `[0, 100]`. - fn change_core_metadata(n: u32, d: u32, i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `86` - // Estimated: `3942` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(14_052_844, 3942) - // Standard Error: 1_584 - .saturating_add(Weight::from_parts(6_072, 0).saturating_mul(n.into())) - // Standard Error: 108 - .saturating_add(Weight::from_parts(2_023, 0).saturating_mul(d.into())) - // Standard Error: 324 - .saturating_add(Weight::from_parts(2_933, 0).saturating_mul(i.into())) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:1) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralStakerInfo (r:1 w:0) - /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn unregister_core() -> Weight { - // Proof Size summary in bytes: - // Measured: `268` - // Estimated: `3942` - // Minimum execution time: 35_000_000 picoseconds. - Weight::from_parts(36_000_000, 3942) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:0) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// Storage: OcifStaking Ledger (r:1 w:1) - /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking CoreEraStake (r:1 w:1) - /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) - /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - fn stake() -> Weight { - // Proof Size summary in bytes: - // Measured: `86` - // Estimated: `4764` - // Minimum execution time: 47_000_000 picoseconds. - Weight::from_parts(48_000_000, 4764) - .saturating_add(RocksDbWeight::get().reads(9_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:0) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) - /// Storage: OcifStaking CoreEraStake (r:1 w:1) - /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: OcifStaking Ledger (r:1 w:1) - /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) - /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) - fn unstake() -> Weight { - // Proof Size summary in bytes: - // Measured: `397` - // Estimated: `4764` - // Minimum execution time: 45_000_000 picoseconds. - Weight::from_parts(46_000_000, 4764) - .saturating_add(RocksDbWeight::get().reads(9_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking Ledger (r:1 w:1) - /// Proof: OcifStaking Ledger (max_values: None, max_size: Some(265), added: 2740, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralEraInfo (r:1 w:1) - /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) - fn withdraw_unstaked() -> Weight { - // Proof Size summary in bytes: - // Measured: `449` - // Estimated: `4764` - // Minimum execution time: 63_000_000 picoseconds. - Weight::from_parts(69_000_000, 4764) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralStakerInfo (r:1 w:1) - /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking CoreEraStake (r:1 w:0) - /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralEraInfo (r:1 w:0) - /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) - fn staker_claim_rewards() -> Weight { - // Proof Size summary in bytes: - // Measured: `374` - // Estimated: `3734` - // Minimum execution time: 24_000_000 picoseconds. - Weight::from_parts(26_000_000, 3734) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking CoreEraStake (r:1 w:1) - /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralEraInfo (r:1 w:0) - /// Proof: OcifStaking GeneralEraInfo (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen) - fn core_claim_rewards() -> Weight { - // Proof Size summary in bytes: - // Measured: `308` - // Estimated: `3557` - // Minimum execution time: 22_000_000 picoseconds. - Weight::from_parts(22_000_000, 3557) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:1) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - fn halt_unhalt_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `4` - // Estimated: `1486` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(9_000_000, 1486) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: OcifStaking Halted (r:1 w:0) - /// Proof: OcifStaking Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: OcifStaking RegisteredCore (r:1 w:0) - /// Proof: OcifStaking RegisteredCore (max_values: None, max_size: Some(477), added: 2952, mode: MaxEncodedLen) - /// Storage: OcifStaking CurrentEra (r:1 w:0) - /// Proof: OcifStaking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: OcifStaking GeneralStakerInfo (r:2 w:2) - /// Proof: OcifStaking GeneralStakerInfo (max_values: None, max_size: Some(269), added: 2744, mode: MaxEncodedLen) - /// Storage: OcifStaking CoreEraStake (r:2 w:2) - /// Proof: OcifStaking CoreEraStake (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - fn move_stake() -> Weight { - // Proof Size summary in bytes: - // Measured: `302` - // Estimated: `6478` - // Minimum execution time: 32_000_000 picoseconds. - Weight::from_parts(33_000_000, 6478) - .saturating_add(RocksDbWeight::get().reads(7_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - } +// For backwards compatibility and tests. +impl WeightInfo for () { + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:1) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `n` is `[0, 20]`. + /// The range of component `d` is `[0, 300]`. + /// The range of component `i` is `[0, 100]`. + fn register_core(_n: u32, d: u32, i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `213` + // Estimated: `3942` + // Minimum execution time: 22_000_000 picoseconds. + Weight::from_parts(23_127_348, 3942) + // Standard Error: 152 + .saturating_add(Weight::from_parts(526, 0).saturating_mul(d.into())) + // Standard Error: 456 + .saturating_add(Weight::from_parts(395, 0).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:1) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// The range of component `n` is `[0, 20]`. + /// The range of component `d` is `[0, 300]`. + /// The range of component `i` is `[0, 100]`. + fn change_core_metadata(n: u32, d: u32, i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `86` + // Estimated: `3942` + // Minimum execution time: 9_000_000 picoseconds. + Weight::from_parts(9_729_396, 3942) + // Standard Error: 1_581 + .saturating_add(Weight::from_parts(5_533, 0).saturating_mul(n.into())) + // Standard Error: 108 + .saturating_add(Weight::from_parts(788, 0).saturating_mul(d.into())) + // Standard Error: 324 + .saturating_add(Weight::from_parts(947, 0).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:1) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralStakerInfo` (r:1 w:0) + /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn unregister_core() -> Weight { + // Proof Size summary in bytes: + // Measured: `337` + // Estimated: `3942` + // Minimum execution time: 27_000_000 picoseconds. + Weight::from_parts(28_000_000, 3942) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:0) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::Ledger` (r:1 w:1) + /// Proof: `OcifStaking::Ledger` (`max_values`: None, `max_size`: Some(265), added: 2740, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:1 w:1) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralStakerInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + fn stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `86` + // Estimated: `4764` + // Minimum execution time: 34_000_000 picoseconds. + Weight::from_parts(35_000_000, 4764) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:0) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralStakerInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:1 w:1) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::Ledger` (r:1 w:1) + /// Proof: `OcifStaking::Ledger` (`max_values`: None, `max_size`: Some(265), added: 2740, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn unstake() -> Weight { + // Proof Size summary in bytes: + // Measured: `397` + // Estimated: `4764` + // Minimum execution time: 35_000_000 picoseconds. + Weight::from_parts(36_000_000, 4764) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::Ledger` (r:1 w:1) + /// Proof: `OcifStaking::Ledger` (`max_values`: None, `max_size`: Some(265), added: 2740, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn withdraw_unstaked() -> Weight { + // Proof Size summary in bytes: + // Measured: `449` + // Estimated: `4764` + // Minimum execution time: 32_000_000 picoseconds. + Weight::from_parts(34_000_000, 4764) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralStakerInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:1 w:0) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:0) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn staker_claim_rewards() -> Weight { + // Proof Size summary in bytes: + // Measured: `374` + // Estimated: `3734` + // Minimum execution time: 19_000_000 picoseconds. + Weight::from_parts(20_000_000, 3734) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:1 w:1) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:0) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn core_claim_rewards() -> Weight { + // Proof Size summary in bytes: + // Measured: `377` + // Estimated: `3557` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 3557) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:1) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + fn halt_unhalt_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `4` + // Estimated: `1486` + // Minimum execution time: 5_000_000 picoseconds. + Weight::from_parts(6_000_000, 1486) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `OcifStaking::Halted` (r:1 w:0) + /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::RegisteredCore` (r:1 w:0) + /// Proof: `OcifStaking::RegisteredCore` (`max_values`: None, `max_size`: Some(477), added: 2952, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CurrentEra` (r:1 w:0) + /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralStakerInfo` (r:2 w:2) + /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:2 w:2) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + fn move_stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `302` + // Estimated: `6478` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(26_000_000, 6478) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } +} diff --git a/pallet-checked-inflation/src/lib.rs b/pallet-checked-inflation/src/lib.rs index e20451e6..7cbec736 100644 --- a/pallet-checked-inflation/src/lib.rs +++ b/pallet-checked-inflation/src/lib.rs @@ -209,7 +209,7 @@ pub mod pallet { }); } - T::DbWeight::get().reads_writes(7, 3) + T::DbWeight::get().reads_writes(3, 4) } else { let inflation_per_era = Self::inflation_per_era(); @@ -275,12 +275,12 @@ pub mod pallet { } } - T::DbWeight::get().reads_writes(8, 2) + T::DbWeight::get().reads_writes(5, 2) } else { - T::DbWeight::get().reads_writes(6, 2) + T::DbWeight::get().reads_writes(4, 2) } } else { - T::DbWeight::get().reads(6) + T::DbWeight::get().reads(4) } } } diff --git a/pallet-checked-inflation/src/weights.rs b/pallet-checked-inflation/src/weights.rs index ea4b8d77..f8dcdb43 100644 --- a/pallet-checked-inflation/src/weights.rs +++ b/pallet-checked-inflation/src/weights.rs @@ -2,26 +2,25 @@ //! Autogenerated weights for `pallet_checked_inflation` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-05-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Gabriels-MacBook-Pro-3.local`, CPU: `` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! HOSTNAME: `anny.local`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: - // ./target/release/invarch-collator - // benchmark - // pallet - // --chain=dev - // --execution=wasm - // --wasm-execution=compiled - // --pallet=pallet_checked_inflation - // --extrinsic=* - // --steps - // 50 - // --repeat - // 20 - // --output=../InvArch-Frames/pallet-checked-inflation/src/weights.rs - // --template=weights-template.hbs +// ./target/release/tinkernet-collator +// benchmark +// pallet +// --chain=dev +// --wasm-execution=compiled +// --pallet=pallet-checked-inflation +// --extrinsic=* +// --steps +// 50 +// --repeat +// 20 +// --output=../../InvArch-Frames/pallet-checked-inflation/src/weights.rs +// --template=../weights-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -33,57 +32,57 @@ use core::marker::PhantomData; /// Weight functions needed for `pallet_checked_inflation`. pub trait WeightInfo { - fn set_first_year_supply() -> Weight; - fn halt_unhalt_pallet() -> Weight; - } + fn set_first_year_supply() -> Weight; + fn halt_unhalt_pallet() -> Weight; +} - /// Weights for `pallet_checked_inflation` using the Substrate node and recommended hardware. - pub struct SubstrateWeight(PhantomData); - impl WeightInfo for SubstrateWeight { - /// Storage: CheckedInflation YearStartIssuance (r:0 w:1) - /// Proof: CheckedInflation YearStartIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - fn set_first_year_supply() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_000_000 picoseconds. - Weight::from_parts(4_000_000, 0) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: CheckedInflation Halted (r:1 w:1) - /// Proof: CheckedInflation Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - fn halt_unhalt_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `42` - // Estimated: `1486` - // Minimum execution time: 10_000_000 picoseconds. - Weight::from_parts(10_000_000, 1486) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - } +/// Weights for `pallet_checked_inflation` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `CheckedInflation::YearStartIssuance` (r:0 w:1) + /// Proof: `CheckedInflation::YearStartIssuance` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + fn set_first_year_supply() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(3_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `CheckedInflation::Halted` (r:1 w:1) + /// Proof: `CheckedInflation::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + fn halt_unhalt_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `1486` + // Minimum execution time: 5_000_000 picoseconds. + Weight::from_parts(6_000_000, 1486) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} - // For backwards compatibility and tests. - impl WeightInfo for () { - /// Storage: CheckedInflation YearStartIssuance (r:0 w:1) - /// Proof: CheckedInflation YearStartIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - fn set_first_year_supply() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_000_000 picoseconds. - Weight::from_parts(4_000_000, 0) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: CheckedInflation Halted (r:1 w:1) - /// Proof: CheckedInflation Halted (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - fn halt_unhalt_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `42` - // Estimated: `1486` - // Minimum execution time: 10_000_000 picoseconds. - Weight::from_parts(10_000_000, 1486) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - } +// For backwards compatibility and tests. +impl WeightInfo for () { + /// Storage: `CheckedInflation::YearStartIssuance` (r:0 w:1) + /// Proof: `CheckedInflation::YearStartIssuance` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + fn set_first_year_supply() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(3_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `CheckedInflation::Halted` (r:1 w:1) + /// Proof: `CheckedInflation::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + fn halt_unhalt_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `1486` + // Minimum execution time: 5_000_000 picoseconds. + Weight::from_parts(6_000_000, 1486) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/pallet-rings/Cargo.toml b/pallet-rings/Cargo.toml index 572f654d..8c778f5e 100644 --- a/pallet-rings/Cargo.toml +++ b/pallet-rings/Cargo.toml @@ -74,6 +74,7 @@ std = [ "orml-tokens2/std", "orml-asset-registry/std", "xcm-builder/std", + "frame-benchmarking?/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/pallet-rings/src/benchmarking.rs b/pallet-rings/src/benchmarking.rs index 540c0a57..8a5cae99 100644 --- a/pallet-rings/src/benchmarking.rs +++ b/pallet-rings/src/benchmarking.rs @@ -15,18 +15,15 @@ benchmarks! { where_clause { where Result< - INV4Origin< - T>, + INV4Origin, ::RuntimeOrigin, >: From<::RuntimeOrigin>, + ::RuntimeOrigin: From>, ::CoreId: Into, [u8; 32]: From<::AccountId>, - ::RuntimeOrigin: - From>, - T::AccountId: From<[u8; 32]>, } From e19df481d77e55693185cd46bdf558dab03b0bf9 Mon Sep 17 00:00:00 2001 From: Francisco Valentim Castilho Date: Mon, 3 Jun 2024 21:30:45 -0300 Subject: [PATCH 3/7] Feat: Core unregistration sharded execution using pallet_message_queue --- Cargo.toml | 3 + OCIF/staking/Cargo.toml | 5 + OCIF/staking/src/lib.rs | 239 ++++++++++++++++++++++--------- OCIF/staking/src/primitives.rs | 116 ++++++++++++++- OCIF/staking/src/testing/mock.rs | 69 ++++++++- OCIF/staking/src/testing/mod.rs | 22 +++ OCIF/staking/src/testing/test.rs | 59 ++++++++ 7 files changed, 440 insertions(+), 73 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f2200c1d..5a35d27d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", d frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } pallet-session = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } @@ -43,6 +44,8 @@ xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/par # dev dependencies +cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.6.0", default-features = false } + orml-asset-registry = { git = "https://github.com/InvArch/open-runtime-module-library.git", default-features = false, branch = "polkadot-v1.6.0" } orml-tokens2 = { package = "orml-tokens", git = "https://github.com/arrudagates/open-runtime-module-library.git", default-features = false, rev = "bc6b41e8a9539971a2da5d62cf8f550cde985f00" } orml-traits2 = { package = "orml-traits", git = "https://github.com/arrudagates/open-runtime-module-library.git", default-features = false, rev = "bc6b41e8a9539971a2da5d62cf8f550cde985f00" } diff --git a/OCIF/staking/Cargo.toml b/OCIF/staking/Cargo.toml index 0deea8b1..3444d6ea 100644 --- a/OCIF/staking/Cargo.toml +++ b/OCIF/staking/Cargo.toml @@ -20,6 +20,7 @@ frame-support = { workspace = true, default-features = false } frame-system = { workspace = true, default-features = false } num-traits = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false, optional = true } +pallet-message-queue = { workspace = true, default-features = false} pallet-session = { workspace = true, default-features = false } pallet-timestamp = { workspace = true, default-features = false, optional = true } sp-arithmetic = { workspace = true, default-features = false } @@ -34,6 +35,7 @@ pallet-inv4 = { path = "../../INV4/pallet-inv4", default-features = false } frame-benchmarking = { workspace = true, default-features = false, optional = true } [dev-dependencies] +cumulus-primitives-core = { workspace = true, default-features = false } orml-traits = { workspace = true, default-features = false } orml-tokens = { workspace = true, default-features = false } xcm = { workspace = true, default-features = false } @@ -45,6 +47,7 @@ std = [ "codec/std", "scale-info/std", "num-traits/std", + "cumulus-primitives-core/std", "sp-core/std", "sp-runtime/std", "sp-arithmetic/std", @@ -55,6 +58,7 @@ std = [ "frame-benchmarking?/std", "xcm/std", "pallet-balances/std", + "pallet-message-queue/std", "pallet-session/std", "pallet-timestamp/std", "pallet-inv4/std", @@ -67,6 +71,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "frame-system/runtime-benchmarks", "pallet-inv4/runtime-benchmarks", + "pallet-message-queue/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] diff --git a/OCIF/staking/src/lib.rs b/OCIF/staking/src/lib.rs index e6167ad7..c85f64e2 100644 --- a/OCIF/staking/src/lib.rs +++ b/OCIF/staking/src/lib.rs @@ -55,11 +55,11 @@ use frame_support::{ ensure, pallet_prelude::*, traits::{ - Currency, ExistenceRequirement, Get, Imbalance, LockIdentifier, LockableCurrency, - ReservableCurrency, WithdrawReasons, + Currency, EnqueueMessage, ExistenceRequirement, Get, Imbalance, LockIdentifier, + LockableCurrency, QueuePausedQuery, ReservableCurrency, WithdrawReasons, }, weights::Weight, - PalletId, + BoundedSlice, PalletId, }; use frame_system::{ensure_signed, pallet_prelude::*}; use sp_runtime::{ @@ -95,6 +95,8 @@ pub mod pallet { CoreAccountDerivation, }; + use pallet_message_queue::{self}; + use super::*; /// The balance type of this pallet. @@ -123,7 +125,9 @@ pub mod pallet { pub type Era = u32; #[pallet::config] - pub trait Config: frame_system::Config + pallet_inv4::Config { + pub trait Config: + frame_system::Config + pallet_inv4::Config + pallet_message_queue::Config + { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -208,6 +212,8 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; + + type StakingMessage: EnqueueMessage; } /// General information about the staker. @@ -272,6 +278,12 @@ pub mod pallet { #[pallet::getter(fn is_halted)] pub type Halted = StorageValue<_, bool, ValueQuery>; + /// Placeholder for the core being unregistered and the era where it started. + #[pallet::storage] + #[pallet::getter(fn core_unregistering_staker_info)] + pub type UnregisteredCoreStakeInfo = + StorageMap<_, Blake2_128Concat, T::CoreId, CoreStakeInfo>, OptionQuery>; + #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] pub enum Event { @@ -337,6 +349,16 @@ pub mod pallet { to_core: T::CoreId, amount: BalanceOf, }, + /// Core is being unregistered. + CoreUnregistrationQueueStarted { core: T::CoreId }, + /// Core ungregistration chunk was processed. + CoreUnregistrationChunksProcessed { + core: T::CoreId, + accounts_processed_in_this_chunk: u64, + accounts_left: u64, + }, + /// Sharded execution of the core unregistration process finished. + CoreUnregistrationQueueFinished { core: T::CoreId }, } #[pallet::error] @@ -391,6 +413,10 @@ pub mod pallet { NoHaltChange, /// Attempted to move stake to the same core. MoveStakeToSameCore, + /// No weight configured for unregistering. + NoWeightConfiguredForUnregistering, + /// Queue is full. + UnregisteringQueueFull, } #[pallet::hooks] @@ -504,9 +530,12 @@ pub mod pallet { ::MaxStakersPerCore::get().div(100) * ::WeightInfo::unstake() )] pub fn unregister_core(origin: OriginFor) -> DispatchResultWithPostInfo { + // whats left to do is copy the storage to a temp storage for the unregistering + // set the stake info to zero. + // create the call to unregister parts, integrate pallet_messages. Self::ensure_not_halted()?; - let core = ensure_multisig::>(origin)?; + let core = ensure_multisig::>(origin.clone())?; let core_account = core.to_account_id(); let core_id = core.id; @@ -517,63 +546,42 @@ pub mod pallet { let current_era = Self::current_era(); - let staker_info_prefix = GeneralStakerInfo::::iter_key_prefix(core_id); - - let mut corrected_staker_length_fee = Zero::zero(); - - for staker in staker_info_prefix { - let mut core_stake_info = - Self::core_stake_info(core_id, current_era).unwrap_or_default(); - - let mut staker_info = Self::staker_info(core_id, &staker); - - let latest_staked_value = staker_info.latest_staked_value(); - - let value_to_unstake = Self::internal_unstake( - &mut staker_info, - &mut core_stake_info, - latest_staked_value, - current_era, - )?; - - let mut ledger = Self::ledger(&staker); - ledger.unbonding_info.add(UnlockingChunk { - amount: value_to_unstake, - unlock_era: current_era + T::UnbondingPeriod::get(), - }); - - ensure!( - ledger.unbonding_info.len() <= T::MaxUnlocking::get(), - Error::::TooManyUnlockingChunks - ); + let mut _core_stake_info = + Self::core_stake_info(core_id, current_era).unwrap_or_default(); + UnregisteredCoreStakeInfo::::insert(core_id, _core_stake_info.clone()); + GeneralEraInfo::::mutate(current_era, |value| { + if let Some(x) = value { + x.staked = x.staked.saturating_sub(_core_stake_info.total); + } + }); + _core_stake_info.total = Zero::zero(); + CoreEraStake::::insert(core_id, current_era, _core_stake_info.clone()); - Self::update_ledger(&staker, ledger); + let mut _corrected_staker_length_fee = Zero::zero(); - GeneralEraInfo::::mutate(current_era, |value| { - if let Some(x) = value { - x.staked = x.staked.saturating_sub(value_to_unstake); - } - }); - Self::update_staker_info(&staker, core_id, staker_info); - CoreEraStake::::insert(core_id, current_era, core_stake_info); + RegisteredCore::::remove(core_id); + ::Currency::unreserve(&core_account, T::RegisterDeposit::get()); - Self::deposit_event(Event::::Unstaked { - staker, - core: core_id, - amount: value_to_unstake, - }); + let _total_stakers = _core_stake_info.number_of_stakers; - corrected_staker_length_fee += ::WeightInfo::unstake(); + let message = primitives::UnregisterMessage:: { + core_id: core_id.clone(), + era: current_era, + stakers_to_unstake: _total_stakers, } + .encode(); - RegisteredCore::::remove(core_id); + T::StakingMessage::enqueue_message( + BoundedSlice::truncate_from(message.as_slice()), + UnregisterMessageOrigin {}, + ); - ::Currency::unreserve(&core_account, T::RegisterDeposit::get()); + Self::deposit_event(Event::::CoreUnregistrationQueueStarted { core: core_id }); Self::deposit_event(Event::::CoreUnregistered { core: core_id }); Ok( - Some(::WeightInfo::unregister_core() + corrected_staker_length_fee) + Some(::WeightInfo::unregister_core() + _corrected_staker_length_fee) .into(), ) } @@ -828,24 +836,43 @@ pub mod pallet { let current_era = Self::current_era(); ensure!(era < current_era, Error::::IncorrectEra); + // // Check if the ensure staking_info.total > Zero::zero(), is a good way to avoid this extra read. + // if let Some(unregister_era) = Self::is_core_unregistering(core_id) { + // ensure!(era < unregister_era, Error::::NoStakeAvailable); + // } let staking_info = Self::core_stake_info(core_id, era).unwrap_or_default(); - let reward_and_stake = - Self::general_era_info(era).ok_or(Error::::UnknownEraReward)?; - let (_, stakers_joint_reward) = - Self::core_stakers_split(&staking_info, &reward_and_stake); - let staker_reward = - Perbill::from_rational(staked, staking_info.total) * stakers_joint_reward; + // // Just in case the core is being unregistered and the staker was not unstaked yet. + // // Erroring here may require the front end to handle the case where the user is trying to claim rewards + // // before the core is unregistered. + // // I'll write another option for avoiding this error down here. + // ensure!( + // staking_info.total > Zero::zero(), + // Error::::NoStakeAvailable + // ); + + let mut staker_reward = Zero::zero(); + + if staking_info.total > Zero::zero() { + let reward_and_stake = + Self::general_era_info(era).ok_or(Error::::UnknownEraReward)?; + + let (_, stakers_joint_reward) = + Self::core_stakers_split(&staking_info, &reward_and_stake); + staker_reward = + Perbill::from_rational(staked, staking_info.total) * stakers_joint_reward; + + let reward_imbalance = ::Currency::withdraw( + &Self::account_id(), + staker_reward, + WithdrawReasons::TRANSFER, + ExistenceRequirement::AllowDeath, + )?; - let reward_imbalance = ::Currency::withdraw( - &Self::account_id(), - staker_reward, - WithdrawReasons::TRANSFER, - ExistenceRequirement::AllowDeath, - )?; + ::Currency::resolve_creating(&staker, reward_imbalance); + Self::update_staker_info(&staker, core_id, staker_info); + } - ::Currency::resolve_creating(&staker, reward_imbalance); - Self::update_staker_info(&staker, core_id, staker_info); Self::deposit_event(Event::::StakerClaimed { staker, core: core_id, @@ -1247,5 +1274,87 @@ pub mod pallet { Ok(()) } } + + /// Sharded execution of the core unregistration process. + /// + /// This function is called by the [`ProcessMessage`] trait implemented in [`primitives::ProcessUnregistrationMessages`] + pub(crate) fn process_core_unregistration_shard( + stakers: u32, + core_id: T::CoreId, + start_era: Era, + chunk_size: u64, + ) -> DispatchResultWithPostInfo { + let staker_info_prefix = GeneralStakerInfo::::iter_key_prefix(core_id); + + let mut corrected_staker_length_fee = Zero::zero(); + + for staker in staker_info_prefix.take(chunk_size as usize) { + let mut core_stake_info = + Self::core_unregistering_staker_info(core_id).unwrap_or_default(); + + let mut staker_info = Self::staker_info(core_id, &staker); + + let latest_staked_value = staker_info.latest_staked_value(); + + let value_to_unstake = Self::internal_unstake( + &mut staker_info, + &mut core_stake_info, + latest_staked_value, + start_era, + )?; + + let mut ledger = Self::ledger(&staker); + ledger.unbonding_info.add(UnlockingChunk { + amount: value_to_unstake, + unlock_era: start_era + T::UnbondingPeriod::get(), + }); + + ensure!( + ledger.unbonding_info.len() <= T::MaxUnlocking::get(), + Error::::TooManyUnlockingChunks + ); + + Self::update_ledger(&staker, ledger); + + Self::update_staker_info(&staker, core_id, staker_info); + + Self::deposit_event(Event::::Unstaked { + staker, + core: core_id, + amount: value_to_unstake, + }); + corrected_staker_length_fee += ::WeightInfo::unstake(); + } + + let total_remaning_stakers = stakers.saturating_sub(chunk_size as u32); + if total_remaning_stakers != 0 { + let _call: Vec = primitives::UnregisterMessage:: { + core_id: core_id.clone(), + stakers_to_unstake: total_remaning_stakers, + era: start_era, + } + .encode(); + + T::StakingMessage::enqueue_message( + BoundedSlice::truncate_from(_call.as_slice()), + UnregisterMessageOrigin {}, + ); + Self::deposit_event(Event::::CoreUnregistrationChunksProcessed { + core: core_id, + accounts_processed_in_this_chunk: chunk_size.min(stakers.into()), + accounts_left: total_remaning_stakers as u64, + }); + } else { + Self::deposit_event(Event::::CoreUnregistrationQueueFinished { core: core_id }); + } + + Ok(Some(corrected_staker_length_fee).into()) + } + } +} + +impl QueuePausedQuery for Pallet { + fn is_paused(_origin: &T) -> bool { + Pallet::::is_halted() } } diff --git a/OCIF/staking/src/primitives.rs b/OCIF/staking/src/primitives.rs index ca9cfc67..25324458 100644 --- a/OCIF/staking/src/primitives.rs +++ b/OCIF/staking/src/primitives.rs @@ -19,16 +19,21 @@ //! - `UnbondingInfo` - A struct that holds information about unbonding chunks of balance. //! - `AccountLedger` - A struct that holds information about an account's locked balance and unbonding information. -use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; -use frame_support::traits::Currency; -use scale_info::TypeInfo; +use codec::{Decode, Encode, FullCodec, HasCompact, MaxEncodedLen}; +use frame_support::{ + pallet_prelude::Weight, + traits::{Currency, ProcessMessage, QueueFootprint, QueuePausedQuery}, +}; +use pallet_message_queue::OnQueueChanged; +use scale_info::{prelude::marker::PhantomData, TypeInfo}; use sp_runtime::{ traits::{AtLeast32BitUnsigned, Zero}, - RuntimeDebug, + Perbill, RuntimeDebug, }; -use sp_std::{ops::Add, prelude::*}; +use sp_std::{fmt::Debug, ops::Add, prelude::*}; pub use crate::pallet::*; +use crate::weights::WeightInfo; /// The balance type of this pallet. pub type BalanceOf = @@ -182,6 +187,9 @@ impl StakerInfo { if let Some(era_stake) = self.stakes.first() { let era_stake = *era_stake; + // this checks if the last claim was from an older era or if the latest staking info is from + // a newer era compared to the last claim, allowing the user to increase their stake while not losing + // or messing with their stake from the previous eras. if self.stakes.len() == 1 || self.stakes[1].era > era_stake.era + 1 { self.stakes[0] = EraStake { staked: era_stake.staked, @@ -313,3 +321,101 @@ impl AccountLedg self.locked.is_zero() && self.unbonding_info.is_empty() } } + +#[derive(Encode, Decode, MaxEncodedLen, Clone, Eq, PartialEq, TypeInfo, Debug)] +pub struct UnregisterMessageOrigin; + +impl QueuePausedQuery for UnregisterMessageOrigin { + fn is_paused(_origin: &O) -> bool { + false + } +} + +impl OnQueueChanged for UnregisterMessageOrigin { + fn on_queue_changed(_origin: O, fp: QueueFootprint) { + println!("on queue changed {:#?}", fp); + } +} + +#[derive(Clone, PartialEq, Eq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen)] +pub struct UnregisterMessage { + pub(crate) core_id: T::CoreId, + pub(crate) era: Era, + pub(crate) stakers_to_unstake: u32, +} + +pub struct ProcessUnregistrationMessages(PhantomData<(Origin, T)>); +impl + ProcessMessage for ProcessUnregistrationMessages +{ + type Origin = Origin; + fn process_message( + message: &[u8], + _origin: Self::Origin, + meter: &mut frame_support::weights::WeightMeter, + _id: &mut [u8; 32], + ) -> Result { + let call: UnregisterMessage = UnregisterMessage::::decode(&mut &message[..]) + .map_err(|_| frame_support::traits::ProcessMessageError::Corrupt)?; + + let unstake_weight = ::WeightInfo::unstake(); + + let meter_limit = meter.limit(); + + let thirdy_of_limit = Perbill::from_percent(30) * meter_limit; + + let meter_remaining = meter.remaining(); + + let min_desired = { + // if a third of the proofsize is > 1/2 MB then we use a 1/2 MB for the proofsize weight. + if thirdy_of_limit.proof_size() >= 524288 { + Weight::from_parts(thirdy_of_limit.ref_time(), 524288) + } else { + thirdy_of_limit + } + }; + + // only use less than 30% of all the weight the message queue can provide. + if !meter_remaining.all_gte(Perbill::from_percent(70) * meter_limit) { + return Err(frame_support::traits::ProcessMessageError::Yield); + } + + let max_calls = { + match min_desired.checked_div_per_component(&unstake_weight) { + Some(x) if x > 0 => x.min(100), + _ => return Err(frame_support::traits::ProcessMessageError::Yield), + } + }; + + let max_weight = max_calls * unstake_weight; + + let chunk_result = crate::pallet::Pallet::::process_core_unregistration_shard( + call.stakers_to_unstake, + call.core_id, + call.era, + max_calls, + ); + + match chunk_result { + Ok(weight) => { + if let Some(actual_weight) = weight.actual_weight { + meter.try_consume(actual_weight).map_err(|_| { + frame_support::traits::ProcessMessageError::Overweight(actual_weight) + })?; + } else { + meter.try_consume(max_weight).map_err(|_| { + frame_support::traits::ProcessMessageError::Overweight(max_weight) + })?; + } + Ok(true) + } + Err(_) => { + println!("error"); + meter.try_consume(max_weight).map_err(|_| { + frame_support::traits::ProcessMessageError::Overweight(max_weight) + })?; + Ok(false) + } + } + } +} diff --git a/OCIF/staking/src/testing/mock.rs b/OCIF/staking/src/testing/mock.rs index b3c2e768..3d9f6af8 100644 --- a/OCIF/staking/src/testing/mock.rs +++ b/OCIF/staking/src/testing/mock.rs @@ -1,12 +1,17 @@ -use crate as pallet_ocif_staking; +use crate::{self as pallet_ocif_staking, ProcessUnregistrationMessages, UnregisterMessageOrigin}; use codec::{Decode, Encode}; use core::convert::{TryFrom, TryInto}; use frame_support::{ - construct_runtime, derive_impl, parameter_types, + construct_runtime, derive_impl, + dispatch::DispatchClass, + parameter_types, traits::{ fungibles::Credit, ConstU128, ConstU32, Contains, Currency, OnFinalize, OnInitialize, }, - weights::Weight, + weights::{ + constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND}, + Weight, + }, PalletId, }; use pallet_inv4::CoreAccountDerivation; @@ -27,6 +32,7 @@ type Block = frame_system::mocking::MockBlock; pub(crate) const EXISTENTIAL_DEPOSIT: Balance = 2; pub(crate) const MAX_NUMBER_OF_STAKERS: u32 = 4; +pub(crate) const _MAX_NUMBER_OF_STAKERS_TINKERNET: u32 = 10000; pub(crate) const MINIMUM_STAKING_AMOUNT: Balance = 10; pub(crate) const MAX_UNLOCKING: u32 = 4; pub(crate) const UNBONDING_PERIOD: EraIndex = 3; @@ -42,6 +48,7 @@ construct_runtime!( OcifStaking: pallet_ocif_staking, CoreAssets: orml_tokens, INV4: pallet_inv4, + MessageQueue: pallet_message_queue, } ); @@ -258,8 +265,61 @@ impl pallet_ocif_staking::Config for Test { type RewardRatio = RewardRatio; type StakeThresholdForActiveCore = ConstU128; type WeightInfo = crate::weights::SubstrateWeight; + type StakingMessage = MessageQueue; +} + +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by +/// `Operational` extrinsics. (from tinkernet) +const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); + +/// We allow for 0.5 of a second of compute with a 12 second average block time. +const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( + WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64, +); + +/// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. +/// This is used to limit the maximal weight of a single extrinsic. +const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); + +parameter_types! { + pub RuntimeBlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() + .base_block(BlockExecutionWeight::get()) + .for_class(DispatchClass::all(), |weights| { + weights.base_extrinsic = ExtrinsicBaseWeight::get(); + }) + .for_class(DispatchClass::Normal, |weights| { + weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); + }) + .for_class(DispatchClass::Operational, |weights| { + weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); + // Operational transactions have some extra reserved space, so that they + // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. + weights.reserved = Some( + MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT + ); + }) + .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) + .build_or_panic(); + pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block; + pub const MessageQueueMaxStale: u32 = 8; + pub const MessageQueueHeapSize: u32 = 128 * 1048; } +impl pallet_message_queue::Config for Test { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_message_queue::weights::SubstrateWeight; + #[cfg(feature = "runtime-benchmarks")] + type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<()>; + #[cfg(not(feature = "runtime-benchmarks"))] + type MessageProcessor = ProcessUnregistrationMessages; + type Size = u32; + type QueueChangeHandler = (); + type QueuePausedQuery = UnregisterMessageOrigin; + type HeapSize = MessageQueueHeapSize; + type MaxStale = MessageQueueMaxStale; + type ServiceWeight = MessageQueueServiceWeight; +} pub struct ExternalityBuilder; pub fn account(core: CoreId) -> AccountId { @@ -324,6 +384,7 @@ pub fn run_to_block(n: u64) { OcifStaking::rewards(Balances::issue(ISSUE_PER_BLOCK)); OcifStaking::on_initialize(System::block_number()); + MessageQueue::on_initialize(System::block_number()); } } @@ -332,6 +393,7 @@ pub fn run_to_block_no_rewards(n: u64) { OcifStaking::on_finalize(System::block_number()); System::set_block_number(System::block_number() + 1); OcifStaking::on_initialize(System::block_number()); + MessageQueue::on_initialize(System::block_number()); } } @@ -363,6 +425,7 @@ pub fn initialize_first_block() { assert_eq!(System::block_number(), 1 as BlockNumber); OcifStaking::on_initialize(System::block_number()); + MessageQueue::on_initialize(System::block_number()); run_to_block(2); } diff --git a/OCIF/staking/src/testing/mod.rs b/OCIF/staking/src/testing/mod.rs index a8498e27..7d42b371 100644 --- a/OCIF/staking/src/testing/mod.rs +++ b/OCIF/staking/src/testing/mod.rs @@ -50,6 +50,19 @@ pub(crate) fn assert_register(core: mock::CoreId) { ); } +pub(crate) fn short_stake(staker: AccountId, core_id: &CoreId, value: Balance) { + assert_ok!(OcifStaking::stake( + RuntimeOrigin::signed(staker.clone()), + core_id.clone(), + value + )); + System::assert_last_event(mock::RuntimeEvent::OcifStaking(Event::Staked { + staker, + core: core_id.clone(), + amount: value, + })); +} + pub(crate) fn assert_stake(staker: AccountId, core: &CoreId, value: Balance) { let current_era = OcifStaking::current_era(); let init_state = MemorySnapshot::all(current_era, &core, staker.clone()); @@ -233,6 +246,15 @@ pub(crate) fn assert_unregister(core: CoreId) { core, })); + // println!("storage info{:#?}", MessageQueue::storage_info()); + // println!("get queue info{:#?}", MessageQueue::debug_info()); + // println!( + // "footprint: {:#?}", + // MessageQueue::footprint(UnregisterMessageOrigin) + // ); + run_for_blocks(1); + // println!("get queue info{:#?}", MessageQueue::debug_info()); + let final_reserved_balance = ::Currency::reserved_balance(&account(core)); assert_eq!( final_reserved_balance, diff --git a/OCIF/staking/src/testing/test.rs b/OCIF/staking/src/testing/test.rs index 1be46bf0..d6fa54bd 100644 --- a/OCIF/staking/src/testing/test.rs +++ b/OCIF/staking/src/testing/test.rs @@ -2317,3 +2317,62 @@ fn move_stake_max_number_of_stakers_exceeded_err() { ); }) } + +#[test] +fn claim_stake_after_unregistering_core_mid_era_changes_is_ok() { + ExternalityBuilder::build().execute_with(|| { + initialize_first_block(); + + let core_id_b = C; + + assert_register(core_id_b); + + let mut stakers: Vec = Vec::new(); + + for temp_staker in 0..4 { + let staker = account(temp_staker + 100); + stakers.push(staker.clone()); + Balances::resolve_creating(&staker, Balances::issue(1000)); + short_stake(staker, &core_id_b, 20); + } + + println!("finished stake preparation"); + + let era = OcifStaking::current_era(); + + let era_to_claim = era + 4; + + let block_at_era_to_claim = System::block_number(); + + advance_to_era(era_to_claim); + + run_to_block(block_at_era_to_claim + 2); + + assert!(era_to_claim == OcifStaking::current_era()); + + assert_unregister(core_id_b); + + System::reset_events(); + + for _ in 0..10 { + println!( + "***** running to block {:?} *****", + System::block_number() + 1 + ); + run_for_blocks(1); + } + + for _ in era..era_to_claim { + for staker in stakers.iter() { + assert_claim_staker(staker.clone(), core_id_b); + } + } + + println!("finished claiming"); + + assert_noop!( + OcifStaking::staker_claim_rewards(RuntimeOrigin::signed(stakers[0].clone()), core_id_b), + Error::::NoStakeAvailable + ); + }); +} From bcbef930ee8ef8d73bf73bd354b8f0b160476b39 Mon Sep 17 00:00:00 2001 From: Francisco Valentim Castilho Date: Fri, 7 Jun 2024 18:21:15 -0300 Subject: [PATCH 4/7] Feat: on-chain storage fee for operate_multisig --- INV4/pallet-inv4/src/lib.rs | 7 ++++++- INV4/pallet-inv4/src/multisig.rs | 20 ++++++++++++++++++-- INV4/pallet-inv4/src/tests/mock.rs | 17 +++++++++++++++++ OCIF/staking/src/lib.rs | 4 ++-- OCIF/staking/src/testing/mock.rs | 5 ++++- pallet-rings/src/tests/mock.rs | 5 +++++ 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/INV4/pallet-inv4/src/lib.rs b/INV4/pallet-inv4/src/lib.rs index a67f9704..1b72cd38 100644 --- a/INV4/pallet-inv4/src/lib.rs +++ b/INV4/pallet-inv4/src/lib.rs @@ -70,7 +70,9 @@ pub mod pallet { fungibles::{Balanced, Inspect}, Currency, Get, GetCallMetadata, ReservableCurrency, }, - transactional, Parameter, + transactional, + weights::WeightToFee, + Parameter, }; use frame_system::{pallet_prelude::*, RawOrigin}; use primitives::CoreInfo; @@ -172,6 +174,9 @@ pub mod pallet { /// Weight info for dispatchable calls type WeightInfo: WeightInfo; + + /// Weight to fee conversion provider, from pallet_transaction_payment + type LengthToFee: WeightToFee>; } /// The current storage version. diff --git a/INV4/pallet-inv4/src/multisig.rs b/INV4/pallet-inv4/src/multisig.rs index 1ef7d575..6689c5e9 100644 --- a/INV4/pallet-inv4/src/multisig.rs +++ b/INV4/pallet-inv4/src/multisig.rs @@ -13,7 +13,7 @@ use super::pallet::{self, *}; use crate::{ account_derivation::CoreAccountDerivation, - fee_handling::FeeAsset, + fee_handling::{FeeAsset, FeeAssetNegativeImbalance, MultisigFeeHandler}, origin::{ensure_multisig, INV4Origin}, voting::{Tally, Vote}, }; @@ -27,8 +27,9 @@ use frame_support::{ traits::{ fungibles::{Inspect, Mutate}, tokens::{Fortitude, Precision}, - Currency, VoteTally, + Currency, ExistenceRequirement, VoteTally, WithdrawReasons, }, + weights::WeightToFee, BoundedBTreeMap, }; use frame_system::{ensure_signed, pallet_prelude::*}; @@ -169,6 +170,21 @@ where .try_into() .map_err(|_| Error::::MaxCallLengthExceeded)?; + let total_lenght = (bounded_call.len() as u64) + .saturating_add(metadata.clone().unwrap_or_default().len() as u64); + + let storage_cost: BalanceOf = + T::LengthToFee::weight_to_fee(&Weight::from_parts(total_lenght as u64, 0)); + + T::FeeCharger::handle_creation_fee(FeeAssetNegativeImbalance::Native( + ::Currency::withdraw( + &owner, + storage_cost, + WithdrawReasons::TRANSACTION_PAYMENT, + ExistenceRequirement::KeepAlive, + )?, + )); + // Insert proposal in storage, it's now in the voting stage Multisig::::insert( core_id, diff --git a/INV4/pallet-inv4/src/tests/mock.rs b/INV4/pallet-inv4/src/tests/mock.rs index 4af34722..e391a184 100644 --- a/INV4/pallet-inv4/src/tests/mock.rs +++ b/INV4/pallet-inv4/src/tests/mock.rs @@ -7,6 +7,7 @@ use frame_support::{ fungibles::Credit, ConstU128, ConstU32, ConstU64, Contains, Currency, EnsureOrigin, EnsureOriginWithArg, }, + weights::ConstantMultiplier, }; use frame_system::EnsureRoot; use orml_asset_registry::AssetMetadata; @@ -87,6 +88,7 @@ impl pallet_balances::Config for Test { } const UNIT: u128 = 1000000000000; +const MICROUNIT: Balance = 1_000_000; pub struct CoreDustRemovalWhitelist; impl Contains for CoreDustRemovalWhitelist { @@ -208,6 +210,8 @@ parameter_types! { pub const MaxReserves: u32 = 1; pub const MaxCallSize: u32 = 50 * 1024; pub const StringLimit: u32 = 2125; + pub const TransactionByteFee: Balance = 10 * MICROUNIT; + } pub struct AssetAuthority; @@ -220,6 +224,18 @@ impl EnsureOriginWithArg> for AssetAuthority { ) -> Result { as EnsureOrigin>::try_origin(origin) } + + fn ensure_origin( + o: RuntimeOrigin, + a: &Option, + ) -> Result { + Self::try_origin(o, a).map_err(|_| sp_runtime::traits::BadOrigin) + } + + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin(_o: &Option) -> Result { + Err(()) + } } impl orml_asset_registry::Config for Test { @@ -340,6 +356,7 @@ impl pallet::Config for Test { type MaxCallSize = MaxCallSize; type ParaId = ConstU32<2125>; + type LengthToFee = ConstantMultiplier; } pub struct ExtBuilder; diff --git a/OCIF/staking/src/lib.rs b/OCIF/staking/src/lib.rs index c85f64e2..1046d094 100644 --- a/OCIF/staking/src/lib.rs +++ b/OCIF/staking/src/lib.rs @@ -565,7 +565,7 @@ pub mod pallet { let _total_stakers = _core_stake_info.number_of_stakers; let message = primitives::UnregisterMessage:: { - core_id: core_id.clone(), + core_id, era: current_era, stakers_to_unstake: _total_stakers, } @@ -1329,7 +1329,7 @@ pub mod pallet { let total_remaning_stakers = stakers.saturating_sub(chunk_size as u32); if total_remaning_stakers != 0 { let _call: Vec = primitives::UnregisterMessage:: { - core_id: core_id.clone(), + core_id, stakers_to_unstake: total_remaning_stakers, era: start_era, } diff --git a/OCIF/staking/src/testing/mock.rs b/OCIF/staking/src/testing/mock.rs index 3d9f6af8..98101c8b 100644 --- a/OCIF/staking/src/testing/mock.rs +++ b/OCIF/staking/src/testing/mock.rs @@ -10,7 +10,7 @@ use frame_support::{ }, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND}, - Weight, + ConstantMultiplier, Weight, }, PalletId, }; @@ -39,6 +39,7 @@ pub(crate) const UNBONDING_PERIOD: EraIndex = 3; pub(crate) const MAX_ERA_STAKE_VALUES: u32 = 8; pub(crate) const BLOCKS_PER_ERA: BlockNumber = 3; pub(crate) const REGISTER_DEPOSIT: Balance = 10; +const MICROUNIT: Balance = 1_000_000; construct_runtime!( pub struct Test { @@ -245,6 +246,7 @@ impl pallet_inv4::Config for Test { type MaxCallSize = ConstU32<51200>; type ParaId = ConstU32<2125>; + type LengthToFee = ConstantMultiplier; } impl pallet_ocif_staking::Config for Test { @@ -304,6 +306,7 @@ parameter_types! { pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block; pub const MessageQueueMaxStale: u32 = 8; pub const MessageQueueHeapSize: u32 = 128 * 1048; + pub const TransactionByteFee: Balance = 10 * MICROUNIT; } impl pallet_message_queue::Config for Test { diff --git a/pallet-rings/src/tests/mock.rs b/pallet-rings/src/tests/mock.rs index 4e75548c..b6ff8f31 100644 --- a/pallet-rings/src/tests/mock.rs +++ b/pallet-rings/src/tests/mock.rs @@ -10,6 +10,7 @@ use frame_support::{ fungibles::Credit, ConstU128, ConstU32, ConstU64, Contains, Currency, EnsureOrigin, EnsureOriginWithArg, Everything, Nothing, }, + weights::ConstantMultiplier, }; use frame_system::EnsureRoot; use orml_asset_registry::AssetMetadata; @@ -34,6 +35,8 @@ type Balance = u128; type AccountId = AccountId32; +const MICROUNIT: Balance = 1_000_000; + pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000; pub const ALICE: AccountId = AccountId32::new([ @@ -324,6 +327,7 @@ parameter_types! { pub const ExistentialDeposit: u128 = 100000000000; pub const MaxLocks: u32 = 1; pub const MaxReserves: u32 = 1; + pub const TransactionByteFee: Balance = 10 * MICROUNIT; } pub struct AssetAuthority; @@ -455,6 +459,7 @@ impl pallet_inv4::Config for Test { type MaxCallSize = ConstU32<51200>; type ParaId = ConstU32<2125>; + type LengthToFee = ConstantMultiplier; } parameter_types! { From bbf5a7e5c8485590e85f41ae57aa2220893202e9 Mon Sep 17 00:00:00 2001 From: Francisco Valentim Castilho Date: Mon, 10 Jun 2024 15:31:59 -0300 Subject: [PATCH 5/7] Feat: Custom implementation of traits required when implementing pallet_message_queue on the runtime --- OCIF/staking/Cargo.toml | 2 +- OCIF/staking/src/lib.rs | 25 ++-- OCIF/staking/src/primitives.rs | 195 ++++++++++++++++++++----------- OCIF/staking/src/testing/mock.rs | 16 ++- 4 files changed, 151 insertions(+), 87 deletions(-) diff --git a/OCIF/staking/Cargo.toml b/OCIF/staking/Cargo.toml index 3444d6ea..4ad92454 100644 --- a/OCIF/staking/Cargo.toml +++ b/OCIF/staking/Cargo.toml @@ -33,9 +33,9 @@ sp-std = { workspace = true, default-features = false } pallet-inv4 = { path = "../../INV4/pallet-inv4", default-features = false } frame-benchmarking = { workspace = true, default-features = false, optional = true } +cumulus-primitives-core = { workspace = true, default-features = false } [dev-dependencies] -cumulus-primitives-core = { workspace = true, default-features = false } orml-traits = { workspace = true, default-features = false } orml-tokens = { workspace = true, default-features = false } xcm = { workspace = true, default-features = false } diff --git a/OCIF/staking/src/lib.rs b/OCIF/staking/src/lib.rs index 1046d094..0c14a040 100644 --- a/OCIF/staking/src/lib.rs +++ b/OCIF/staking/src/lib.rs @@ -55,8 +55,8 @@ use frame_support::{ ensure, pallet_prelude::*, traits::{ - Currency, EnqueueMessage, ExistenceRequirement, Get, Imbalance, LockIdentifier, - LockableCurrency, QueuePausedQuery, ReservableCurrency, WithdrawReasons, + Currency, ExistenceRequirement, Get, HandleMessage, Imbalance, LockIdentifier, + LockableCurrency, ProcessMessage, QueuePausedQuery, ReservableCurrency, WithdrawReasons, }, weights::Weight, BoundedSlice, PalletId, @@ -213,7 +213,7 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; - type StakingMessage: EnqueueMessage; + type StakingMessage: HandleMessage; } /// General information about the staker. @@ -530,9 +530,6 @@ pub mod pallet { ::MaxStakersPerCore::get().div(100) * ::WeightInfo::unstake() )] pub fn unregister_core(origin: OriginFor) -> DispatchResultWithPostInfo { - // whats left to do is copy the storage to a temp storage for the unregistering - // set the stake info to zero. - // create the call to unregister parts, integrate pallet_messages. Self::ensure_not_halted()?; let core = ensure_multisig::>(origin.clone())?; @@ -571,10 +568,7 @@ pub mod pallet { } .encode(); - T::StakingMessage::enqueue_message( - BoundedSlice::truncate_from(message.as_slice()), - UnregisterMessageOrigin {}, - ); + T::StakingMessage::handle_message(BoundedSlice::truncate_from(message.as_slice())); Self::deposit_event(Event::::CoreUnregistrationQueueStarted { core: core_id }); @@ -1328,17 +1322,15 @@ pub mod pallet { let total_remaning_stakers = stakers.saturating_sub(chunk_size as u32); if total_remaning_stakers != 0 { - let _call: Vec = primitives::UnregisterMessage:: { + let message: Vec = primitives::UnregisterMessage:: { core_id, stakers_to_unstake: total_remaning_stakers, era: start_era, } .encode(); - T::StakingMessage::enqueue_message( - BoundedSlice::truncate_from(_call.as_slice()), - UnregisterMessageOrigin {}, - ); + T::StakingMessage::handle_message(BoundedSlice::truncate_from(message.as_slice())); + Self::deposit_event(Event::::CoreUnregistrationChunksProcessed { core: core_id, accounts_processed_in_this_chunk: chunk_size.min(stakers.into()), @@ -1358,3 +1350,6 @@ impl QueuePausedQuery for Pallet { Pallet::::is_halted() } } + +pub type MessageOriginOf = + <::MessageProcessor as ProcessMessage>::Origin; diff --git a/OCIF/staking/src/primitives.rs b/OCIF/staking/src/primitives.rs index 25324458..ca883046 100644 --- a/OCIF/staking/src/primitives.rs +++ b/OCIF/staking/src/primitives.rs @@ -20,6 +20,7 @@ //! - `AccountLedger` - A struct that holds information about an account's locked balance and unbonding information. use codec::{Decode, Encode, FullCodec, HasCompact, MaxEncodedLen}; +use cumulus_primitives_core::{AggregateMessageOrigin, MultiLocation, ParaId}; use frame_support::{ pallet_prelude::Weight, traits::{Currency, ProcessMessage, QueueFootprint, QueuePausedQuery}, @@ -323,30 +324,74 @@ impl AccountLedg } #[derive(Encode, Decode, MaxEncodedLen, Clone, Eq, PartialEq, TypeInfo, Debug)] -pub struct UnregisterMessageOrigin; +pub enum CustomAggregateMessageOrigin { + Aggregate(XcmOrigin), + UnregisterMessageOrigin, +} -impl QueuePausedQuery for UnregisterMessageOrigin { - fn is_paused(_origin: &O) -> bool { - false +/// Custom Convert a sibling `ParaId` to an `AggregateMessageOrigin`. +pub struct CustomParaIdToSibling; +impl sp_runtime::traits::Convert> + for CustomParaIdToSibling +{ + fn convert(para_id: ParaId) -> CustomAggregateMessageOrigin { + CustomAggregateMessageOrigin::Aggregate(AggregateMessageOrigin::Sibling(para_id)) } } -impl OnQueueChanged for UnregisterMessageOrigin { - fn on_queue_changed(_origin: O, fp: QueueFootprint) { - println!("on queue changed {:#?}", fp); +pub struct CustomNarrowOriginToSibling(PhantomData<(Inner, T)>); +impl, T: Config> + QueuePausedQuery> + for CustomNarrowOriginToSibling +{ + fn is_paused(origin: &CustomAggregateMessageOrigin) -> bool { + match origin { + CustomAggregateMessageOrigin::Aggregate(AggregateMessageOrigin::Sibling(id)) => { + Inner::is_paused(id) + } + CustomAggregateMessageOrigin::Aggregate(_) => false, + CustomAggregateMessageOrigin::UnregisterMessageOrigin => Pallet::::is_halted(), + } } } -#[derive(Clone, PartialEq, Eq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct UnregisterMessage { - pub(crate) core_id: T::CoreId, - pub(crate) era: Era, - pub(crate) stakers_to_unstake: u32, +impl, T: Config> + OnQueueChanged> + for CustomNarrowOriginToSibling +{ + fn on_queue_changed( + origin: CustomAggregateMessageOrigin, + fp: QueueFootprint, + ) { + match origin { + CustomAggregateMessageOrigin::Aggregate(AggregateMessageOrigin::Sibling(id)) => { + Inner::on_queue_changed(id, fp) + } + CustomAggregateMessageOrigin::Aggregate(_) => (), + CustomAggregateMessageOrigin::UnregisterMessageOrigin => (), + } + } } -pub struct ProcessUnregistrationMessages(PhantomData<(Origin, T)>); -impl - ProcessMessage for ProcessUnregistrationMessages +pub struct CustomMessageProcessor( + PhantomData<(Origin, XcmOrigin, XcmProcessor, C, T)>, +); + +impl ProcessMessage + for CustomMessageProcessor +where + Origin: Into> + + FullCodec + + MaxEncodedLen + + Clone + + Eq + + PartialEq + + TypeInfo + + Debug, + XcmOrigin: + Into + FullCodec + MaxEncodedLen + Clone + Eq + PartialEq + TypeInfo + Debug, + XcmProcessor: ProcessMessage, + T: Config, { type Origin = Origin; fn process_message( @@ -355,67 +400,83 @@ impl Result { - let call: UnregisterMessage = UnregisterMessage::::decode(&mut &message[..]) - .map_err(|_| frame_support::traits::ProcessMessageError::Corrupt)?; + match _origin.into() { + CustomAggregateMessageOrigin::Aggregate(o) => { + XcmProcessor::process_message(message, o, meter, _id) + } + CustomAggregateMessageOrigin::UnregisterMessageOrigin => { + let call: UnregisterMessage = UnregisterMessage::::decode(&mut &message[..]) + .map_err(|_| frame_support::traits::ProcessMessageError::Corrupt)?; - let unstake_weight = ::WeightInfo::unstake(); + let unstake_weight = ::WeightInfo::unstake(); - let meter_limit = meter.limit(); + let meter_limit = meter.limit(); - let thirdy_of_limit = Perbill::from_percent(30) * meter_limit; + let thirdy_of_limit = Perbill::from_percent(30) * meter_limit; - let meter_remaining = meter.remaining(); + let meter_remaining = meter.remaining(); - let min_desired = { - // if a third of the proofsize is > 1/2 MB then we use a 1/2 MB for the proofsize weight. - if thirdy_of_limit.proof_size() >= 524288 { - Weight::from_parts(thirdy_of_limit.ref_time(), 524288) - } else { - thirdy_of_limit - } - }; + let min_desired = { + // if a third of the proofsize is > 1/2 MB then we use a 1/2 MB for the proofsize weight. + if thirdy_of_limit.proof_size() >= 524288 { + Weight::from_parts(thirdy_of_limit.ref_time(), 524288) + } else { + thirdy_of_limit + } + }; - // only use less than 30% of all the weight the message queue can provide. - if !meter_remaining.all_gte(Perbill::from_percent(70) * meter_limit) { - return Err(frame_support::traits::ProcessMessageError::Yield); - } + // only use less than 30% of all the weight the message queue can provide. + if !meter_remaining.all_gte(Perbill::from_percent(70) * meter_limit) { + return Err(frame_support::traits::ProcessMessageError::Yield); + } - let max_calls = { - match min_desired.checked_div_per_component(&unstake_weight) { - Some(x) if x > 0 => x.min(100), - _ => return Err(frame_support::traits::ProcessMessageError::Yield), - } - }; - - let max_weight = max_calls * unstake_weight; - - let chunk_result = crate::pallet::Pallet::::process_core_unregistration_shard( - call.stakers_to_unstake, - call.core_id, - call.era, - max_calls, - ); - - match chunk_result { - Ok(weight) => { - if let Some(actual_weight) = weight.actual_weight { - meter.try_consume(actual_weight).map_err(|_| { - frame_support::traits::ProcessMessageError::Overweight(actual_weight) - })?; - } else { - meter.try_consume(max_weight).map_err(|_| { - frame_support::traits::ProcessMessageError::Overweight(max_weight) - })?; + let max_calls = { + match min_desired.checked_div_per_component(&unstake_weight) { + Some(x) if x > 0 => x.min(100), + _ => return Err(frame_support::traits::ProcessMessageError::Yield), + } + }; + + let max_weight = max_calls * unstake_weight; + + let chunk_result = crate::pallet::Pallet::::process_core_unregistration_shard( + call.stakers_to_unstake, + call.core_id, + call.era, + max_calls, + ); + + match chunk_result { + Ok(weight) => { + if let Some(actual_weight) = weight.actual_weight { + meter.try_consume(actual_weight).map_err(|_| { + frame_support::traits::ProcessMessageError::Overweight( + actual_weight, + ) + })?; + } else { + meter.try_consume(max_weight).map_err(|_| { + frame_support::traits::ProcessMessageError::Overweight(max_weight) + })?; + } + Ok(true) + } + Err(_) => { + println!("error"); + meter.try_consume(max_weight).map_err(|_| { + frame_support::traits::ProcessMessageError::Overweight(max_weight) + })?; + Ok(false) + } } - Ok(true) - } - Err(_) => { - println!("error"); - meter.try_consume(max_weight).map_err(|_| { - frame_support::traits::ProcessMessageError::Overweight(max_weight) - })?; - Ok(false) } } } } + +#[derive(Clone, PartialEq, Eq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen)] +pub struct UnregisterMessage { + pub(crate) core_id: T::CoreId, + pub(crate) era: Era, + pub(crate) stakers_to_unstake: u32, +} diff --git a/OCIF/staking/src/testing/mock.rs b/OCIF/staking/src/testing/mock.rs index 98101c8b..0021adf3 100644 --- a/OCIF/staking/src/testing/mock.rs +++ b/OCIF/staking/src/testing/mock.rs @@ -1,6 +1,7 @@ -use crate::{self as pallet_ocif_staking, ProcessUnregistrationMessages, UnregisterMessageOrigin}; +use crate::{self as pallet_ocif_staking, CustomAggregateMessageOrigin, CustomMessageProcessor}; use codec::{Decode, Encode}; use core::convert::{TryFrom, TryInto}; +use cumulus_primitives_core::AggregateMessageOrigin; use frame_support::{ construct_runtime, derive_impl, dispatch::DispatchClass, @@ -142,6 +143,7 @@ parameter_types! { 243, 115, 218, 162, 0, 9, 138, 232, 68, 55, 129, 106, 210, ]); pub const RelayAssetId: u32 = 9999; + pub const UnregisterOrigin: CustomAggregateMessageOrigin = CustomAggregateMessageOrigin::UnregisterMessageOrigin; } #[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo, Debug)] @@ -267,7 +269,7 @@ impl pallet_ocif_staking::Config for Test { type RewardRatio = RewardRatio; type StakeThresholdForActiveCore = ConstU128; type WeightInfo = crate::weights::SubstrateWeight; - type StakingMessage = MessageQueue; + type StakingMessage = frame_support::traits::EnqueueWithOrigin; } /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by @@ -315,10 +317,16 @@ impl pallet_message_queue::Config for Test { #[cfg(feature = "runtime-benchmarks")] type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<()>; #[cfg(not(feature = "runtime-benchmarks"))] - type MessageProcessor = ProcessUnregistrationMessages; + type MessageProcessor = CustomMessageProcessor< + CustomAggregateMessageOrigin, + AggregateMessageOrigin, + pallet_message_queue::mock_helpers::NoopMessageProcessor, + RuntimeCall, + Test, + >; type Size = u32; type QueueChangeHandler = (); - type QueuePausedQuery = UnregisterMessageOrigin; + type QueuePausedQuery = (); type HeapSize = MessageQueueHeapSize; type MaxStale = MessageQueueMaxStale; type ServiceWeight = MessageQueueServiceWeight; From 2ea6d9dbc46ef66467709d4619507ebe1240095a Mon Sep 17 00:00:00 2001 From: Francisco Valentim Castilho Date: Tue, 18 Jun 2024 01:36:43 -0300 Subject: [PATCH 6/7] Fix: corredted bad loop in `process_core_unregistration_shard` + charging unstake fees upfront from the core on unregistration. --- INV4/pallet-inv4/src/lib.rs | 2 +- OCIF/staking/src/lib.rs | 187 ++++++++++++++++++------------- OCIF/staking/src/primitives.rs | 1 - OCIF/staking/src/testing/mock.rs | 7 +- 4 files changed, 116 insertions(+), 81 deletions(-) diff --git a/INV4/pallet-inv4/src/lib.rs b/INV4/pallet-inv4/src/lib.rs index 1b72cd38..bdb74eb2 100644 --- a/INV4/pallet-inv4/src/lib.rs +++ b/INV4/pallet-inv4/src/lib.rs @@ -175,7 +175,7 @@ pub mod pallet { /// Weight info for dispatchable calls type WeightInfo: WeightInfo; - /// Weight to fee conversion provider, from pallet_transaction_payment + /// Byte to fee conversion provider, from pallet_transaction_payment. type LengthToFee: WeightToFee>; } diff --git a/OCIF/staking/src/lib.rs b/OCIF/staking/src/lib.rs index 0c14a040..bb713868 100644 --- a/OCIF/staking/src/lib.rs +++ b/OCIF/staking/src/lib.rs @@ -56,9 +56,10 @@ use frame_support::{ pallet_prelude::*, traits::{ Currency, ExistenceRequirement, Get, HandleMessage, Imbalance, LockIdentifier, - LockableCurrency, ProcessMessage, QueuePausedQuery, ReservableCurrency, WithdrawReasons, + LockableCurrency, OnUnbalanced, ProcessMessage, QueuePausedQuery, ReservableCurrency, + WithdrawReasons, }, - weights::Weight, + weights::{Weight, WeightToFee}, BoundedSlice, PalletId, }; use frame_system::{ensure_signed, pallet_prelude::*}; @@ -72,7 +73,6 @@ use sp_std::{ }; pub mod primitives; -use core::ops::Div; use primitives::*; #[cfg(feature = "runtime-benchmarks")] @@ -213,7 +213,14 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; + /// Message queue interface. type StakingMessage: HandleMessage; + + /// Weight to fee conversion provider, from pallet_transaction_payment. + type WeightToFee: WeightToFee>; + + /// Fee charghing interface. + type OnUnbalanced: OnUnbalanced>; } /// General information about the staker. @@ -278,12 +285,23 @@ pub mod pallet { #[pallet::getter(fn is_halted)] pub type Halted = StorageValue<_, bool, ValueQuery>; - /// Placeholder for the core being unregistered and the era where it started. + /// Placeholder for the core being unregistered and its stake info. #[pallet::storage] #[pallet::getter(fn core_unregistering_staker_info)] pub type UnregisteredCoreStakeInfo = StorageMap<_, Blake2_128Concat, T::CoreId, CoreStakeInfo>, OptionQuery>; + /// Placeholder for the core being unregistered and its stakers. + #[pallet::storage] + #[pallet::getter(fn core_unregistering_staker_list)] + pub type UnregisteredCoreStakers = StorageMap< + _, + Blake2_128Concat, + T::CoreId, + BoundedVec, + OptionQuery, + >; + #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] pub enum Event { @@ -413,10 +431,6 @@ pub mod pallet { NoHaltChange, /// Attempted to move stake to the same core. MoveStakeToSameCore, - /// No weight configured for unregistering. - NoWeightConfiguredForUnregistering, - /// Queue is full. - UnregisteringQueueFull, } #[pallet::hooks] @@ -526,8 +540,7 @@ pub mod pallet { /// - `core_id`: Id of the core to be unregistered. #[pallet::call_index(1)] #[pallet::weight( - ::WeightInfo::unregister_core() + - ::MaxStakersPerCore::get().div(100) * ::WeightInfo::unstake() + ::WeightInfo::unregister_core() )] pub fn unregister_core(origin: OriginFor) -> DispatchResultWithPostInfo { Self::ensure_not_halted()?; @@ -543,28 +556,46 @@ pub mod pallet { let current_era = Self::current_era(); - let mut _core_stake_info = + let all_stakers: BoundedVec = + BoundedVec::truncate_from( + GeneralStakerInfo::::iter_key_prefix(core_id).collect::>(), + ); + + let all_fee = ::WeightToFee::weight_to_fee( + &(all_stakers.len() as u32 * ::WeightInfo::unstake()), + ); + + UnregisteredCoreStakers::::insert(core_id, all_stakers); + + let mut core_stake_info = Self::core_stake_info(core_id, current_era).unwrap_or_default(); - UnregisteredCoreStakeInfo::::insert(core_id, _core_stake_info.clone()); + UnregisteredCoreStakeInfo::::insert(core_id, core_stake_info.clone()); GeneralEraInfo::::mutate(current_era, |value| { if let Some(x) = value { - x.staked = x.staked.saturating_sub(_core_stake_info.total); + x.staked = x.staked.saturating_sub(core_stake_info.total); } }); - _core_stake_info.total = Zero::zero(); - CoreEraStake::::insert(core_id, current_era, _core_stake_info.clone()); + core_stake_info.total = Zero::zero(); + CoreEraStake::::insert(core_id, current_era, core_stake_info.clone()); - let mut _corrected_staker_length_fee = Zero::zero(); + let reserve_deposit = T::RegisterDeposit::get(); + ::Currency::unreserve(&core_account, reserve_deposit); + + T::OnUnbalanced::on_unbalanced(::Currency::withdraw( + &core_account, + reserve_deposit.min(all_fee), + WithdrawReasons::TRANSACTION_PAYMENT, + ExistenceRequirement::KeepAlive, + )?); RegisteredCore::::remove(core_id); - ::Currency::unreserve(&core_account, T::RegisterDeposit::get()); - let _total_stakers = _core_stake_info.number_of_stakers; + let total_stakers = core_stake_info.number_of_stakers; let message = primitives::UnregisterMessage:: { core_id, era: current_era, - stakers_to_unstake: _total_stakers, + stakers_to_unstake: total_stakers, } .encode(); @@ -574,10 +605,7 @@ pub mod pallet { Self::deposit_event(Event::::CoreUnregistered { core: core_id }); - Ok( - Some(::WeightInfo::unregister_core() + _corrected_staker_length_fee) - .into(), - ) + Ok(Some(::WeightInfo::unregister_core()).into()) } /// Used to change the metadata of a core. @@ -830,21 +858,8 @@ pub mod pallet { let current_era = Self::current_era(); ensure!(era < current_era, Error::::IncorrectEra); - // // Check if the ensure staking_info.total > Zero::zero(), is a good way to avoid this extra read. - // if let Some(unregister_era) = Self::is_core_unregistering(core_id) { - // ensure!(era < unregister_era, Error::::NoStakeAvailable); - // } let staking_info = Self::core_stake_info(core_id, era).unwrap_or_default(); - // // Just in case the core is being unregistered and the staker was not unstaked yet. - // // Erroring here may require the front end to handle the case where the user is trying to claim rewards - // // before the core is unregistered. - // // I'll write another option for avoiding this error down here. - // ensure!( - // staking_info.total > Zero::zero(), - // Error::::NoStakeAvailable - // ); - let mut staker_reward = Zero::zero(); if staking_info.total > Zero::zero() { @@ -1278,68 +1293,84 @@ pub mod pallet { start_era: Era, chunk_size: u64, ) -> DispatchResultWithPostInfo { - let staker_info_prefix = GeneralStakerInfo::::iter_key_prefix(core_id); + let mut staker_info_prefix = + Self::core_unregistering_staker_list(core_id).unwrap_or_default(); let mut corrected_staker_length_fee = Zero::zero(); - for staker in staker_info_prefix.take(chunk_size as usize) { - let mut core_stake_info = - Self::core_unregistering_staker_info(core_id).unwrap_or_default(); + let mut core_stake_info = + Self::core_unregistering_staker_info(core_id).unwrap_or_default(); + let mut unsteked_count: u64 = 0; + while let Some(staker) = staker_info_prefix.pop() { let mut staker_info = Self::staker_info(core_id, &staker); let latest_staked_value = staker_info.latest_staked_value(); - let value_to_unstake = Self::internal_unstake( + if let Ok(value_to_unstake) = Self::internal_unstake( &mut staker_info, &mut core_stake_info, latest_staked_value, start_era, - )?; + ) { + UnregisteredCoreStakeInfo::::insert(core_id, core_stake_info.clone()); + let mut ledger = Self::ledger(&staker); + ledger.unbonding_info.add(UnlockingChunk { + amount: value_to_unstake, + unlock_era: start_era + T::UnbondingPeriod::get(), + }); + + ensure!( + ledger.unbonding_info.len() <= T::MaxUnlocking::get(), + Error::::TooManyUnlockingChunks + ); + + Self::update_ledger(&staker, ledger); + + Self::update_staker_info(&staker, core_id, staker_info); + + Self::deposit_event(Event::::Unstaked { + staker: staker.clone(), + core: core_id, + amount: value_to_unstake, + }); + corrected_staker_length_fee += ::WeightInfo::unstake(); + } else { + // if the staker has moved or already unstaked `internal_unstake` will do one read and return err. + corrected_staker_length_fee += T::DbWeight::get().reads(1); + } - let mut ledger = Self::ledger(&staker); - ledger.unbonding_info.add(UnlockingChunk { - amount: value_to_unstake, - unlock_era: start_era + T::UnbondingPeriod::get(), - }); + unsteked_count += 1; - ensure!( - ledger.unbonding_info.len() <= T::MaxUnlocking::get(), - Error::::TooManyUnlockingChunks - ); - - Self::update_ledger(&staker, ledger); + if unsteked_count >= chunk_size { + let total_remaning_stakers = stakers.saturating_sub(unsteked_count as u32); + let message: Vec = primitives::UnregisterMessage:: { + core_id, + stakers_to_unstake: total_remaning_stakers, + era: start_era, + } + .encode(); - Self::update_staker_info(&staker, core_id, staker_info); + T::StakingMessage::handle_message(BoundedSlice::truncate_from( + message.as_slice(), + )); - Self::deposit_event(Event::::Unstaked { - staker, - core: core_id, - amount: value_to_unstake, - }); - corrected_staker_length_fee += ::WeightInfo::unstake(); - } + Self::deposit_event(Event::::CoreUnregistrationChunksProcessed { + core: core_id, + accounts_processed_in_this_chunk: unsteked_count, + accounts_left: total_remaning_stakers as u64, + }); + UnregisteredCoreStakeInfo::::insert(core_id, core_stake_info.clone()); + UnregisteredCoreStakers::::insert(core_id, staker_info_prefix); - let total_remaning_stakers = stakers.saturating_sub(chunk_size as u32); - if total_remaning_stakers != 0 { - let message: Vec = primitives::UnregisterMessage:: { - core_id, - stakers_to_unstake: total_remaning_stakers, - era: start_era, + return Ok(Some(corrected_staker_length_fee).into()); } - .encode(); - - T::StakingMessage::handle_message(BoundedSlice::truncate_from(message.as_slice())); - - Self::deposit_event(Event::::CoreUnregistrationChunksProcessed { - core: core_id, - accounts_processed_in_this_chunk: chunk_size.min(stakers.into()), - accounts_left: total_remaning_stakers as u64, - }); - } else { - Self::deposit_event(Event::::CoreUnregistrationQueueFinished { core: core_id }); } + Self::deposit_event(Event::::CoreUnregistrationQueueFinished { core: core_id }); + UnregisteredCoreStakers::::remove(core_id); + UnregisteredCoreStakeInfo::::remove(core_id); + Ok(Some(corrected_staker_length_fee).into()) } } diff --git a/OCIF/staking/src/primitives.rs b/OCIF/staking/src/primitives.rs index ca883046..d71def87 100644 --- a/OCIF/staking/src/primitives.rs +++ b/OCIF/staking/src/primitives.rs @@ -462,7 +462,6 @@ where Ok(true) } Err(_) => { - println!("error"); meter.try_consume(max_weight).map_err(|_| { frame_support::traits::ProcessMessageError::Overweight(max_weight) })?; diff --git a/OCIF/staking/src/testing/mock.rs b/OCIF/staking/src/testing/mock.rs index 0021adf3..20b33b60 100644 --- a/OCIF/staking/src/testing/mock.rs +++ b/OCIF/staking/src/testing/mock.rs @@ -270,6 +270,8 @@ impl pallet_ocif_staking::Config for Test { type StakeThresholdForActiveCore = ConstU128; type WeightInfo = crate::weights::SubstrateWeight; type StakingMessage = frame_support::traits::EnqueueWithOrigin; + type WeightToFee = ConstantMultiplier; + type OnUnbalanced = (); } /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by @@ -309,13 +311,16 @@ parameter_types! { pub const MessageQueueMaxStale: u32 = 8; pub const MessageQueueHeapSize: u32 = 128 * 1048; pub const TransactionByteFee: Balance = 10 * MICROUNIT; + pub const ZeroFee: Balance = 0; } impl pallet_message_queue::Config for Test { type RuntimeEvent = RuntimeEvent; type WeightInfo = pallet_message_queue::weights::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] - type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<()>; + type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor< + CustomAggregateMessageOrigin, + >; #[cfg(not(feature = "runtime-benchmarks"))] type MessageProcessor = CustomMessageProcessor< CustomAggregateMessageOrigin, From c7bd7bb82384fcd4cd75d4030dfc0c637dd6f58a Mon Sep 17 00:00:00 2001 From: Francisco Valentim Castilho Date: Tue, 18 Jun 2024 01:55:38 -0300 Subject: [PATCH 7/7] Fix: corrected weight for `unregister_core` --- OCIF/staking/src/weights.rs | 130 +++++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 55 deletions(-) diff --git a/OCIF/staking/src/weights.rs b/OCIF/staking/src/weights.rs index 28e48e00..21106a88 100644 --- a/OCIF/staking/src/weights.rs +++ b/OCIF/staking/src/weights.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_ocif_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-05-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-18, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `anny.local`, CPU: `` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` @@ -58,16 +58,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 20]`. /// The range of component `d` is `[0, 300]`. /// The range of component `i` is `[0, 100]`. - fn register_core(_n: u32, d: u32, i: u32, ) -> Weight { + fn register_core(_n: u32, _d: u32, _i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `213` // Estimated: `3942` // Minimum execution time: 22_000_000 picoseconds. - Weight::from_parts(23_127_348, 3942) - // Standard Error: 152 - .saturating_add(Weight::from_parts(526, 0).saturating_mul(d.into())) - // Standard Error: 456 - .saturating_add(Weight::from_parts(395, 0).saturating_mul(i.into())) + Weight::from_parts(24_293_021, 3942) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -83,13 +79,13 @@ impl WeightInfo for SubstrateWeight { // Measured: `86` // Estimated: `3942` // Minimum execution time: 9_000_000 picoseconds. - Weight::from_parts(9_729_396, 3942) - // Standard Error: 1_581 - .saturating_add(Weight::from_parts(5_533, 0).saturating_mul(n.into())) - // Standard Error: 108 - .saturating_add(Weight::from_parts(788, 0).saturating_mul(d.into())) - // Standard Error: 324 - .saturating_add(Weight::from_parts(947, 0).saturating_mul(i.into())) + Weight::from_parts(9_593_278, 3942) + // Standard Error: 890 + .saturating_add(Weight::from_parts(4_471, 0).saturating_mul(n.into())) + // Standard Error: 61 + .saturating_add(Weight::from_parts(856, 0).saturating_mul(d.into())) + // Standard Error: 182 + .saturating_add(Weight::from_parts(1_028, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -103,16 +99,30 @@ impl WeightInfo for SubstrateWeight { /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `OcifStaking::GeneralStakerInfo` (r:1 w:0) /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:1 w:1) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `MessageQueue::BookStateFor` (r:1 w:1) + /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`) + /// Storage: `MessageQueue::ServiceHead` (r:1 w:1) + /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(6), added: 501, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::UnregisteredCoreStakeInfo` (r:0 w:1) + /// Proof: `OcifStaking::UnregisteredCoreStakeInfo` (`max_values`: None, `max_size`: Some(42), added: 2517, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::UnregisteredCoreStakers` (r:0 w:1) + /// Proof: `OcifStaking::UnregisteredCoreStakers` (`max_values`: None, `max_size`: Some(320022), added: 322497, mode: `MaxEncodedLen`) + /// Storage: `MessageQueue::Pages` (r:0 w:1) + /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134194), added: 136669, mode: `MaxEncodedLen`) fn unregister_core() -> Weight { // Proof Size summary in bytes: - // Measured: `337` + // Measured: `343` // Estimated: `3942` - // Minimum execution time: 27_000_000 picoseconds. - Weight::from_parts(28_000_000, 3942) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Minimum execution time: 44_000_000 picoseconds. + Weight::from_parts(45_000_000, 3942) + .saturating_add(T::DbWeight::get().reads(10_u64)) + .saturating_add(T::DbWeight::get().writes(9_u64)) } /// Storage: `OcifStaking::Halted` (r:1 w:0) /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) @@ -163,8 +173,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `397` // Estimated: `4764` - // Minimum execution time: 35_000_000 picoseconds. - Weight::from_parts(36_000_000, 4764) + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(37_000_000, 4764) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -184,8 +194,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `449` // Estimated: `4764` - // Minimum execution time: 32_000_000 picoseconds. - Weight::from_parts(34_000_000, 4764) + // Minimum execution time: 31_000_000 picoseconds. + Weight::from_parts(32_000_000, 4764) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -203,8 +213,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `374` // Estimated: `3734` - // Minimum execution time: 19_000_000 picoseconds. - Weight::from_parts(20_000_000, 3734) + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 3734) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -234,7 +244,7 @@ impl WeightInfo for SubstrateWeight { // Measured: `4` // Estimated: `1486` // Minimum execution time: 5_000_000 picoseconds. - Weight::from_parts(6_000_000, 1486) + Weight::from_parts(5_000_000, 1486) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -252,8 +262,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `302` // Estimated: `6478` - // Minimum execution time: 25_000_000 picoseconds. - Weight::from_parts(26_000_000, 6478) + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(25_000_000, 6478) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -272,16 +282,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 20]`. /// The range of component `d` is `[0, 300]`. /// The range of component `i` is `[0, 100]`. - fn register_core(_n: u32, d: u32, i: u32, ) -> Weight { + fn register_core(_n: u32, _d: u32, _i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `213` // Estimated: `3942` // Minimum execution time: 22_000_000 picoseconds. - Weight::from_parts(23_127_348, 3942) - // Standard Error: 152 - .saturating_add(Weight::from_parts(526, 0).saturating_mul(d.into())) - // Standard Error: 456 - .saturating_add(Weight::from_parts(395, 0).saturating_mul(i.into())) + Weight::from_parts(24_293_021, 3942) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -297,13 +303,13 @@ impl WeightInfo for () { // Measured: `86` // Estimated: `3942` // Minimum execution time: 9_000_000 picoseconds. - Weight::from_parts(9_729_396, 3942) - // Standard Error: 1_581 - .saturating_add(Weight::from_parts(5_533, 0).saturating_mul(n.into())) - // Standard Error: 108 - .saturating_add(Weight::from_parts(788, 0).saturating_mul(d.into())) - // Standard Error: 324 - .saturating_add(Weight::from_parts(947, 0).saturating_mul(i.into())) + Weight::from_parts(9_593_278, 3942) + // Standard Error: 890 + .saturating_add(Weight::from_parts(4_471, 0).saturating_mul(n.into())) + // Standard Error: 61 + .saturating_add(Weight::from_parts(856, 0).saturating_mul(d.into())) + // Standard Error: 182 + .saturating_add(Weight::from_parts(1_028, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -317,16 +323,30 @@ impl WeightInfo for () { /// Proof: `OcifStaking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `OcifStaking::GeneralStakerInfo` (r:1 w:0) /// Proof: `OcifStaking::GeneralStakerInfo` (`max_values`: None, `max_size`: Some(269), added: 2744, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::CoreEraStake` (r:1 w:1) + /// Proof: `OcifStaking::CoreEraStake` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::GeneralEraInfo` (r:1 w:1) + /// Proof: `OcifStaking::GeneralEraInfo` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `MessageQueue::BookStateFor` (r:1 w:1) + /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`) + /// Storage: `MessageQueue::ServiceHead` (r:1 w:1) + /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(6), added: 501, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::UnregisteredCoreStakeInfo` (r:0 w:1) + /// Proof: `OcifStaking::UnregisteredCoreStakeInfo` (`max_values`: None, `max_size`: Some(42), added: 2517, mode: `MaxEncodedLen`) + /// Storage: `OcifStaking::UnregisteredCoreStakers` (r:0 w:1) + /// Proof: `OcifStaking::UnregisteredCoreStakers` (`max_values`: None, `max_size`: Some(320022), added: 322497, mode: `MaxEncodedLen`) + /// Storage: `MessageQueue::Pages` (r:0 w:1) + /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134194), added: 136669, mode: `MaxEncodedLen`) fn unregister_core() -> Weight { // Proof Size summary in bytes: - // Measured: `337` + // Measured: `343` // Estimated: `3942` - // Minimum execution time: 27_000_000 picoseconds. - Weight::from_parts(28_000_000, 3942) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + // Minimum execution time: 44_000_000 picoseconds. + Weight::from_parts(45_000_000, 3942) + .saturating_add(RocksDbWeight::get().reads(10_u64)) + .saturating_add(RocksDbWeight::get().writes(9_u64)) } /// Storage: `OcifStaking::Halted` (r:1 w:0) /// Proof: `OcifStaking::Halted` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) @@ -377,8 +397,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `397` // Estimated: `4764` - // Minimum execution time: 35_000_000 picoseconds. - Weight::from_parts(36_000_000, 4764) + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(37_000_000, 4764) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -398,8 +418,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `449` // Estimated: `4764` - // Minimum execution time: 32_000_000 picoseconds. - Weight::from_parts(34_000_000, 4764) + // Minimum execution time: 31_000_000 picoseconds. + Weight::from_parts(32_000_000, 4764) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -417,8 +437,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `374` // Estimated: `3734` - // Minimum execution time: 19_000_000 picoseconds. - Weight::from_parts(20_000_000, 3734) + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 3734) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -448,7 +468,7 @@ impl WeightInfo for () { // Measured: `4` // Estimated: `1486` // Minimum execution time: 5_000_000 picoseconds. - Weight::from_parts(6_000_000, 1486) + Weight::from_parts(5_000_000, 1486) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -466,8 +486,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `302` // Estimated: `6478` - // Minimum execution time: 25_000_000 picoseconds. - Weight::from_parts(26_000_000, 6478) + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(25_000_000, 6478) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) }