diff --git a/pallets/slp-v2/src/astar_dapp_staking/impls.rs b/pallets/slp-v2/src/astar_dapp_staking/impls.rs index ba4a1fe01..b9f832497 100644 --- a/pallets/slp-v2/src/astar_dapp_staking/impls.rs +++ b/pallets/slp-v2/src/astar_dapp_staking/impls.rs @@ -23,9 +23,9 @@ use crate::{ common::types::{ Delegator, DelegatorIndex, Ledger, PendingStatus, StakingProtocol, Validator, XcmTask, }, - Call, Config, ConfigurationByStakingProtocol, DelegatorByStakingProtocolAndDelegatorIndex, - DelegatorIndexByStakingProtocolAndDelegator, Error, Event, LedgerByStakingProtocolAndDelegator, - Pallet, PendingStatusByQueryId, ValidatorsByStakingProtocolAndDelegator, + Call, Config, ConfigurationByStakingProtocol, Error, Event, + LedgerByStakingProtocolAndDelegator, Pallet, PendingStatusByQueryId, + ValidatorsByStakingProtocolAndDelegator, }; use bifrost_primitives::VtokenMintingOperator; use frame_support::{dispatch::DispatchResultWithPostInfo, ensure}; @@ -54,18 +54,7 @@ impl Pallet { delegator: Delegator, task: DappStaking, ) -> DispatchResultWithPostInfo { - let delegator_index = DelegatorIndexByStakingProtocolAndDelegator::::get( - ASTAR_DAPP_STAKING, - delegator.clone(), - ) - .ok_or(Error::::DelegatorIndexNotFound)?; - ensure!( - DelegatorByStakingProtocolAndDelegatorIndex::::contains_key( - ASTAR_DAPP_STAKING, - delegator_index - ), - Error::::DelegatorNotFound - ); + let delegator_index = Self::ensure_delegator_exist(&ASTAR_DAPP_STAKING, &delegator)?; let (call, pending_status) = match task.clone() { DappStaking::Lock(amount) => ( AstarCall::::DappStaking(DappStaking::::Lock(amount)).encode(), diff --git a/pallets/slp-v2/src/benchmarking.rs b/pallets/slp-v2/src/benchmarking.rs index ec977e7be..92f124653 100644 --- a/pallets/slp-v2/src/benchmarking.rs +++ b/pallets/slp-v2/src/benchmarking.rs @@ -84,6 +84,7 @@ mod benchmarks { .unwrap() .into(), ); + assert_ok!(SlpV2::::add_delegator(RawOrigin::Root.into(), STAKING_PROTOCOL, None)); let validator = Validator::AstarDappStaking(AstarValidator::Evm(H160::zero())); #[extrinsic_call] _(RawOrigin::Root, STAKING_PROTOCOL, delegator, validator); @@ -97,6 +98,7 @@ mod benchmarks { .unwrap() .into(), ); + assert_ok!(SlpV2::::add_delegator(RawOrigin::Root.into(), STAKING_PROTOCOL, None)); let validator = Validator::AstarDappStaking(AstarValidator::Evm(H160::zero())); assert_ok!(SlpV2::::add_validator( RawOrigin::Root.into(), diff --git a/pallets/slp-v2/src/common/impls.rs b/pallets/slp-v2/src/common/impls.rs index 679aead72..336454874 100644 --- a/pallets/slp-v2/src/common/impls.rs +++ b/pallets/slp-v2/src/common/impls.rs @@ -23,7 +23,7 @@ use crate::{ }, Config, ConfigurationByStakingProtocol, DelegatorByStakingProtocolAndDelegatorIndex, DelegatorIndexByStakingProtocolAndDelegator, Error, Event, LedgerByStakingProtocolAndDelegator, - NextDelegatorIndexByStakingProtocol, Pallet, + NextDelegatorIndexByStakingProtocol, Pallet, ValidatorsByStakingProtocolAndDelegator, }; use bifrost_primitives::{Balance, CurrencyId, VtokenMintingOperator}; use frame_support::{ @@ -103,15 +103,15 @@ impl Pallet { staking_protocol: StakingProtocol, delegator: Delegator, ) -> DispatchResultWithPostInfo { - let delegator_index = DelegatorIndexByStakingProtocolAndDelegator::::take( - staking_protocol, - delegator.clone(), - ) - .ok_or(Error::::DelegatorIndexNotFound)?; - DelegatorByStakingProtocolAndDelegatorIndex::::take(staking_protocol, delegator_index) - .ok_or(Error::::DelegatorNotFound)?; - LedgerByStakingProtocolAndDelegator::::take(staking_protocol, delegator.clone()) - .ok_or(Error::::LedgerNotFound)?; + let delegator_index = + DelegatorIndexByStakingProtocolAndDelegator::::take(&staking_protocol, &delegator) + .ok_or(Error::::DelegatorIndexNotFound)?; + DelegatorByStakingProtocolAndDelegatorIndex::::remove( + &staking_protocol, + delegator_index, + ); + ValidatorsByStakingProtocolAndDelegator::::remove(&staking_protocol, &delegator); + LedgerByStakingProtocolAndDelegator::::remove(&staking_protocol, &delegator); Self::deposit_event(Event::RemoveDelegator { staking_protocol, delegator_index, @@ -124,21 +124,28 @@ impl Pallet { staking_protocol: StakingProtocol, delegator: Delegator, ) -> DispatchResultWithPostInfo { + Self::ensure_delegator_exist(&staking_protocol, &delegator)?; let currency_id = staking_protocol.info().currency_id; let dest_beneficiary_location = staking_protocol - .get_dest_beneficiary_location::(delegator) + .get_dest_beneficiary_location::(delegator.clone()) .ok_or(Error::::UnsupportedStakingProtocol)?; let (entrance_account, _) = T::VtokenMinting::get_entrance_and_exit_accounts(); - let entrance_account_fee_balance = + let entrance_account_free_balance = T::MultiCurrency::free_balance(currency_id, &entrance_account); T::XcmTransfer::transfer( - entrance_account, + entrance_account.clone(), currency_id, - entrance_account_fee_balance, + entrance_account_free_balance, dest_beneficiary_location, WeightLimit::Unlimited, ) .map_err(|_| Error::::DerivativeAccountIdFailed)?; + Self::deposit_event(Event::TransferTo { + staking_protocol, + from: entrance_account, + to: delegator, + amount: entrance_account_free_balance, + }); Ok(().into()) } @@ -147,23 +154,13 @@ impl Pallet { delegator: Delegator, amount: Balance, ) -> DispatchResultWithPostInfo { - let delegator_index = DelegatorIndexByStakingProtocolAndDelegator::::get( - staking_protocol, - delegator.clone(), - ) - .ok_or(Error::::DelegatorIndexNotFound)?; - ensure!( - DelegatorByStakingProtocolAndDelegatorIndex::::contains_key( - staking_protocol, - delegator_index - ), - Error::::DelegatorNotFound - ); - + let delegator_index = Self::ensure_delegator_exist(&staking_protocol, &delegator)?; + let (entrance_account, _) = T::VtokenMinting::get_entrance_and_exit_accounts(); let transfer_back_call_data = Self::wrap_polkadot_xcm_limited_reserve_transfer_assets_call_data( &staking_protocol, amount, + entrance_account.clone(), )?; let utility_as_derivative_call_data = Self::wrap_utility_as_derivative_call_data( &staking_protocol, @@ -173,6 +170,12 @@ impl Pallet { let xcm_message = Self::wrap_xcm_message(&staking_protocol, utility_as_derivative_call_data)?; Self::send_xcm_message(staking_protocol, xcm_message)?; + Self::deposit_event(Event::TransferBack { + staking_protocol, + from: delegator, + to: entrance_account, + amount, + }); Ok(().into()) } @@ -207,14 +210,12 @@ impl Pallet { pub fn wrap_polkadot_xcm_limited_reserve_transfer_assets_call_data( staking_protocol: &StakingProtocol, amount: Balance, + to: T::AccountId, ) -> Result, Error> { let xcm_pallet_index = staking_protocol.info().xcm_pallet_index; let bifrost_dest_location = staking_protocol.info().bifrost_dest_location; - let (entrance_account, _) = T::VtokenMinting::get_entrance_and_exit_accounts(); - let account_id = entrance_account - .encode() - .try_into() - .map_err(|_| Error::::DerivativeAccountIdFailed)?; + let account_id = + to.encode().try_into().map_err(|_| Error::::DerivativeAccountIdFailed)?; let beneficiary = Location::new(0, AccountId32 { network: None, id: account_id }); let fee_asset_item = 0u32; let weight_limit = WeightLimit::Unlimited; @@ -351,4 +352,21 @@ impl Pallet { }, } } + + pub fn ensure_delegator_exist( + staking_protocol: &StakingProtocol, + delegator: &Delegator, + ) -> Result> { + let delegator_index = + DelegatorIndexByStakingProtocolAndDelegator::::get(staking_protocol, delegator) + .ok_or(Error::::DelegatorIndexNotFound)?; + ensure!( + DelegatorByStakingProtocolAndDelegatorIndex::::contains_key( + staking_protocol, + delegator_index + ), + Error::::DelegatorNotFound + ); + Ok(delegator_index) + } } diff --git a/pallets/slp-v2/src/lib.rs b/pallets/slp-v2/src/lib.rs index f05edfa53..ce08dca9a 100644 --- a/pallets/slp-v2/src/lib.rs +++ b/pallets/slp-v2/src/lib.rs @@ -285,6 +285,28 @@ pub mod pallet { /// Amount of exchange rates updated amount: Balance, }, + /// Transfer the staking token to remote chain. + TransferTo { + /// Slp supports staking protocols. + staking_protocol: StakingProtocol, + /// Bifrost Account + from: T::AccountId, + /// Delegator account. + to: Delegator, + /// Amount + amount: Balance, + }, + /// Transfer the staking token back from remote chain. + TransferBack { + /// Slp supports staking protocols. + staking_protocol: StakingProtocol, + /// Delegator account. + from: Delegator, + /// Bifrost Account. + to: T::AccountId, + /// Amount + amount: Balance, + }, } #[pallet::error] @@ -430,6 +452,7 @@ pub mod pallet { validator: Validator, ) -> DispatchResultWithPostInfo { T::ControlOrigin::ensure_origin(origin)?; + Self::ensure_delegator_exist(&staking_protocol, &delegator)?; ValidatorsByStakingProtocolAndDelegator::::mutate( staking_protocol, delegator.clone(), @@ -465,6 +488,7 @@ pub mod pallet { validator: Validator, ) -> DispatchResultWithPostInfo { T::ControlOrigin::ensure_origin(origin)?; + Self::ensure_delegator_exist(&staking_protocol, &delegator)?; ValidatorsByStakingProtocolAndDelegator::::mutate( staking_protocol, delegator.clone(), @@ -498,18 +522,7 @@ pub mod pallet { ledger: Ledger, ) -> DispatchResultWithPostInfo { T::ControlOrigin::ensure_origin(origin)?; - let delegator_index = DelegatorIndexByStakingProtocolAndDelegator::::get( - staking_protocol, - delegator.clone(), - ) - .ok_or(Error::::DelegatorIndexNotFound)?; - ensure!( - DelegatorByStakingProtocolAndDelegatorIndex::::contains_key( - staking_protocol, - delegator_index - ), - Error::::DelegatorNotFound - ); + Self::ensure_delegator_exist(&staking_protocol, &delegator)?; LedgerByStakingProtocolAndDelegator::::mutate( staking_protocol, delegator.clone(), @@ -743,7 +756,9 @@ pub mod pallet { .ok_or(Error::::PendingStatusNotFound)?; if Response::DispatchResult(MaybeErrorCode::Success) == response { Self::do_notify_astar_dapp_staking(responder, pending_status)?; - }; + } else { + PendingStatusByQueryId::::remove(query_id); + } Ok(().into()) } } diff --git a/pallets/slp-v2/src/tests.rs b/pallets/slp-v2/src/tests.rs index c3357beaf..d2649ecf2 100644 --- a/pallets/slp-v2/src/tests.rs +++ b/pallets/slp-v2/src/tests.rs @@ -261,10 +261,18 @@ fn remove_delegator_should_work() { None ); assert_eq!( - DelegatorIndexByStakingProtocolAndDelegator::::get(STAKING_PROTOCOL, delegator), + DelegatorIndexByStakingProtocolAndDelegator::::get( + STAKING_PROTOCOL, + delegator.clone() + ), None ); assert_eq!(NextDelegatorIndexByStakingProtocol::::get(STAKING_PROTOCOL), 1); + assert_eq!( + ValidatorsByStakingProtocolAndDelegator::::get(STAKING_PROTOCOL, delegator) + .to_vec(), + vec![] + ); }); } @@ -281,24 +289,6 @@ fn remove_delegator_delegator_index_not_found() { }); } -#[test] -fn remove_delegator_delegator_not_found() { - new_test_ext().execute_with(|| { - let delegator = Delegator::Substrate( - AccountId::from_ss58check("YLF9AnL6V1vQRfuiB832NXNGZYCPAWkKLLkh7cf3KwXhB9o").unwrap(), - ); - DelegatorIndexByStakingProtocolAndDelegator::::insert( - STAKING_PROTOCOL, - delegator.clone(), - 0, - ); - assert_noop!( - SlpV2::remove_delegator(RuntimeOrigin::root(), STAKING_PROTOCOL, delegator.clone()), - SlpV2Error::::DelegatorNotFound - ); - }); -} - #[test] fn add_validator_should_work() { new_test_ext().execute_with(|| { @@ -307,6 +297,8 @@ fn add_validator_should_work() { ); let validator = Validator::AstarDappStaking(AstarValidator::Evm(H160::default())); + assert_ok!(SlpV2::add_delegator(RuntimeOrigin::root(), STAKING_PROTOCOL, None)); + assert_ok!(SlpV2::add_validator( RuntimeOrigin::root(), STAKING_PROTOCOL, @@ -337,6 +329,8 @@ fn repeat_add_validator_should_work() { AccountId::from_ss58check("YeKP2BdVpFrXbbqkoVhDFZP9u3nUuop7fpMppQczQXBLhD1").unwrap(), )); + assert_ok!(SlpV2::add_delegator(RuntimeOrigin::root(), STAKING_PROTOCOL, None)); + assert_ok!(SlpV2::add_validator( RuntimeOrigin::root(), STAKING_PROTOCOL, @@ -374,6 +368,8 @@ fn remove_validator_should_work() { ); let validator = Validator::AstarDappStaking(AstarValidator::Evm(H160::default())); + assert_ok!(SlpV2::add_delegator(RuntimeOrigin::root(), STAKING_PROTOCOL, None)); + assert_ok!(SlpV2::add_validator( RuntimeOrigin::root(), STAKING_PROTOCOL, @@ -644,9 +640,11 @@ fn staking_protocol_get_dest_beneficiary_location() { #[test] fn astar_polkadot_xcm_call() { new_test_ext().execute_with(|| { + let (to, _) = VtokenMinting::get_entrance_and_exit_accounts(); let calldata = SlpV2::wrap_polkadot_xcm_limited_reserve_transfer_assets_call_data( &StakingProtocol::AstarDappStaking, 100, + to.clone() ) .unwrap(); @@ -655,6 +653,7 @@ fn astar_polkadot_xcm_call() { let call_data = SlpV2::wrap_polkadot_xcm_limited_reserve_transfer_assets_call_data( &StakingProtocol::PolkadotStaking, 100, + to ) .unwrap(); assert_eq!(to_hex(&call_data, false), "0x630804000100b91f04000101006d6f646c62662f76746b696e0000000000000000000000000000000000000000040400000091010000000000"); diff --git a/pallets/slp-v2/src/weights.rs b/pallets/slp-v2/src/weights.rs index 130773e53..5ca1dccd7 100644 --- a/pallets/slp-v2/src/weights.rs +++ b/pallets/slp-v2/src/weights.rs @@ -25,8 +25,8 @@ //! Autogenerated weights for bifrost_slp_v2 //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-09-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `MacBook-Pro-2`, CPU: `` +//! DATE: 2024-09-11, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bifrost-jenkins`, CPU: `Intel(R) Xeon(R) CPU E5-26xx v4` //! WASM-EXECUTION: Compiled, CHAIN: Some("bifrost-polkadot-local"), DB CACHE: 1024 // Executed Command: @@ -93,17 +93,13 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `341` // Estimated: `3533` - // Minimum execution time: 23_000_000 picoseconds. - Weight::from_parts(24_000_000, 3533) + // Minimum execution time: 59_092_000 picoseconds. + Weight::from_parts(60_502_000, 3533) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (r:1 w:1) /// Proof: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) - /// Storage: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (r:1 w:1) - /// Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) - /// Storage: `SlpV2::LedgerByStakingProtocolAndDelegator` (r:1 w:1) - /// Proof: `SlpV2::LedgerByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`) /// Storage: `System::Number` (r:1 w:0) /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `System::ExecutionPhase` (r:1 w:0) @@ -112,15 +108,25 @@ impl WeightInfo for () { /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `System::Events` (r:1 w:1) /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `SlpV2::LedgerByStakingProtocolAndDelegator` (r:0 w:1) + /// Proof: `SlpV2::LedgerByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`) + /// Storage: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (r:0 w:1) + /// Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + /// Storage: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (r:0 w:1) + /// Proof: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(8772), added: 11247, mode: `MaxEncodedLen`) fn remove_delegator() -> Weight { // Proof Size summary in bytes: - // Measured: `548` - // Estimated: `3717` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(22_000_000, 3717) - .saturating_add(RocksDbWeight::get().reads(7_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) + // Measured: `432` + // Estimated: `3533` + // Minimum execution time: 48_567_000 picoseconds. + Weight::from_parts(49_673_000, 3533) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } + /// Storage: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (r:1 w:0) + /// Proof: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + /// Storage: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (r:1 w:0) + /// Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) /// Storage: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (r:1 w:1) /// Proof: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(8772), added: 11247, mode: `MaxEncodedLen`) /// Storage: `System::Number` (r:1 w:0) @@ -133,13 +139,17 @@ impl WeightInfo for () { /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn add_validator() -> Weight { // Proof Size summary in bytes: - // Measured: `238` + // Measured: `487` // Estimated: `12237` - // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(13_000_000, 12237) - .saturating_add(RocksDbWeight::get().reads(5_u64)) + // Minimum execution time: 51_665_000 picoseconds. + Weight::from_parts(52_597_000, 12237) + .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } + /// Storage: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (r:1 w:0) + /// Proof: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + /// Storage: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (r:1 w:0) + /// Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) /// Storage: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (r:1 w:1) /// Proof: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(8772), added: 11247, mode: `MaxEncodedLen`) /// Storage: `System::Number` (r:1 w:0) @@ -152,11 +162,11 @@ impl WeightInfo for () { /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn remove_validator() -> Weight { // Proof Size summary in bytes: - // Measured: `353` + // Measured: `598` // Estimated: `12237` - // Minimum execution time: 13_000_000 picoseconds. - Weight::from_parts(14_000_000, 12237) - .saturating_add(RocksDbWeight::get().reads(5_u64)) + // Minimum execution time: 53_942_000 picoseconds. + Weight::from_parts(55_252_000, 12237) + .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `SlpV2::ConfigurationByStakingProtocol` (r:1 w:1) @@ -173,8 +183,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `238` // Estimated: `3567` - // Minimum execution time: 10_000_000 picoseconds. - Weight::from_parts(11_000_000, 3567) + // Minimum execution time: 32_670_000 picoseconds. + Weight::from_parts(33_460_000, 3567) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -196,20 +206,33 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `545` // Estimated: `3717` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_000_000, 3717) + // Minimum execution time: 52_407_000 picoseconds. + Weight::from_parts(53_463_000, 3717) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } + /// Storage: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (r:1 w:0) + /// Proof: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + /// Storage: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (r:1 w:0) + /// Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:1 w:0) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(118), added: 2593, mode: `MaxEncodedLen`) + /// Storage: `System::Number` (r:1 w:0) + /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::ExecutionPhase` (r:1 w:0) + /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + /// Storage: `System::EventCount` (r:1 w:1) + /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Events` (r:1 w:1) + /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn transfer_to() -> Weight { // Proof Size summary in bytes: - // Measured: `455` + // Measured: `942` // Estimated: `3583` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(9_000_000, 3583) - .saturating_add(RocksDbWeight::get().reads(1_u64)) + // Minimum execution time: 56_532_000 picoseconds. + Weight::from_parts(57_959_000, 3583) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (r:1 w:0) /// Proof: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) @@ -217,13 +240,22 @@ impl WeightInfo for () { /// Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) /// Storage: `SlpV2::ConfigurationByStakingProtocol` (r:1 w:0) /// Proof: `SlpV2::ConfigurationByStakingProtocol` (`max_values`: None, `max_size`: Some(102), added: 2577, mode: `MaxEncodedLen`) + /// Storage: `System::Number` (r:1 w:0) + /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::ExecutionPhase` (r:1 w:0) + /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + /// Storage: `System::EventCount` (r:1 w:1) + /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Events` (r:1 w:1) + /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn transfer_back() -> Weight { // Proof Size summary in bytes: - // Measured: `571` + // Measured: `596` // Estimated: `3567` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(20_000_000, 3567) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Minimum execution time: 62_312_000 picoseconds. + Weight::from_parts(65_024_000, 3567) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -247,8 +279,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `560` // Estimated: `3567` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_000_000, 3567) + // Minimum execution time: 52_270_000 picoseconds. + Weight::from_parts(53_152_000, 3567) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -276,8 +308,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `755` // Estimated: `3717` - // Minimum execution time: 25_000_000 picoseconds. - Weight::from_parts(26_000_000, 3717) + // Minimum execution time: 67_792_000 picoseconds. + Weight::from_parts(69_546_000, 3717) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -305,8 +337,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `836` // Estimated: `3567` - // Minimum execution time: 30_000_000 picoseconds. - Weight::from_parts(31_000_000, 3567) + // Minimum execution time: 80_609_000 picoseconds. + Weight::from_parts(81_635_000, 3567) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -326,9 +358,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `567` // Estimated: `3717` - // Minimum execution time: 15_000_000 picoseconds. - Weight::from_parts(16_000_000, 3717) + // Minimum execution time: 45_781_000 picoseconds. + Weight::from_parts(46_813_000, 3717) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } -} +} \ No newline at end of file diff --git a/runtime/bifrost-polkadot/src/weights/bifrost_slp_v2.rs b/runtime/bifrost-polkadot/src/weights/bifrost_slp_v2.rs index 461e29d56..b7bd7ff5b 100644 --- a/runtime/bifrost-polkadot/src/weights/bifrost_slp_v2.rs +++ b/runtime/bifrost-polkadot/src/weights/bifrost_slp_v2.rs @@ -25,8 +25,8 @@ //! Autogenerated weights for bifrost_slp_v2 //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-09-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `MacBook-Pro-2`, CPU: `` +//! DATE: 2024-09-11, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bifrost-jenkins`, CPU: `Intel(R) Xeon(R) CPU E5-26xx v4` //! WASM-EXECUTION: Compiled, CHAIN: Some("bifrost-polkadot-local"), DB CACHE: 1024 // Executed Command: @@ -78,17 +78,13 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof Size summary in bytes: // Measured: `341` // Estimated: `3533` - // Minimum execution time: 22_000 nanoseconds. - Weight::from_parts(24_000_000, 3533) + // Minimum execution time: 53_863 nanoseconds. + Weight::from_parts(54_653_000, 3533) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(6)) } // Storage: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (r:1 w:1) // Proof: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) - // Storage: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (r:1 w:1) - // Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) - // Storage: `SlpV2::LedgerByStakingProtocolAndDelegator` (r:1 w:1) - // Proof: `SlpV2::LedgerByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`) // Storage: `System::Number` (r:1 w:0) // Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) // Storage: `System::ExecutionPhase` (r:1 w:0) @@ -97,15 +93,25 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) // Storage: `System::Events` (r:1 w:1) // Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `SlpV2::LedgerByStakingProtocolAndDelegator` (r:0 w:1) + // Proof: `SlpV2::LedgerByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(252), added: 2727, mode: `MaxEncodedLen`) + // Storage: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (r:0 w:1) + // Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + // Storage: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (r:0 w:1) + // Proof: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(8772), added: 11247, mode: `MaxEncodedLen`) fn remove_delegator() -> Weight { // Proof Size summary in bytes: - // Measured: `548` - // Estimated: `3717` - // Minimum execution time: 20_000 nanoseconds. - Weight::from_parts(21_000_000, 3717) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + // Measured: `432` + // Estimated: `3533` + // Minimum execution time: 44_302 nanoseconds. + Weight::from_parts(45_092_000, 3533) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(6)) } + // Storage: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (r:1 w:0) + // Proof: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + // Storage: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (r:1 w:0) + // Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) // Storage: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (r:1 w:1) // Proof: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(8772), added: 11247, mode: `MaxEncodedLen`) // Storage: `System::Number` (r:1 w:0) @@ -118,13 +124,17 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn add_validator() -> Weight { // Proof Size summary in bytes: - // Measured: `238` + // Measured: `487` // Estimated: `12237` - // Minimum execution time: 11_000 nanoseconds. - Weight::from_parts(12_000_000, 12237) - .saturating_add(T::DbWeight::get().reads(5)) + // Minimum execution time: 45_532 nanoseconds. + Weight::from_parts(46_472_000, 12237) + .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } + // Storage: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (r:1 w:0) + // Proof: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + // Storage: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (r:1 w:0) + // Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) // Storage: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (r:1 w:1) // Proof: `SlpV2::ValidatorsByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(8772), added: 11247, mode: `MaxEncodedLen`) // Storage: `System::Number` (r:1 w:0) @@ -137,11 +147,11 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn remove_validator() -> Weight { // Proof Size summary in bytes: - // Measured: `353` + // Measured: `598` // Estimated: `12237` - // Minimum execution time: 13_000 nanoseconds. - Weight::from_parts(13_000_000, 12237) - .saturating_add(T::DbWeight::get().reads(5)) + // Minimum execution time: 46_892 nanoseconds. + Weight::from_parts(48_157_000, 12237) + .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } // Storage: `SlpV2::ConfigurationByStakingProtocol` (r:1 w:1) @@ -158,8 +168,8 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof Size summary in bytes: // Measured: `238` // Estimated: `3567` - // Minimum execution time: 10_000 nanoseconds. - Weight::from_parts(11_000_000, 3567) + // Minimum execution time: 29_559 nanoseconds. + Weight::from_parts(30_338_000, 3567) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -181,20 +191,33 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof Size summary in bytes: // Measured: `545` // Estimated: `3717` - // Minimum execution time: 19_000 nanoseconds. - Weight::from_parts(19_000_000, 3717) + // Minimum execution time: 47_747 nanoseconds. + Weight::from_parts(48_586_000, 3717) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } + // Storage: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (r:1 w:0) + // Proof: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) + // Storage: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (r:1 w:0) + // Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) // Storage: `Tokens::Accounts` (r:1 w:0) // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(118), added: 2593, mode: `MaxEncodedLen`) + // Storage: `System::Number` (r:1 w:0) + // Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `System::ExecutionPhase` (r:1 w:0) + // Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + // Storage: `System::EventCount` (r:1 w:1) + // Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `System::Events` (r:1 w:1) + // Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn transfer_to() -> Weight { // Proof Size summary in bytes: - // Measured: `455` + // Measured: `942` // Estimated: `3583` - // Minimum execution time: 9_000 nanoseconds. - Weight::from_parts(9_000_000, 3583) - .saturating_add(T::DbWeight::get().reads(1)) + // Minimum execution time: 51_620 nanoseconds. + Weight::from_parts(52_770_000, 3583) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (r:1 w:0) // Proof: `SlpV2::DelegatorIndexByStakingProtocolAndDelegator` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) @@ -202,13 +225,22 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof: `SlpV2::DelegatorByStakingProtocolAndDelegatorIndex` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) // Storage: `SlpV2::ConfigurationByStakingProtocol` (r:1 w:0) // Proof: `SlpV2::ConfigurationByStakingProtocol` (`max_values`: None, `max_size`: Some(102), added: 2577, mode: `MaxEncodedLen`) + // Storage: `System::Number` (r:1 w:0) + // Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `System::ExecutionPhase` (r:1 w:0) + // Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) + // Storage: `System::EventCount` (r:1 w:1) + // Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `System::Events` (r:1 w:1) + // Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn transfer_back() -> Weight { // Proof Size summary in bytes: - // Measured: `571` + // Measured: `596` // Estimated: `3567` - // Minimum execution time: 19_000 nanoseconds. - Weight::from_parts(20_000_000, 3567) - .saturating_add(T::DbWeight::get().reads(3)) + // Minimum execution time: 57_783 nanoseconds. + Weight::from_parts(59_016_000, 3567) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: `ParachainSystem::ValidationData` (r:1 w:0) // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -232,8 +264,8 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof Size summary in bytes: // Measured: `560` // Estimated: `3567` - // Minimum execution time: 19_000 nanoseconds. - Weight::from_parts(19_000_000, 3567) + // Minimum execution time: 45_649 nanoseconds. + Weight::from_parts(47_962_000, 3567) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -261,8 +293,8 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof Size summary in bytes: // Measured: `755` // Estimated: `3717` - // Minimum execution time: 25_000 nanoseconds. - Weight::from_parts(26_000_000, 3717) + // Minimum execution time: 62_204 nanoseconds. + Weight::from_parts(63_446_000, 3717) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -290,8 +322,8 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof Size summary in bytes: // Measured: `836` // Estimated: `3567` - // Minimum execution time: 30_000 nanoseconds. - Weight::from_parts(31_000_000, 3567) + // Minimum execution time: 72_646 nanoseconds. + Weight::from_parts(73_892_000, 3567) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -311,9 +343,9 @@ impl bifrost_slp_v2::WeightInfo for BifrostWeight { // Proof Size summary in bytes: // Measured: `567` // Estimated: `3717` - // Minimum execution time: 15_000 nanoseconds. - Weight::from_parts(16_000_000, 3717) + // Minimum execution time: 40_876 nanoseconds. + Weight::from_parts(41_668_000, 3717) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } -} +} \ No newline at end of file