Skip to content

Commit

Permalink
Merge pull request #299 from opentensor/junius/tiny-fixes
Browse files Browse the repository at this point in the history
tiny fixes
  • Loading branch information
open-junius committed Apr 9, 2024
2 parents 18f2c94 + db3d92a commit 42b3873
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
12 changes: 6 additions & 6 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub mod pallet {
T::InitialSenateRequiredStakePercentage::get()
}

#[pallet::storage] // --- ITEM ( tx_rate_limit )
#[pallet::storage]
pub(super) type SenateRequiredStakePercentage<T> =
StorageValue<_, u64, ValueQuery, DefaultSenateRequiredStakePercentage<T>>;

Expand Down Expand Up @@ -425,7 +425,7 @@ pub mod pallet {
T::InitialNetworkRateLimit::get()
}

#[pallet::storage] // --- ITEM( total_number_of_existing_networks )
#[pallet::storage] // --- ITEM( maximum_number_of_networks )
pub type SubnetLimit<T> = StorageValue<_, u16, ValueQuery, DefaultSubnetLimit<T>>;
#[pallet::storage] // --- ITEM( total_number_of_existing_networks )
pub type TotalNetworks<T> = StorageValue<_, u16, ValueQuery>;
Expand Down Expand Up @@ -518,16 +518,16 @@ pub mod pallet {
#[pallet::storage] // --- MAP ( netuid ) --> pending_emission
pub type PendingEmission<T> =
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultPendingEmission<T>>;
#[pallet::storage] // --- MAP ( netuid ) --> blocks_since_last_step.
#[pallet::storage] // --- MAP ( netuid ) --> blocks_since_last_step
pub type BlocksSinceLastStep<T> =
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultBlocksSinceLastStep<T>>;
#[pallet::storage] // --- MAP ( netuid ) --> last_mechanism_step_block
pub type LastMechansimStepBlock<T> =
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultLastMechanismStepBlock<T>>;
#[pallet::storage]
#[pallet::storage] // --- MAP ( netuid ) --> subnet_owner
pub type SubnetOwner<T: Config> =
StorageMap<_, Identity, u16, T::AccountId, ValueQuery, DefaultSubnetOwner<T>>;
#[pallet::storage]
#[pallet::storage] // --- MAP ( netuid ) --> subnet_locked
pub type SubnetLocked<T: Config> =
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultSubnetLocked<T>>;

Expand All @@ -547,7 +547,7 @@ pub mod pallet {
pub ip_type: u8, // --- Axon ip type, 4 for ipv4 and 6 for ipv6.
pub protocol: u8, // --- Axon protocol. TCP, UDP, other.
pub placeholder1: u8, // --- Axon proto placeholder 1.
pub placeholder2: u8, // --- Axon proto placeholder 1.
pub placeholder2: u8, // --- Axon proto placeholder 2.
}

// --- Struct for Prometheus.
Expand Down
17 changes: 10 additions & 7 deletions pallets/subtensor/src/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,19 @@ impl<T: Config> Pallet<T> {
let mut min_score_in_immunity_period = u16::MAX;
let mut uid_with_min_score = 0;
let mut uid_with_min_score_in_immunity_period: u16 = 0;
if Self::get_subnetwork_n(netuid) == 0 {
return 0;
} // If there are no neurons in this network.
for neuron_uid_i in 0..Self::get_subnetwork_n(netuid) {

let neurons_n = Self::get_subnetwork_n(netuid);
if neurons_n == 0 {
return 0; // If there are no neurons in this network.
}

let current_block: u64 = Self::get_current_block_as_u64();
let immunity_period: u64 = Self::get_immunity_period(netuid) as u64;
for neuron_uid_i in 0..neurons_n {
let pruning_score: u16 = Self::get_pruning_score_for_uid(netuid, neuron_uid_i);
let block_at_registration: u64 =
Self::get_neuron_block_at_registration(netuid, neuron_uid_i);
let current_block: u64 = Self::get_current_block_as_u64();
let immunity_period: u64 = Self::get_immunity_period(netuid) as u64;

if min_score == pruning_score {
if current_block - block_at_registration < immunity_period {
//neuron is in immunity period
Expand All @@ -443,7 +447,6 @@ impl<T: Config> Pallet<T> {
uid_with_min_score_in_immunity_period = neuron_uid_i;
}
} else {
min_score = pruning_score;
uid_with_min_score = neuron_uid_i;
}
}
Expand Down

0 comments on commit 42b3873

Please sign in to comment.