Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 111 additions & 107 deletions pallets/proxy/src/weights.rs

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions pallets/subtensor/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,61 @@ mod pallet_benchmarks {
);
}

#[benchmark]
fn remove_stake() {
let netuid = NetUid::from(1);
let tempo: u16 = 1;
let seed: u32 = 1;

Subtensor::<T>::increase_total_stake(1_000_000_000_000_u64.into());

Subtensor::<T>::init_new_network(netuid, tempo);
Subtensor::<T>::set_network_registration_allowed(netuid, true);
SubtokenEnabled::<T>::insert(netuid, true);

Subtensor::<T>::set_max_allowed_uids(netuid, 4096);
assert_eq!(Subtensor::<T>::get_max_allowed_uids(netuid), 4096);

let coldkey: T::AccountId = account("Test", 0, seed);
let hotkey: T::AccountId = account("Alice", 0, seed);
Subtensor::<T>::set_burn(netuid, benchmark_registration_burn());

let tao_reserve = TaoBalance::from(1_000_000_000_000_u64);
let alpha_in = AlphaBalance::from(100_000_000_000_000_u64);
set_reserves::<T>(netuid, tao_reserve, alpha_in);

let wallet_bal = 1000000u32.into();
Subtensor::<T>::add_balance_to_coldkey_account(&coldkey.clone(), wallet_bal);

assert_ok!(Subtensor::<T>::burned_register(
RawOrigin::Signed(coldkey.clone()).into(),
netuid,
hotkey.clone()
));

let staked_amt = TaoBalance::from(100_000_000_000_u64);
Subtensor::<T>::add_balance_to_coldkey_account(&coldkey.clone(), staked_amt);

assert_ok!(Subtensor::<T>::add_stake(
RawOrigin::Signed(coldkey.clone()).into(),
hotkey.clone(),
netuid,
staked_amt
));

let amount_unstaked = AlphaBalance::from(30_000_000_000_u64);

StakingOperationRateLimiter::<T>::remove((hotkey.clone(), coldkey.clone(), netuid));

#[extrinsic_call]
_(
RawOrigin::Signed(coldkey.clone()),
hotkey.clone(),
netuid,
amount_unstaked,
);
}

#[benchmark]
fn remove_stake_limit() {
let netuid = NetUid::from(1);
Expand Down
4 changes: 1 addition & 3 deletions pallets/subtensor/src/macros/dispatches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,7 @@ mod dispatches {
/// - Thrown if there is not enough stake on the hotkey to withdwraw this amount.
///
#[pallet::call_index(3)]
#[pallet::weight((Weight::from_parts(196_800_000, 0)
.saturating_add(T::DbWeight::get().reads(19))
.saturating_add(T::DbWeight::get().writes(10)), DispatchClass::Normal, Pays::Yes))]
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::remove_stake())]
pub fn remove_stake(
origin: OriginFor<T>,
hotkey: T::AccountId,
Expand Down
Loading
Loading