fix: clear ValidatorTrust/ValidatorPermit on neuron replace#2609
Open
boskodev790 wants to merge 1 commit intoopentensor:mainfrom
Open
fix: clear ValidatorTrust/ValidatorPermit on neuron replace#2609boskodev790 wants to merge 1 commit intoopentensor:mainfrom
boskodev790 wants to merge 1 commit intoopentensor:mainfrom
Conversation
clear_neuron zeroed the per-UID slot of Emission, Consensus, Incentive, Dividends, StakeWeight, Bonds and Weights, but missed ValidatorTrust and ValidatorPermit. Both are Vec<_>-per-netuid storage that append_neuron initialises on a fresh UID, so when replace_neuron reuses a UID it currently left the old occupant's validator_permit=true flag and validator_trust score in place until the next epoch recomputed the vectors. Between replacement and the next epoch, RPC surfaces (delegate_info, show_subnet) and on-chain readers (trim_to_max_allowed_uids and the per-mechanism validator aggregation in mechanism.rs) observed stale validator state for the freshly registered neuron. Same class of stale-inheritance bug PR opentensor#755 was introduced to fix; these two fields were missed there. - clear_neuron now also zeroes ValidatorTrust[uid] and resets ValidatorPermit[uid] = false, using the same set_element_at idiom already applied to the other vec-per-netuid fields two lines above. - Add test_replace_neuron_clears_validator_trust_and_permit mirroring the existing test_replace_neuron_resets_last_update style.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
clear_neuron zeroed the per-UID slot of Emission, Consensus, Incentive, Dividends, StakeWeight, Bonds and Weights, but missed ValidatorTrust and ValidatorPermit. Both are Vec<_>-per-netuid storage that append_neuron initialises on a fresh UID, so when replace_neuron reuses a UID it currently left the old occupant's validator_permit=true flag and validator_trust score in place until the next epoch recomputed the vectors.
Between replacement and the next epoch, RPC surfaces (delegate_info, show_subnet) and on-chain readers (trim_to_max_allowed_uids and the per-mechanism validator aggregation in mechanism.rs) observed stale validator state for the freshly registered neuron.
Same class of stale-inheritance bug PR #755 was introduced to fix; these two fields were missed there.
Description
Related Issue(s)
Type of Change
Breaking Change
If this PR introduces a breaking change, please provide a detailed description of the impact and the migration path for existing applications.
Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyScreenshots (if applicable)
Please include any relevant screenshots or GIFs that demonstrate the changes made.
Additional Notes
Please provide any additional information or context that may be helpful for reviewers.