-
Notifications
You must be signed in to change notification settings - Fork 150
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
reset neuron data on dereg #755
base: devnet-ready
Are you sure you want to change the base?
reset neuron data on dereg #755
Conversation
@andreea-popescu-reef also changed the base against |
bdd5e14
to
5e425fb
Compare
} | ||
|
||
/// Resets the trust, emission, consensus, incentive, dividends of the neuron to default | ||
pub fn clear_neuron(netuid: u16, neuron_uid: u16) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we optimise this by reducing the number of storage / writes , and number of function calls ?
pub fn clear_neuron(netuid: u16, neuron_uid: u16) {
let neuron_index: usize = neuron_uid.into();
let default_value = 0;
for storage in &mut [
&mut Emission::<T>::get(netuid),
&mut Trust::<T>::get(netuid),
&mut Consensus::<T>::get(netuid),
&mut Incentive::<T>::get(netuid),
&mut Dividends::<T>::get(netuid),
] {
set_element_at(storage, neuron_index, default_value);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that does not quite work as the vectors have different int types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the same number of calls to the set_element_at. is there much difference between get vs mutate calls? aren't they compiled to similar things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyway made the change
5e425fb
to
5e45f5c
Compare
reviving: #522
Description
On neuron registration the trust, emission, consensus, incentive, dividends values as well as axon info associated with the assigned neuron_uid are inherited from the previous neuron. Thus for the first few blocks after registration these values will be wrong, then reset to zero and then get populated with the correct values for the newly registered neuron. This change resets these values on neuron registration.