reset neuron data on registration#522
reset neuron data on registration#522andreea-popescu-reef wants to merge 5 commits intoopentensor:mainfrom
Conversation
|
@distributedstatemachine I don't think I'm doing any math operations |
|
Apologies @andreea-popescu-reef , i meant unsafe , or potentially panicing operation. @keithtensor can you take a look ? the CI should catch these |
56a0328 to
4e4af9d
Compare
pallets/subtensor/src/uids.rs
Outdated
| } | ||
|
|
||
| pub fn set_emission_for_uid(netuid: u16, neuron_uid: u16, emission: u64) { | ||
| Emission::<T>::mutate(netuid, |v| v[neuron_uid as usize] = emission); |
There was a problem hiding this comment.
Could this direct indexing panic? cc @keithtensor
4e4af9d to
85895a4
Compare
85895a4 to
44ce566
Compare
pallets/subtensor/src/uids.rs
Outdated
|
|
||
| /// Resets the trust, emission, consensus, incentive, dividends of the neuron to default | ||
| pub fn clear_neuron(netuid: u16, neuron_uid: u16) { | ||
| Emission::<T>::mutate(netuid, |v| v[neuron_uid as usize] = 0); |
There was a problem hiding this comment.
can you add the length check before index with neuron_uid.
232f687 to
51fc171
Compare
| SubnetworkN::<T>::get(netuid) | ||
| } | ||
|
|
||
| fn clear_element_at<N>(position: u16) -> impl Fn(&mut Vec<N>) |
There was a problem hiding this comment.
We are almost there! can you please add doc comments to this , as it would break some lints down the line.
I will get this approved today , and move it through our deployment process. I estimate this change would be on testnet in about 2 weeks
There was a problem hiding this comment.
right, added.
thanks!
There was a problem hiding this comment.
@distributedstatemachine could you take a look at this again?
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.
Related Issue(s)
N/A
Type of Change
Breaking Change
no
Checklist
cargo fmtandcargo clippyto ensure my code is formatted and linted correctlyScreenshots (if applicable)
N/A
Additional Notes
N/A