diff --git a/pallets/subtensor/src/coinbase/root.rs b/pallets/subtensor/src/coinbase/root.rs index 067d5855b..1efbd2208 100644 --- a/pallets/subtensor/src/coinbase/root.rs +++ b/pallets/subtensor/src/coinbase/root.rs @@ -299,24 +299,6 @@ impl Pallet { Self::deposit_event(Event::NetworkRateLimitSet(limit)); } - /// Checks if registrations are allowed for a given subnet. - /// - /// This function retrieves the subnet hyperparameters for the specified subnet and checks the `registration_allowed` flag. - /// If the subnet doesn't exist or doesn't have hyperparameters defined, it returns `false`. - /// - /// # Arguments - /// - /// * `netuid` - The unique identifier of the subnet. - /// - /// # Returns - /// - /// * `bool` - `true` if registrations are allowed for the subnet, `false` otherwise. - pub fn is_registration_allowed(netuid: u16) -> bool { - Self::get_subnet_hyperparams(netuid) - .map(|params| params.registration_allowed) - .unwrap_or(false) - } - /// Computes and sets emission values for the root network which determine the emission for all subnets. /// /// This function is responsible for calculating emission based on network weights, stake values, diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index d919c6dbb..bd54269c2 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -803,18 +803,6 @@ impl Pallet { I32F32::from_num(Self::get_kappa(netuid)).saturating_div(I32F32::from_num(u16::MAX)) } - pub fn get_normalized_stake(netuid: u16) -> Vec { - let n = Self::get_subnetwork_n(netuid); - let mut stake_64: Vec = (0..n) - .map(|neuron_uid| { - I64F64::from_num(Self::get_stake_for_uid_and_subnetwork(netuid, neuron_uid)) - }) - .collect(); - inplace_normalize_64(&mut stake_64); - let stake: Vec = vec_fixed64_to_fixed32(stake_64); - stake - } - pub fn get_block_at_registration(netuid: u16) -> Vec { let n = Self::get_subnetwork_n(netuid); let block_at_registration: Vec = (0..n) diff --git a/pallets/subtensor/src/macros/errors.rs b/pallets/subtensor/src/macros/errors.rs index aab849994..be5c03138 100644 --- a/pallets/subtensor/src/macros/errors.rs +++ b/pallets/subtensor/src/macros/errors.rs @@ -22,33 +22,42 @@ mod errors { HotKeyAccountNotExists, /// The hotkey is not registered in any subnet. HotKeyNotRegisteredInNetwork, - /// Request to stake, unstake or subscribe is made by a coldkey that is not associated with the hotkey account. + /// Request to stake, unstake or subscribe is made by a coldkey that is not associated with + /// the hotkey account. NonAssociatedColdKey, /// The hotkey is not a delegate and the signer is not the owner of the hotkey. HotKeyNotDelegateAndSignerNotOwnHotKey, /// Stake amount to withdraw is zero. StakeToWithdrawIsZero, - /// The caller is requesting removing more stake than there exists in the staking account. See: "[remove_stake()]". + /// The caller is requesting removing more stake than there exists in the staking account. + /// See: "[remove_stake()]". NotEnoughStakeToWithdraw, - /// The caller is requesting to set weights but the caller has less than minimum stake required to set weights (less than WeightsMinStake). + /// The caller is requesting to set weights but the caller has less than minimum stake + /// required to set weights (less than WeightsMinStake). NotEnoughStakeToSetWeights, - /// The caller is requesting adding more stake than there exists in the coldkey account. See: "[add_stake()]" + /// The caller is requesting adding more stake than there exists in the coldkey account. + /// See: "[add_stake()]" NotEnoughBalanceToStake, - /// The caller is trying to add stake, but for some reason the requested amount could not be withdrawn from the coldkey account. + /// The caller is trying to add stake, but for some reason the requested amount could not be + /// withdrawn from the coldkey account. BalanceWithdrawalError, - /// Unsuccessfully withdraw, balance could be zero (can not make account exist) after withdrawal. + /// Unsuccessfully withdraw, balance could be zero (can not make account exist) after + /// withdrawal. ZeroBalanceAfterWithdrawn, /// The caller is attempting to set non-self weights without being a permitted validator. NeuronNoValidatorPermit, - /// The caller is attempting to set the weight keys and values but these vectors have different size. + /// The caller is attempting to set the weight keys and values but these vectors have + /// different size. WeightVecNotEqualSize, /// The caller is attempting to set weights with duplicate UIDs in the weight matrix. DuplicateUids, - /// The caller is attempting to set weight to at least one UID that does not exist in the metagraph. + /// The caller is attempting to set weight to at least one UID that does not exist in the + /// metagraph. UidVecContainInvalidOne, /// The dispatch is attempting to set weights on chain with fewer elements than are allowed. WeightVecLengthIsLow, - /// Number of registrations in this block exceeds the allowed number (i.e., exceeds the subnet hyperparameter "max_regs_per_block"). + /// Number of registrations in this block exceeds the allowed number (i.e., exceeds the + /// subnet hyperparameter "max_regs_per_block"). TooManyRegistrationsThisBlock, /// The caller is requesting registering a neuron which already exists in the active set. HotKeyAlreadyRegisteredInSubNet, @@ -60,7 +69,8 @@ mod errors { InvalidDifficulty, /// The supplied PoW hash seal does not match the supplied work. InvalidSeal, - /// The dispatch is attempting to set weights on chain with weight value exceeding the MaxWeightLimit (max_weight_limit subnet hyperparameter). + /// The dispatch is attempting to set weights on chain with weight value exceeding the + /// MaxWeightLimit (max_weight_limit subnet hyperparameter). MaxWeightExceeded, /// The hotkey is attempting to become a delegate when the hotkey is already a delegate. HotKeyAlreadyDelegate, @@ -114,7 +124,8 @@ mod errors { DelegateTakeTooLow, /// Delegate take is too high. DelegateTakeTooHigh, - /// No commit found for the provided hotkey+netuid combination when attempting to reveal the weights. + /// No commit found for the provided hotkey+netuid combination when attempting to reveal the + /// weights. NoWeightsCommitFound, /// Committed hash does not equal the hashed reveal data. InvalidRevealCommitHashNotMatch, @@ -132,28 +143,10 @@ mod errors { AlphaLowOutOfRange, /// The coldkey has already been swapped ColdKeyAlreadyAssociated, - /// The coldkey swap transaction rate limit exceeded - ColdKeySwapTxRateLimitExceeded, - /// The new coldkey is the same as the old coldkey - NewColdKeyIsSameWithOld, - /// The coldkey does not exist - NotExistColdkey, /// The coldkey balance is not enough to pay for the swap NotEnoughBalanceToPaySwapColdKey, - /// No balance to transfer - NoBalanceToTransfer, - /// Same coldkey - SameColdkey, /// The coldkey is in arbitration ColdkeyIsInArbitration, - /// The new coldkey is already registered for the drain - DuplicateColdkey, - /// Error thrown on a coldkey swap. - ColdkeySwapError, - /// Insufficient Balance to Schedule coldkey swap - InsufficientBalanceToPerformColdkeySwap, - /// The maximum number of coldkey destinations has been reached - MaxColdkeyDestinationsReached, /// Attempting to set an invalid child for a hotkey on a network. InvalidChild, /// Duplicate child when setting children. @@ -164,16 +157,12 @@ mod errors { TooManyChildren, /// Default transaction rate limit exceeded. TxRateLimitExceeded, - /// Swap coldkey only callable by root. - SwapColdkeyOnlyCallableByRoot, /// Swap already scheduled. SwapAlreadyScheduled, /// failed to swap coldkey FailedToSchedule, /// New coldkey is hotkey NewColdKeyIsHotkey, - /// New coldkey is in arbitration - NewColdkeyIsInArbitration, /// Childkey take is invalid. InvalidChildkeyTake, /// Childkey take rate limit exceeded. diff --git a/pallets/subtensor/src/rpc_info/delegate_info.rs b/pallets/subtensor/src/rpc_info/delegate_info.rs index a41b6e17e..a877a9730 100644 --- a/pallets/subtensor/src/rpc_info/delegate_info.rs +++ b/pallets/subtensor/src/rpc_info/delegate_info.rs @@ -156,20 +156,6 @@ impl Pallet { total_delegated } - // Helper function to get total delegated stake for a hotkey - pub fn get_total_hotkey_delegated_stake(hotkey: &T::AccountId) -> u64 { - let mut total_delegated = 0u64; - - // Iterate through all delegators for this hotkey - for (delegator, stake) in Stake::::iter_prefix(hotkey) { - if delegator != Self::get_coldkey_for_hotkey(hotkey) { - total_delegated = total_delegated.saturating_add(stake); - } - } - - total_delegated - } - // Helper function to get the coldkey associated with a hotkey pub fn get_coldkey_for_hotkey(hotkey: &T::AccountId) -> T::AccountId { Owner::::get(hotkey) diff --git a/pallets/subtensor/src/staking/helpers.rs b/pallets/subtensor/src/staking/helpers.rs index 9fd60ea51..af3037b10 100644 --- a/pallets/subtensor/src/staking/helpers.rs +++ b/pallets/subtensor/src/staking/helpers.rs @@ -341,13 +341,6 @@ impl Pallet { let _ = T::Currency::deposit(coldkey, amount, Precision::BestEffort); } - pub fn set_balance_on_coldkey_account( - coldkey: &T::AccountId, - amount: <::Currency as fungible::Inspect<::AccountId>>::Balance, - ) { - T::Currency::set_balance(coldkey, amount); - } - pub fn can_remove_balance_from_coldkey_account( coldkey: &T::AccountId, amount: <::Currency as fungible::Inspect<::AccountId>>::Balance, diff --git a/pallets/subtensor/src/subnets/serving.rs b/pallets/subtensor/src/subnets/serving.rs index 7e2b9a0f0..647b328cc 100644 --- a/pallets/subtensor/src/subnets/serving.rs +++ b/pallets/subtensor/src/subnets/serving.rs @@ -246,14 +246,6 @@ impl Pallet { rate_limit == 0 || last_serve == 0 || current_block.saturating_sub(last_serve) >= rate_limit } - pub fn has_axon_info(netuid: u16, hotkey: &T::AccountId) -> bool { - Axons::::contains_key(netuid, hotkey) - } - - pub fn has_prometheus_info(netuid: u16, hotkey: &T::AccountId) -> bool { - Prometheus::::contains_key(netuid, hotkey) - } - pub fn get_axon_info(netuid: u16, hotkey: &T::AccountId) -> AxonInfoOf { if let Some(axons) = Axons::::get(netuid, hotkey) { axons diff --git a/pallets/subtensor/src/subnets/uids.rs b/pallets/subtensor/src/subnets/uids.rs index 61b6be70b..dddeb7498 100644 --- a/pallets/subtensor/src/subnets/uids.rs +++ b/pallets/subtensor/src/subnets/uids.rs @@ -127,12 +127,6 @@ impl Pallet { } } - /// Return the total number of subnetworks available on the chain. - /// - pub fn get_number_of_subnets() -> u16 { - as IterableStorageMap>::iter().count() as u16 - } - /// Return a list of all networks a hotkey is registered on. /// pub fn get_registered_networks_for_hotkey(hotkey: &T::AccountId) -> Vec { diff --git a/pallets/subtensor/src/utils/misc.rs b/pallets/subtensor/src/utils/misc.rs index 57cc38786..e69506507 100644 --- a/pallets/subtensor/src/utils/misc.rs +++ b/pallets/subtensor/src/utils/misc.rs @@ -424,9 +424,6 @@ impl Pallet { Self::deposit_event(Event::AdjustmentAlphaSet(netuid, adjustment_alpha)); } - pub fn get_validator_prune_len(netuid: u16) -> u64 { - ValidatorPruneLen::::get(netuid) - } pub fn set_validator_prune_len(netuid: u16, validator_prune_len: u64) { ValidatorPruneLen::::insert(netuid, validator_prune_len); Self::deposit_event(Event::ValidatorPruneLenSet(netuid, validator_prune_len)); diff --git a/pallets/subtensor/src/utils/rate_limiting.rs b/pallets/subtensor/src/utils/rate_limiting.rs index b02ad9855..f3668f514 100644 --- a/pallets/subtensor/src/utils/rate_limiting.rs +++ b/pallets/subtensor/src/utils/rate_limiting.rs @@ -57,15 +57,6 @@ impl Pallet { last_block == 0 || block.saturating_sub(last_block) >= limit } - /// Check if a transaction should be rate limited globally - pub fn passes_rate_limit_globally(tx_type: &TransactionType, hotkey: &T::AccountId) -> bool { - let netuid: u16 = u16::MAX; - let block: u64 = Self::get_current_block_as_u64(); - let limit: u64 = Self::get_rate_limit(tx_type); - let last_block: u64 = Self::get_last_transaction_block(hotkey, netuid, tx_type); - block.saturating_sub(last_block) >= limit - } - /// Get the block number of the last transaction for a specific hotkey, network, and transaction type pub fn get_last_transaction_block( hotkey: &T::AccountId, @@ -99,10 +90,6 @@ impl Pallet { pub fn get_last_tx_block_delegate_take(key: &T::AccountId) -> u64 { LastTxBlockDelegateTake::::get(key) } - - pub fn set_last_tx_block_childkey_take(key: &T::AccountId, block: u64) { - LastTxBlockChildKeyTake::::insert(key, block) - } pub fn get_last_tx_block_childkey_take(key: &T::AccountId) -> u64 { LastTxBlockChildKeyTake::::get(key) }