Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tiny fixes & improvements #284

Merged
merged 2 commits into from
Apr 9, 2024
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
12 changes: 6 additions & 6 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,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 @@ -397,7 +397,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 @@ -490,16 +490,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, DefaultLastMechansimStepBlock<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 @@ -519,7 +519,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 @@ -432,15 +432,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 @@ -449,7 +453,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