Skip to content

Commit d492d31

Browse files
committed
missed prometheus cleaning
1 parent 66114d4 commit d492d31

File tree

2 files changed

+11
-31
lines changed

2 files changed

+11
-31
lines changed

pallets/subtensor/src/subnets/uids.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,13 @@ impl<T: Config> Pallet<T> {
8888
BlockAtRegistration::<T>::insert(netuid, uid_to_replace, block_number); // Fill block at registration.
8989
IsNetworkMember::<T>::insert(new_hotkey.clone(), netuid, true); // Fill network is member.
9090

91-
// 4. Clear neuron certificates
92-
NeuronCertificates::<T>::remove(netuid, old_hotkey.clone());
91+
// 4. Clear neuron axons, certificates and prometheus info
92+
Axons::<T>::remove(netuid, &old_hotkey);
93+
NeuronCertificates::<T>::remove(netuid, &old_hotkey);
94+
Prometheus::<T>::remove(netuid, &old_hotkey);
9395

9496
// 5. Reset new neuron's values.
9597
Self::clear_neuron(netuid, uid_to_replace);
96-
97-
// 5a. reset axon info for the new uid.
98-
Axons::<T>::remove(netuid, old_hotkey);
9998
}
10099

101100
/// Appends the uid to the network.

pallets/subtensor/src/tests/uids.rs

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ fn test_replace_neuron() {
3232

3333
let new_hotkey_account_id = U256::from(2);
3434
let _new_colkey_account_id = U256::from(12345);
35-
let certificate = NeuronCertificate::try_from(vec![1, 2, 3]).unwrap();
3635
let evm_address = H160::from_slice(&[1_u8; 20]);
3736
//add network
3837
add_network(netuid, tempo, 0);
@@ -71,28 +70,11 @@ fn test_replace_neuron() {
7170
});
7271
Bonds::<Test>::insert(NetUidStorageIndex::from(netuid), neuron_uid, vec![(0, 1)]);
7372

74-
// serve axon mock address
75-
let ip: u128 = 1676056785;
76-
let port: u16 = 9999;
77-
let ip_type: u8 = 4;
78-
assert!(
79-
SubtensorModule::serve_axon(
80-
<<Test as Config>::RuntimeOrigin>::signed(hotkey_account_id),
81-
netuid,
82-
0,
83-
ip,
84-
port,
85-
ip_type,
86-
0,
87-
0,
88-
0
89-
)
90-
.is_ok()
91-
);
92-
93-
// Set a neuron certificate for it
94-
NeuronCertificates::<Test>::insert(netuid, hotkey_account_id, certificate);
73+
Axons::<Test>::insert(netuid, hotkey_account_id, AxonInfoOf::default());
74+
NeuronCertificates::<Test>::insert(netuid, hotkey_account_id, NeuronCertificateOf::default());
75+
Prometheus::<Test>::insert(netuid, hotkey_account_id, PrometheusInfoOf::default());
9576
AssociatedEvmAddress::<Test>::insert(netuid, neuron_uid, (evm_address, 1));
77+
9678
// Replace the neuron.
9779
SubtensorModule::replace_neuron(netuid, neuron_uid, &new_hotkey_account_id, block_number);
9880

@@ -139,10 +121,9 @@ fn test_replace_neuron() {
139121
);
140122

141123
// Check axon info is reset.
142-
let axon_info = SubtensorModule::get_axon_info(netuid, &curr_hotkey.unwrap());
143-
assert_eq!(axon_info.ip, 0);
144-
assert_eq!(axon_info.port, 0);
145-
assert_eq!(axon_info.ip_type, 0);
124+
assert!(!Axons::<Test>::contains_key(netuid, curr_hotkey.unwrap()));
125+
assert!(!NeuronCertificates::<Test>::contains_key(netuid, curr_hotkey.unwrap()));
126+
assert!(!Prometheus::<Test>::contains_key(netuid, curr_hotkey.unwrap()));
146127

147128
// Check bonds are cleared.
148129
assert_eq!(

0 commit comments

Comments
 (0)