From dbb1fd94770da417ea5a9702138c4ee8b661df99 Mon Sep 17 00:00:00 2001 From: Gabriel Facco de Arruda Date: Thu, 30 Nov 2023 15:55:09 -0300 Subject: [PATCH 1/3] OCIF Staking: Move stake between cores --- OCIF/staking/src/benchmarking.rs | 40 +++++ OCIF/staking/src/lib.rs | 63 ++++++++ OCIF/staking/src/testing/mod.rs | 74 ++++++++++ OCIF/staking/src/testing/test.rs | 241 +++++++++++++++++++++++++++++++ OCIF/staking/src/weights.rs | 135 +++++++++++------ 5 files changed, 507 insertions(+), 46 deletions(-) diff --git a/OCIF/staking/src/benchmarking.rs b/OCIF/staking/src/benchmarking.rs index 80d41c64..a3a4eafc 100644 --- a/OCIF/staking/src/benchmarking.rs +++ b/OCIF/staking/src/benchmarking.rs @@ -60,6 +60,28 @@ where ) } +fn mock_register_2() -> DispatchResultWithPostInfo +where + Result< + INV4Origin::CoreId, ::AccountId>, + ::RuntimeOrigin, + >: From<::RuntimeOrigin>, + ::RuntimeOrigin: + From::CoreId, ::AccountId>>, +{ + ::Currency::make_free_balance_be( + &derive_account::(1u32.into()), + T::RegisterDeposit::get() + T::RegisterDeposit::get(), + ); + + OcifStaking::::register_core( + INV4Origin::Multisig(MultisigInternalOrigin::new(1u32.into())).into(), + vec![].try_into().unwrap(), + vec![].try_into().unwrap(), + vec![].try_into().unwrap(), + ) +} + fn mock_stake() -> DispatchResultWithPostInfo where Result< @@ -268,4 +290,22 @@ benchmarks! { is_halted: true }.into()); } + + move_stake { + mock_register().unwrap(); + mock_register_2().unwrap(); + + mock_stake().unwrap(); + + let staker: T::AccountId = whitelisted_caller(); + let amount = T::StakeThresholdForActiveCore::get() + T::StakeThresholdForActiveCore::get(); + }: _(RawOrigin::Signed(staker.clone()), 0u32.into(), amount, 1u32.into()) + verify { + assert_last_event::(Event::::StakeMoved { + staker, + from_core: 0u32.into(), + amount, + to_core: 1u32.into() + }.into()); + } } diff --git a/OCIF/staking/src/lib.rs b/OCIF/staking/src/lib.rs index 8bfc1f64..57837f34 100644 --- a/OCIF/staking/src/lib.rs +++ b/OCIF/staking/src/lib.rs @@ -281,6 +281,12 @@ pub mod pallet { old_metadata: CoreMetadata, Vec, Vec>, new_metadata: CoreMetadata, Vec, Vec>, }, + StakeMoved { + staker: T::AccountId, + from_core: ::CoreId, + to_core: ::CoreId, + amount: BalanceOf, + }, } #[pallet::error] @@ -309,6 +315,7 @@ pub mod pallet { NotRegistered, Halted, NoHaltChange, + MoveStakeToSameCore, } #[pallet::hooks] @@ -789,6 +796,62 @@ pub mod pallet { Ok(().into()) } + + #[pallet::call_index(9)] + #[pallet::weight(::WeightInfo::move_stake())] + pub fn move_stake( + origin: OriginFor, + from_core: ::CoreId, + #[pallet::compact] amount: BalanceOf, + to_core: ::CoreId, + ) -> DispatchResultWithPostInfo { + Self::ensure_not_halted()?; + + let staker = ensure_signed(origin)?; + + ensure!(from_core != to_core, Error::::MoveStakeToSameCore); + ensure!( + Self::core_info(to_core).is_some(), + Error::::NotRegistered + ); + + let current_era = Self::current_era(); + let mut from_staker_info = Self::staker_info(from_core, &staker); + let mut from_core_info = + Self::core_stake_info(from_core, current_era).unwrap_or_default(); + + let unstaked_amount = Self::internal_unstake( + &mut from_staker_info, + &mut from_core_info, + amount, + current_era, + )?; + + let mut to_staker_info = Self::staker_info(to_core, &staker); + let mut to_core_info = Self::core_stake_info(to_core, current_era).unwrap_or_default(); + + Self::internal_stake( + &mut to_staker_info, + &mut to_core_info, + unstaked_amount, + current_era, + )?; + + CoreEraStake::::insert(from_core, current_era, from_core_info); + Self::update_staker_info(&staker, from_core, from_staker_info); + + CoreEraStake::::insert(to_core, current_era, to_core_info); + Self::update_staker_info(&staker, to_core, to_staker_info); + + Self::deposit_event(Event::::StakeMoved { + staker, + from_core, + to_core, + amount: unstaked_amount, + }); + + Ok(().into()) + } } impl Pallet { diff --git a/OCIF/staking/src/testing/mod.rs b/OCIF/staking/src/testing/mod.rs index bbeff694..3ccf731f 100644 --- a/OCIF/staking/src/testing/mod.rs +++ b/OCIF/staking/src/testing/mod.rs @@ -349,3 +349,77 @@ fn assert_reward( final_state_current_era.core_stake_info ); } + +pub(crate) fn assert_move_stake( + staker: AccountId, + from_core: &CoreId, + to_core: &CoreId, + amount: Balance, +) { + let current_era = OcifStaking::current_era(); + let from_init_state = MemorySnapshot::all(current_era, &from_core, staker); + let to_init_state = MemorySnapshot::all(current_era, &to_core, staker); + + let init_staked_value = from_init_state.staker_info.latest_staked_value(); + let expected_transfer_amount = if init_staked_value - amount >= MINIMUM_STAKING_AMOUNT { + amount + } else { + init_staked_value + }; + + assert_ok!(OcifStaking::move_stake( + RuntimeOrigin::signed(staker), + from_core.clone(), + amount, + to_core.clone() + )); + System::assert_last_event(mock::RuntimeEvent::OcifStaking(Event::StakeMoved { + staker, + from_core: from_core.clone(), + amount: expected_transfer_amount, + to_core: to_core.clone(), + })); + + let from_final_state = MemorySnapshot::all(current_era, &from_core, staker); + let to_final_state = MemorySnapshot::all(current_era, &to_core, staker); + + assert_eq!( + from_final_state.staker_info.latest_staked_value(), + init_staked_value - expected_transfer_amount + ); + assert_eq!( + to_final_state.staker_info.latest_staked_value(), + to_init_state.staker_info.latest_staked_value() + expected_transfer_amount + ); + + assert_eq!( + from_final_state.core_stake_info.total, + from_init_state.core_stake_info.total - expected_transfer_amount + ); + assert_eq!( + to_final_state.core_stake_info.total, + to_init_state.core_stake_info.total + expected_transfer_amount + ); + + let from_core_fully_unstaked = init_staked_value == expected_transfer_amount; + if from_core_fully_unstaked { + assert_eq!( + from_final_state.core_stake_info.number_of_stakers + 1, + from_init_state.core_stake_info.number_of_stakers + ); + } + + let no_init_stake_on_to_core = to_init_state.staker_info.latest_staked_value().is_zero(); + if no_init_stake_on_to_core { + assert_eq!( + to_final_state.core_stake_info.number_of_stakers, + to_init_state.core_stake_info.number_of_stakers + 1 + ); + } + + let fully_unstaked_and_nothing_to_claim = + from_core_fully_unstaked && to_final_state.staker_info.clone().claim() == (0, 0); + if fully_unstaked_and_nothing_to_claim { + assert!(!GeneralStakerInfo::::contains_key(&to_core, &staker)); + } +} diff --git a/OCIF/staking/src/testing/test.rs b/OCIF/staking/src/testing/test.rs index 04dbb764..2c7df7ef 100644 --- a/OCIF/staking/src/testing/test.rs +++ b/OCIF/staking/src/testing/test.rs @@ -2061,3 +2061,244 @@ fn halted_no_change() { ); }) } + +#[test] +fn move_stake_is_ok() { + ExternalityBuilder::build().execute_with(|| { + initialize_first_block(); + + let staker = account(B); + let core_id_a = A; + let core_id_b = C; + + assert_register(core_id_a); + assert_register(core_id_b); + let stake_value = 100; + assert_stake(staker, &core_id_a, stake_value); + + assert_move_stake(staker, &core_id_a, &core_id_b, stake_value / 2); + assert!(!GeneralStakerInfo::::get(&core_id_a, &staker) + .latest_staked_value() + .is_zero()); + + assert_move_stake(staker, &core_id_a, &core_id_b, stake_value / 2); + assert!(GeneralStakerInfo::::get(&core_id_a, &staker) + .latest_staked_value() + .is_zero()); + }) +} + +#[test] +fn move_stake_to_same_contract_err() { + ExternalityBuilder::build().execute_with(|| { + initialize_first_block(); + + let staker = account(B); + let core_id_a = A; + + assert_register(core_id_a); + let stake_value = 100; + assert_stake(staker, &core_id_a, stake_value); + + assert_noop!( + OcifStaking::move_stake( + RuntimeOrigin::signed(staker), + core_id_a, + stake_value, + core_id_a, + ), + Error::::MoveStakeToSameCore + ); + }) +} + +#[test] +fn move_stake_to_unregistered_core_err() { + ExternalityBuilder::build().execute_with(|| { + initialize_first_block(); + + let staker = account(B); + let core_id_a = A; + let core_id_b = C; + let core_id_c = D; + + assert_register(core_id_a); + let stake_value = 100; + assert_stake(staker, &core_id_a, stake_value); + + assert_noop!( + OcifStaking::move_stake( + RuntimeOrigin::signed(staker), + core_id_b, + stake_value, + core_id_c, + ), + Error::::NotRegistered + ); + + assert_noop!( + OcifStaking::move_stake( + RuntimeOrigin::signed(staker), + core_id_a, + stake_value, + core_id_b, + ), + Error::::NotRegistered + ); + + assert_noop!( + OcifStaking::move_stake( + RuntimeOrigin::signed(staker), + core_id_b, + stake_value, + core_id_a, + ), + Error::::NoStakeAvailable + ); + }) +} + +#[test] +fn move_stake_not_staking_err() { + ExternalityBuilder::build().execute_with(|| { + initialize_first_block(); + + let staker = account(B); + let core_id_a = A; + let core_id_b = C; + + assert_register(core_id_a); + assert_register(core_id_b); + let stake_value = 100; + + assert_noop!( + OcifStaking::move_stake( + RuntimeOrigin::signed(staker), + core_id_a, + stake_value, + core_id_b + ), + Error::::NoStakeAvailable + ); + }) +} + +#[test] +fn move_stake_with_no_amount_err() { + ExternalityBuilder::build().execute_with(|| { + initialize_first_block(); + + let staker = account(B); + let core_id_a = A; + let core_id_b = C; + + assert_register(core_id_a); + assert_register(core_id_b); + let stake_value = 100; + assert_stake(staker, &core_id_a, stake_value); + + assert_noop!( + OcifStaking::move_stake( + RuntimeOrigin::signed(staker), + core_id_a, + Zero::zero(), + core_id_b + ), + Error::::UnstakingNothing + ); + }) +} + +#[test] +fn move_stake_with_insufficient_amount_err() { + ExternalityBuilder::build().execute_with(|| { + initialize_first_block(); + + let staker = account(B); + let core_id_a = A; + let core_id_b = C; + + assert_register(core_id_a); + assert_register(core_id_b); + let stake_value = 100; + assert_stake(staker, &core_id_a, stake_value); + + assert_noop!( + OcifStaking::move_stake( + RuntimeOrigin::signed(staker), + core_id_a, + MINIMUM_STAKING_AMOUNT - 1, + core_id_b + ), + Error::::InsufficientBalance + ); + }) +} + +#[test] +fn move_stake_core_has_too_many_era_stake_err() { + ExternalityBuilder::build().execute_with(|| { + initialize_first_block(); + + let staker = account(B); + let core_id_a = A; + let core_id_b = C; + + assert_register(core_id_a); + assert_register(core_id_b); + + for _ in 1..MAX_ERA_STAKE_VALUES { + assert_stake(staker, &core_id_a, MINIMUM_STAKING_AMOUNT); + advance_to_era(OcifStaking::current_era() + 1); + } + assert_noop!( + OcifStaking::stake(RuntimeOrigin::signed(staker), core_id_a, 15), + Error::::TooManyEraStakeValues + ); + + assert_noop!( + OcifStaking::move_stake(RuntimeOrigin::signed(staker), core_id_a, 15, core_id_b), + Error::::TooManyEraStakeValues + ); + + assert_stake(staker, &core_id_b, 15); + assert_noop!( + OcifStaking::move_stake(RuntimeOrigin::signed(staker), core_id_b, 15, core_id_a), + Error::::TooManyEraStakeValues + ); + }) +} + +#[test] +fn move_stake_max_number_of_stakers_exceeded_err() { + ExternalityBuilder::build().execute_with(|| { + initialize_first_block(); + + let staker_a = account(B); + let staker_b = account(D); + let core_id_a = A; + let core_id_b = C; + + assert_register(core_id_a); + assert_register(core_id_b); + + assert_stake(staker_a, &core_id_a, 23); + assert_stake(staker_b, &core_id_b, 37); + assert_stake(staker_b, &core_id_b, 41); + + for temp_staker in (staker_b + 1)..(MAX_NUMBER_OF_STAKERS as u64 + staker_b) { + Balances::resolve_creating(&temp_staker, Balances::issue(100)); + assert_stake(temp_staker, &core_id_b, 13); + } + + assert_noop!( + OcifStaking::stake(RuntimeOrigin::signed(staker_a), core_id_b, 19), + Error::::MaxStakersReached + ); + + assert_noop!( + OcifStaking::move_stake(RuntimeOrigin::signed(staker_a), core_id_a, 19, core_id_b,), + Error::::MaxStakersReached + ); + }) +} diff --git a/OCIF/staking/src/weights.rs b/OCIF/staking/src/weights.rs index 76f919ed..bb53e10f 100644 --- a/OCIF/staking/src/weights.rs +++ b/OCIF/staking/src/weights.rs @@ -2,13 +2,13 @@ //! Autogenerated weights for `pallet_ocif_staking` //! //! 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: 2023-11-30, 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` // Executed Command: - // ./target/release/invarch-collator + // ./target/release/tinkernet-collator // benchmark // pallet // --chain=dev @@ -20,8 +20,8 @@ // 50 // --repeat // 20 - // --output=../InvArch-Frames/OCIF/staking/src/weights.rs - // --template=weights-template.hbs + // --output=../../InvArch-Frames/OCIF/staking/src/weights.rs + // --template=../weights-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -42,6 +42,7 @@ pub trait WeightInfo { 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. @@ -56,14 +57,16 @@ pub trait WeightInfo { /// 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: `144` // Estimated: `3942` // Minimum execution time: 28_000_000 picoseconds. - Weight::from_parts(29_525_844, 3942) - // Standard Error: 641 - .saturating_add(Weight::from_parts(2_603, 0).saturating_mul(i.into())) + 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)) } @@ -78,14 +81,14 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `86` // Estimated: `3942` - // Minimum execution time: 13_000_000 picoseconds. - Weight::from_parts(13_415_126, 3942) - // Standard Error: 2_128 - .saturating_add(Weight::from_parts(6_775, 0).saturating_mul(n.into())) - // Standard Error: 145 - .saturating_add(Weight::from_parts(1_501, 0).saturating_mul(d.into())) - // Standard Error: 436 - .saturating_add(Weight::from_parts(3_700, 0).saturating_mul(i.into())) + // 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)) } @@ -103,8 +106,8 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `268` // Estimated: `3942` - // Minimum execution time: 34_000_000 picoseconds. - Weight::from_parts(34_000_000, 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)) } @@ -130,8 +133,8 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `86` // Estimated: `4764` - // Minimum execution time: 46_000_000 picoseconds. - Weight::from_parts(47_000_000, 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)) } @@ -157,8 +160,8 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `397` // Estimated: `4764` - // Minimum execution time: 43_000_000 picoseconds. - Weight::from_parts(44_000_000, 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)) } @@ -178,8 +181,8 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `449` // Estimated: `4764` - // Minimum execution time: 45_000_000 picoseconds. - Weight::from_parts(70_000_000, 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)) } @@ -214,7 +217,7 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `308` // Estimated: `3557` - // Minimum execution time: 21_000_000 picoseconds. + // 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)) @@ -230,6 +233,25 @@ pub trait WeightInfo { .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)) + } } // For backwards compatibility and tests. @@ -243,14 +265,16 @@ pub trait WeightInfo { /// 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: `144` // Estimated: `3942` // Minimum execution time: 28_000_000 picoseconds. - Weight::from_parts(29_525_844, 3942) - // Standard Error: 641 - .saturating_add(Weight::from_parts(2_603, 0).saturating_mul(i.into())) + 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)) } @@ -265,14 +289,14 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `86` // Estimated: `3942` - // Minimum execution time: 13_000_000 picoseconds. - Weight::from_parts(13_415_126, 3942) - // Standard Error: 2_128 - .saturating_add(Weight::from_parts(6_775, 0).saturating_mul(n.into())) - // Standard Error: 145 - .saturating_add(Weight::from_parts(1_501, 0).saturating_mul(d.into())) - // Standard Error: 436 - .saturating_add(Weight::from_parts(3_700, 0).saturating_mul(i.into())) + // 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)) } @@ -290,8 +314,8 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `268` // Estimated: `3942` - // Minimum execution time: 34_000_000 picoseconds. - Weight::from_parts(34_000_000, 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)) } @@ -317,8 +341,8 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `86` // Estimated: `4764` - // Minimum execution time: 46_000_000 picoseconds. - Weight::from_parts(47_000_000, 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)) } @@ -344,8 +368,8 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `397` // Estimated: `4764` - // Minimum execution time: 43_000_000 picoseconds. - Weight::from_parts(44_000_000, 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)) } @@ -365,8 +389,8 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `449` // Estimated: `4764` - // Minimum execution time: 45_000_000 picoseconds. - Weight::from_parts(70_000_000, 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)) } @@ -401,7 +425,7 @@ pub trait WeightInfo { // Proof Size summary in bytes: // Measured: `308` // Estimated: `3557` - // Minimum execution time: 21_000_000 picoseconds. + // 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)) @@ -417,4 +441,23 @@ pub trait WeightInfo { .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)) + } } From ff0f60e7eeec0ea143ac7beb62f912924348d060 Mon Sep 17 00:00:00 2001 From: Gabriel Facco de Arruda Date: Thu, 30 Nov 2023 16:03:00 -0300 Subject: [PATCH 2/3] bump rust toolchain --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 77ee2509..124289af 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2022-11-01" +channel = "nightly-2023-05-22" targets = ["wasm32-unknown-unknown"] components = [ "rustfmt", "rustc", "rust-std", "cargo", "clippy", "llvm-tools-preview"] \ No newline at end of file From 42050468daf534624cae1bc5871e5401cf2ac1e2 Mon Sep 17 00:00:00 2001 From: Gabriel Facco de Arruda Date: Thu, 30 Nov 2023 16:07:44 -0300 Subject: [PATCH 3/3] clippy --- INV4/pallet-inv4/src/origin.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/INV4/pallet-inv4/src/origin.rs b/INV4/pallet-inv4/src/origin.rs index b8ecbd7b..4023ebb1 100644 --- a/INV4/pallet-inv4/src/origin.rs +++ b/INV4/pallet-inv4/src/origin.rs @@ -36,10 +36,7 @@ impl< > MultisigInternalOrigin { pub fn new(id: CoreId) -> Self { - Self { - id, - t: PhantomData::default(), - } + Self { id, t: PhantomData } } pub fn to_account_id(&self) -> AccountId {