Skip to content

Commit 688d4a7

Browse files
committed
Remove dead code
1 parent 4914867 commit 688d4a7

File tree

9 files changed

+22
-114
lines changed

9 files changed

+22
-114
lines changed

pallets/subtensor/src/coinbase/root.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -299,24 +299,6 @@ impl<T: Config> Pallet<T> {
299299
Self::deposit_event(Event::NetworkRateLimitSet(limit));
300300
}
301301

302-
/// Checks if registrations are allowed for a given subnet.
303-
///
304-
/// This function retrieves the subnet hyperparameters for the specified subnet and checks the `registration_allowed` flag.
305-
/// If the subnet doesn't exist or doesn't have hyperparameters defined, it returns `false`.
306-
///
307-
/// # Arguments
308-
///
309-
/// * `netuid` - The unique identifier of the subnet.
310-
///
311-
/// # Returns
312-
///
313-
/// * `bool` - `true` if registrations are allowed for the subnet, `false` otherwise.
314-
pub fn is_registration_allowed(netuid: u16) -> bool {
315-
Self::get_subnet_hyperparams(netuid)
316-
.map(|params| params.registration_allowed)
317-
.unwrap_or(false)
318-
}
319-
320302
/// Computes and sets emission values for the root network which determine the emission for all subnets.
321303
///
322304
/// This function is responsible for calculating emission based on network weights, stake values,

pallets/subtensor/src/epoch/run_epoch.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -803,18 +803,6 @@ impl<T: Config> Pallet<T> {
803803
I32F32::from_num(Self::get_kappa(netuid)).saturating_div(I32F32::from_num(u16::MAX))
804804
}
805805

806-
pub fn get_normalized_stake(netuid: u16) -> Vec<I32F32> {
807-
let n = Self::get_subnetwork_n(netuid);
808-
let mut stake_64: Vec<I64F64> = (0..n)
809-
.map(|neuron_uid| {
810-
I64F64::from_num(Self::get_stake_for_uid_and_subnetwork(netuid, neuron_uid))
811-
})
812-
.collect();
813-
inplace_normalize_64(&mut stake_64);
814-
let stake: Vec<I32F32> = vec_fixed64_to_fixed32(stake_64);
815-
stake
816-
}
817-
818806
pub fn get_block_at_registration(netuid: u16) -> Vec<u64> {
819807
let n = Self::get_subnetwork_n(netuid);
820808
let block_at_registration: Vec<u64> = (0..n)

pallets/subtensor/src/macros/errors.rs

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,42 @@ mod errors {
2222
HotKeyAccountNotExists,
2323
/// The hotkey is not registered in any subnet.
2424
HotKeyNotRegisteredInNetwork,
25-
/// Request to stake, unstake or subscribe is made by a coldkey that is not associated with the hotkey account.
25+
/// Request to stake, unstake or subscribe is made by a coldkey that is not associated with
26+
/// the hotkey account.
2627
NonAssociatedColdKey,
2728
/// The hotkey is not a delegate and the signer is not the owner of the hotkey.
2829
HotKeyNotDelegateAndSignerNotOwnHotKey,
2930
/// Stake amount to withdraw is zero.
3031
StakeToWithdrawIsZero,
31-
/// The caller is requesting removing more stake than there exists in the staking account. See: "[remove_stake()]".
32+
/// The caller is requesting removing more stake than there exists in the staking account.
33+
/// See: "[remove_stake()]".
3234
NotEnoughStakeToWithdraw,
33-
/// The caller is requesting to set weights but the caller has less than minimum stake required to set weights (less than WeightsMinStake).
35+
/// The caller is requesting to set weights but the caller has less than minimum stake
36+
/// required to set weights (less than WeightsMinStake).
3437
NotEnoughStakeToSetWeights,
35-
/// The caller is requesting adding more stake than there exists in the coldkey account. See: "[add_stake()]"
38+
/// The caller is requesting adding more stake than there exists in the coldkey account.
39+
/// See: "[add_stake()]"
3640
NotEnoughBalanceToStake,
37-
/// The caller is trying to add stake, but for some reason the requested amount could not be withdrawn from the coldkey account.
41+
/// The caller is trying to add stake, but for some reason the requested amount could not be
42+
/// withdrawn from the coldkey account.
3843
BalanceWithdrawalError,
39-
/// Unsuccessfully withdraw, balance could be zero (can not make account exist) after withdrawal.
44+
/// Unsuccessfully withdraw, balance could be zero (can not make account exist) after
45+
/// withdrawal.
4046
ZeroBalanceAfterWithdrawn,
4147
/// The caller is attempting to set non-self weights without being a permitted validator.
4248
NeuronNoValidatorPermit,
43-
/// The caller is attempting to set the weight keys and values but these vectors have different size.
49+
/// The caller is attempting to set the weight keys and values but these vectors have
50+
/// different size.
4451
WeightVecNotEqualSize,
4552
/// The caller is attempting to set weights with duplicate UIDs in the weight matrix.
4653
DuplicateUids,
47-
/// The caller is attempting to set weight to at least one UID that does not exist in the metagraph.
54+
/// The caller is attempting to set weight to at least one UID that does not exist in the
55+
/// metagraph.
4856
UidVecContainInvalidOne,
4957
/// The dispatch is attempting to set weights on chain with fewer elements than are allowed.
5058
WeightVecLengthIsLow,
51-
/// Number of registrations in this block exceeds the allowed number (i.e., exceeds the subnet hyperparameter "max_regs_per_block").
59+
/// Number of registrations in this block exceeds the allowed number (i.e., exceeds the
60+
/// subnet hyperparameter "max_regs_per_block").
5261
TooManyRegistrationsThisBlock,
5362
/// The caller is requesting registering a neuron which already exists in the active set.
5463
HotKeyAlreadyRegisteredInSubNet,
@@ -60,7 +69,8 @@ mod errors {
6069
InvalidDifficulty,
6170
/// The supplied PoW hash seal does not match the supplied work.
6271
InvalidSeal,
63-
/// The dispatch is attempting to set weights on chain with weight value exceeding the MaxWeightLimit (max_weight_limit subnet hyperparameter).
72+
/// The dispatch is attempting to set weights on chain with weight value exceeding the
73+
/// MaxWeightLimit (max_weight_limit subnet hyperparameter).
6474
MaxWeightExceeded,
6575
/// The hotkey is attempting to become a delegate when the hotkey is already a delegate.
6676
HotKeyAlreadyDelegate,
@@ -114,7 +124,8 @@ mod errors {
114124
DelegateTakeTooLow,
115125
/// Delegate take is too high.
116126
DelegateTakeTooHigh,
117-
/// No commit found for the provided hotkey+netuid combination when attempting to reveal the weights.
127+
/// No commit found for the provided hotkey+netuid combination when attempting to reveal the
128+
/// weights.
118129
NoWeightsCommitFound,
119130
/// Committed hash does not equal the hashed reveal data.
120131
InvalidRevealCommitHashNotMatch,
@@ -132,28 +143,10 @@ mod errors {
132143
AlphaLowOutOfRange,
133144
/// The coldkey has already been swapped
134145
ColdKeyAlreadyAssociated,
135-
/// The coldkey swap transaction rate limit exceeded
136-
ColdKeySwapTxRateLimitExceeded,
137-
/// The new coldkey is the same as the old coldkey
138-
NewColdKeyIsSameWithOld,
139-
/// The coldkey does not exist
140-
NotExistColdkey,
141146
/// The coldkey balance is not enough to pay for the swap
142147
NotEnoughBalanceToPaySwapColdKey,
143-
/// No balance to transfer
144-
NoBalanceToTransfer,
145-
/// Same coldkey
146-
SameColdkey,
147148
/// The coldkey is in arbitration
148149
ColdkeyIsInArbitration,
149-
/// The new coldkey is already registered for the drain
150-
DuplicateColdkey,
151-
/// Error thrown on a coldkey swap.
152-
ColdkeySwapError,
153-
/// Insufficient Balance to Schedule coldkey swap
154-
InsufficientBalanceToPerformColdkeySwap,
155-
/// The maximum number of coldkey destinations has been reached
156-
MaxColdkeyDestinationsReached,
157150
/// Attempting to set an invalid child for a hotkey on a network.
158151
InvalidChild,
159152
/// Duplicate child when setting children.
@@ -164,16 +157,12 @@ mod errors {
164157
TooManyChildren,
165158
/// Default transaction rate limit exceeded.
166159
TxRateLimitExceeded,
167-
/// Swap coldkey only callable by root.
168-
SwapColdkeyOnlyCallableByRoot,
169160
/// Swap already scheduled.
170161
SwapAlreadyScheduled,
171162
/// failed to swap coldkey
172163
FailedToSchedule,
173164
/// New coldkey is hotkey
174165
NewColdKeyIsHotkey,
175-
/// New coldkey is in arbitration
176-
NewColdkeyIsInArbitration,
177166
/// Childkey take is invalid.
178167
InvalidChildkeyTake,
179168
/// Childkey take rate limit exceeded.

pallets/subtensor/src/rpc_info/delegate_info.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,6 @@ impl<T: Config> Pallet<T> {
156156
total_delegated
157157
}
158158

159-
// Helper function to get total delegated stake for a hotkey
160-
pub fn get_total_hotkey_delegated_stake(hotkey: &T::AccountId) -> u64 {
161-
let mut total_delegated = 0u64;
162-
163-
// Iterate through all delegators for this hotkey
164-
for (delegator, stake) in Stake::<T>::iter_prefix(hotkey) {
165-
if delegator != Self::get_coldkey_for_hotkey(hotkey) {
166-
total_delegated = total_delegated.saturating_add(stake);
167-
}
168-
}
169-
170-
total_delegated
171-
}
172-
173159
// Helper function to get the coldkey associated with a hotkey
174160
pub fn get_coldkey_for_hotkey(hotkey: &T::AccountId) -> T::AccountId {
175161
Owner::<T>::get(hotkey)

pallets/subtensor/src/staking/helpers.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,6 @@ impl<T: Config> Pallet<T> {
341341
let _ = T::Currency::deposit(coldkey, amount, Precision::BestEffort);
342342
}
343343

344-
pub fn set_balance_on_coldkey_account(
345-
coldkey: &T::AccountId,
346-
amount: <<T as Config>::Currency as fungible::Inspect<<T as system::Config>::AccountId>>::Balance,
347-
) {
348-
T::Currency::set_balance(coldkey, amount);
349-
}
350-
351344
pub fn can_remove_balance_from_coldkey_account(
352345
coldkey: &T::AccountId,
353346
amount: <<T as Config>::Currency as fungible::Inspect<<T as system::Config>::AccountId>>::Balance,

pallets/subtensor/src/subnets/serving.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,6 @@ impl<T: Config> Pallet<T> {
246246
rate_limit == 0 || last_serve == 0 || current_block.saturating_sub(last_serve) >= rate_limit
247247
}
248248

249-
pub fn has_axon_info(netuid: u16, hotkey: &T::AccountId) -> bool {
250-
Axons::<T>::contains_key(netuid, hotkey)
251-
}
252-
253-
pub fn has_prometheus_info(netuid: u16, hotkey: &T::AccountId) -> bool {
254-
Prometheus::<T>::contains_key(netuid, hotkey)
255-
}
256-
257249
pub fn get_axon_info(netuid: u16, hotkey: &T::AccountId) -> AxonInfoOf {
258250
if let Some(axons) = Axons::<T>::get(netuid, hotkey) {
259251
axons

pallets/subtensor/src/subnets/uids.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ impl<T: Config> Pallet<T> {
127127
}
128128
}
129129

130-
/// Return the total number of subnetworks available on the chain.
131-
///
132-
pub fn get_number_of_subnets() -> u16 {
133-
<SubnetworkN<T> as IterableStorageMap<u16, u16>>::iter().count() as u16
134-
}
135-
136130
/// Return a list of all networks a hotkey is registered on.
137131
///
138132
pub fn get_registered_networks_for_hotkey(hotkey: &T::AccountId) -> Vec<u16> {

pallets/subtensor/src/utils/misc.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,6 @@ impl<T: Config> Pallet<T> {
424424
Self::deposit_event(Event::AdjustmentAlphaSet(netuid, adjustment_alpha));
425425
}
426426

427-
pub fn get_validator_prune_len(netuid: u16) -> u64 {
428-
ValidatorPruneLen::<T>::get(netuid)
429-
}
430427
pub fn set_validator_prune_len(netuid: u16, validator_prune_len: u64) {
431428
ValidatorPruneLen::<T>::insert(netuid, validator_prune_len);
432429
Self::deposit_event(Event::ValidatorPruneLenSet(netuid, validator_prune_len));

pallets/subtensor/src/utils/rate_limiting.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ impl<T: Config> Pallet<T> {
5656
last_block == 0 || block.saturating_sub(last_block) >= limit
5757
}
5858

59-
/// Check if a transaction should be rate limited globally
60-
pub fn passes_rate_limit_globally(tx_type: &TransactionType, hotkey: &T::AccountId) -> bool {
61-
let netuid: u16 = u16::MAX;
62-
let block: u64 = Self::get_current_block_as_u64();
63-
let limit: u64 = Self::get_rate_limit(tx_type, 0);
64-
let last_block: u64 = Self::get_last_transaction_block(hotkey, netuid, tx_type);
65-
block.saturating_sub(last_block) >= limit
66-
}
67-
6859
/// Get the block number of the last transaction for a specific hotkey, network, and transaction type
6960
pub fn get_last_transaction_block(
7061
hotkey: &T::AccountId,
@@ -98,10 +89,6 @@ impl<T: Config> Pallet<T> {
9889
pub fn get_last_tx_block_delegate_take(key: &T::AccountId) -> u64 {
9990
LastTxBlockDelegateTake::<T>::get(key)
10091
}
101-
102-
pub fn set_last_tx_block_childkey_take(key: &T::AccountId, block: u64) {
103-
LastTxBlockChildKeyTake::<T>::insert(key, block)
104-
}
10592
pub fn get_last_tx_block_childkey_take(key: &T::AccountId) -> u64 {
10693
LastTxBlockChildKeyTake::<T>::get(key)
10794
}

0 commit comments

Comments
 (0)