Skip to content

Commit

Permalink
Remove get_prometheus and get_pruning_score from pallet-subtensor::Pa…
Browse files Browse the repository at this point in the history
…llet
  • Loading branch information
ales-otf committed Dec 16, 2024
1 parent c250ffd commit c28300f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 23 deletions.
4 changes: 2 additions & 2 deletions pallets/subtensor/src/rpc_info/neuron_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<T: Config> Pallet<T> {

let axon_info = Axons::<T>::get(netuid, &hotkey).unwrap_or_default();

let prometheus_info = Self::get_prometheus_info(netuid, &hotkey);
let prometheus_info = Prometheus::<T>::get(netuid, &hotkey).unwrap_or_default();

let coldkey = Owner::<T>::get(hotkey.clone()).clone();

Expand Down Expand Up @@ -162,7 +162,7 @@ impl<T: Config> Pallet<T> {

let axon_info = Axons::<T>::get(netuid, &hotkey).unwrap_or_default();

let prometheus_info = Self::get_prometheus_info(netuid, &hotkey);
let prometheus_info = Prometheus::<T>::get(netuid, &hotkey).unwrap_or_default();

let coldkey = Owner::<T>::get(&hotkey).clone();

Expand Down
16 changes: 1 addition & 15 deletions pallets/subtensor/src/subnets/serving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<T: Config> Pallet<T> {
);

// We get the previous axon info assoicated with this ( netuid, uid )
let mut prev_prometheus = Self::get_prometheus_info(netuid, &hotkey_id);
let mut prev_prometheus = Prometheus::<T>::get(netuid, &hotkey_id).unwrap_or_default();
let current_block: u64 = Self::get_current_block_as_u64();
ensure!(
Self::prometheus_passes_rate_limit(netuid, &prev_prometheus, current_block),
Expand Down Expand Up @@ -247,20 +247,6 @@ impl<T: Config> Pallet<T> {
rate_limit == 0 || last_serve == 0 || current_block.saturating_sub(last_serve) >= rate_limit
}

pub fn get_prometheus_info(netuid: u16, hotkey: &T::AccountId) -> PrometheusInfoOf {
if let Some(prometheus) = Prometheus::<T>::get(netuid, hotkey) {
prometheus
} else {
PrometheusInfo {
block: 0,
version: 0,
ip: 0,
port: 0,
ip_type: 0,
}
}
}

pub fn is_valid_ip_type(ip_type: u8) -> bool {
let allowed_values = [4, 6];
allowed_values.contains(&ip_type)
Expand Down
6 changes: 3 additions & 3 deletions pallets/subtensor/src/tests/serving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ fn test_prometheus_serving_ok() {
port,
ip_type
));
let neuron = SubtensorModule::get_prometheus_info(netuid, &hotkey_account_id);
let neuron = Prometheus::<Test>::get(netuid, hotkey_account_id).unwrap_or_default();
assert_eq!(neuron.ip, ip);
assert_eq!(neuron.version, version);
assert_eq!(neuron.port, port);
Expand Down Expand Up @@ -413,7 +413,7 @@ fn test_prometheus_serving_set_metadata_update() {
port,
ip_type
));
let neuron = SubtensorModule::get_prometheus_info(netuid, &hotkey_account_id);
let neuron = Prometheus::<Test>::get(netuid, hotkey_account_id).unwrap_or_default();
assert_eq!(neuron.ip, ip);
assert_eq!(neuron.version, version);
assert_eq!(neuron.port, port);
Expand All @@ -430,7 +430,7 @@ fn test_prometheus_serving_set_metadata_update() {
port2,
ip_type2
));
let neuron = SubtensorModule::get_prometheus_info(netuid, &hotkey_account_id);
let neuron = Prometheus::<Test>::get(netuid, hotkey_account_id).unwrap_or_default();
assert_eq!(neuron.ip, ip2);
assert_eq!(neuron.version, version2);
assert_eq!(neuron.port, port2);
Expand Down
3 changes: 0 additions & 3 deletions pallets/subtensor/src/utils/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ impl<T: Config> Pallet<T> {
Trust::<T>::get(netuid)
}

pub fn get_pruning_score(netuid: u16) -> Vec<u16> {
PruningScores::<T>::get(netuid)
}
pub fn get_validator_trust(netuid: u16) -> Vec<u16> {
ValidatorTrust::<T>::get(netuid)
}
Expand Down

0 comments on commit c28300f

Please sign in to comment.