From 2aad6fe60e4c6f77841452bea46717dcb0f9f1e3 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Mon, 2 Sep 2024 21:20:00 +0800 Subject: [PATCH] cleanup get_neuron_certificate --- pallets/subtensor/src/rpc_info/neuron_info.rs | 17 ----------------- pallets/subtensor/src/subnets/serving.rs | 4 ---- pallets/subtensor/tests/serving.rs | 10 +++++----- pallets/subtensor/tests/uids.rs | 2 +- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/pallets/subtensor/src/rpc_info/neuron_info.rs b/pallets/subtensor/src/rpc_info/neuron_info.rs index 065855b04..cadd4b6e3 100644 --- a/pallets/subtensor/src/rpc_info/neuron_info.rs +++ b/pallets/subtensor/src/rpc_info/neuron_info.rs @@ -147,23 +147,6 @@ impl Pallet { Some(neuron) } - pub fn get_neuron_certificate(netuid: u16, uid: u16) -> Option { - 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::::get(netuid, hotkey) - } else { - None - } - } - pub fn get_neuron(netuid: u16, uid: u16) -> Option> { if !Self::if_subnet_exist(netuid) { return None; diff --git a/pallets/subtensor/src/subnets/serving.rs b/pallets/subtensor/src/subnets/serving.rs index e6c1a62d7..22550fb93 100644 --- a/pallets/subtensor/src/subnets/serving.rs +++ b/pallets/subtensor/src/subnets/serving.rs @@ -252,10 +252,6 @@ impl Pallet { Axons::::contains_key(netuid, hotkey) } - pub fn has_neuron_certificate(netuid: u16, hotkey: &T::AccountId) -> bool { - NeuronCertificates::::contains_key(netuid, hotkey) - } - pub fn has_prometheus_info(netuid: u16, hotkey: &T::AccountId) -> bool { Prometheus::::contains_key(netuid, hotkey) } diff --git a/pallets/subtensor/tests/serving.rs b/pallets/subtensor/tests/serving.rs index a0988fc02..17b8d2144 100644 --- a/pallets/subtensor/tests/serving.rs +++ b/pallets/subtensor/tests/serving.rs @@ -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; @@ -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::::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( @@ -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::::get(netuid, hotkey_account_id) + .expect("Certificate should exist"); assert_eq!(stored_certificate.certificate, new_certificate) }); } diff --git a/pallets/subtensor/tests/uids.rs b/pallets/subtensor/tests/uids.rs index 743471b5d..827d4ec1a 100644 --- a/pallets/subtensor/tests/uids.rs +++ b/pallets/subtensor/tests/uids.rs @@ -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::::get(netuid, hotkey_account_id); assert_eq!(certificate, None); }); }