Skip to content

Commit

Permalink
cleanup get_neuron_certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
andreea-popescu-reef committed Sep 2, 2024
1 parent 05d0d8d commit 2aad6fe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 27 deletions.
17 changes: 0 additions & 17 deletions pallets/subtensor/src/rpc_info/neuron_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,6 @@ impl<T: Config> Pallet<T> {
Some(neuron)
}

pub fn get_neuron_certificate(netuid: u16, uid: u16) -> Option<NeuronCertificate> {
if !Self::if_subnet_exist(netuid) {
return None;
}

let hotkey = match Self::get_hotkey_for_net_and_uid(netuid, uid) {
Ok(h) => h,
Err(_) => return None,
};

if Self::has_neuron_certificate(netuid, &hotkey) {
NeuronCertificates::<T>::get(netuid, hotkey)
} else {
None
}
}

pub fn get_neuron(netuid: u16, uid: u16) -> Option<NeuronInfo<T>> {
if !Self::if_subnet_exist(netuid) {
return None;
Expand Down
4 changes: 0 additions & 4 deletions pallets/subtensor/src/subnets/serving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ impl<T: Config> Pallet<T> {
Axons::<T>::contains_key(netuid, hotkey)
}

pub fn has_neuron_certificate(netuid: u16, hotkey: &T::AccountId) -> bool {
NeuronCertificates::<T>::contains_key(netuid, hotkey)
}

pub fn has_prometheus_info(netuid: u16, hotkey: &T::AccountId) -> bool {
Prometheus::<T>::contains_key(netuid, hotkey)
}
Expand Down
10 changes: 5 additions & 5 deletions pallets/subtensor/tests/serving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ fn test_serving_ok() {
fn test_serving_tls_ok() {
new_test_ext(1).execute_with(|| {
let hotkey_account_id = U256::from(1);
let uid: u16 = 0;
let netuid: u16 = 1;
let tempo: u16 = 13;
let version: u32 = 2;
Expand All @@ -129,8 +128,9 @@ fn test_serving_tls_ok() {
placeholder2,
certificate.clone()
));
let stored_certificate =
SubtensorModule::get_neuron_certificate(netuid, uid).expect("Certificate should exist");

let stored_certificate = NeuronCertificates::<Test>::get(netuid, hotkey_account_id)
.expect("Certificate should exist");
assert_eq!(stored_certificate.certificate, certificate);
let new_certificate = "UPDATED_CERT".as_bytes().to_vec();
assert_ok!(SubtensorModule::serve_axon_tls(
Expand All @@ -145,8 +145,8 @@ fn test_serving_tls_ok() {
placeholder2,
new_certificate.clone()
));
let stored_certificate =
SubtensorModule::get_neuron_certificate(netuid, uid).expect("Certificate should exist");
let stored_certificate = NeuronCertificates::<Test>::get(netuid, hotkey_account_id)
.expect("Certificate should exist");
assert_eq!(stored_certificate.certificate, new_certificate)
});
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/subtensor/tests/uids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn test_replace_neuron() {
assert_eq!(curr_hotkey.unwrap(), new_hotkey_account_id);

// Check neuron certificate was reset
let certificate = SubtensorModule::get_neuron_certificate(netuid, neuron_uid.unwrap());
let certificate = NeuronCertificates::<Test>::get(netuid, hotkey_account_id);
assert_eq!(certificate, None);
});
}
Expand Down

0 comments on commit 2aad6fe

Please sign in to comment.