Skip to content

reset neuron data on dereg#755

Merged
camfairchild merged 1 commit into
opentensor:devnet-readyfrom
backend-developers-ltd:fix-reg
Jan 27, 2025
Merged

reset neuron data on dereg#755
camfairchild merged 1 commit into
opentensor:devnet-readyfrom
backend-developers-ltd:fix-reg

Conversation

@andreea-popescu-reef
Copy link
Copy Markdown
Contributor

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.

Comment thread pallets/subtensor/src/uids.rs Outdated
@distributedstatemachine distributedstatemachine changed the base branch from main to devnet-ready August 27, 2024 12:55
@distributedstatemachine
Copy link
Copy Markdown
Contributor

@andreea-popescu-reef also changed the base against devnet-ready , so you need to resolve conflicts , or fork off devnet-ready

@andreea-popescu-reef andreea-popescu-reef force-pushed the fix-reg branch 2 times, most recently from bdd5e14 to 5e425fb Compare August 31, 2024 08:54
Comment thread pallets/subtensor/src/subnets/uids.rs
@andreea-popescu-reef
Copy link
Copy Markdown
Contributor Author

rebased this pr

@andreea-popescu-reef andreea-popescu-reef force-pushed the fix-reg branch 2 times, most recently from ef3ce2d to a0f769a Compare November 15, 2024 13:54
Comment thread runtime/src/lib.rs Outdated
camfairchild
camfairchild previously approved these changes Nov 26, 2024
basfroman
basfroman previously approved these changes Nov 26, 2024
@andreea-popescu-reef
Copy link
Copy Markdown
Contributor Author

rebased again

@camfairchild camfairchild added no-spec-version-bump PR does not contain changes that requires bumping the spec version skip-cargo-audit This PR fails cargo audit but needs to be merged anyway labels Jan 27, 2025
@camfairchild camfairchild removed the request for review from basfroman January 27, 2025 12:29
@camfairchild camfairchild merged commit 2ba69b1 into opentensor:devnet-ready Jan 27, 2025
@ppolewicz ppolewicz deleted the fix-reg branch March 16, 2025 21:14
boskodev790 added a commit to boskodev790/subtensor that referenced this pull request May 11, 2026
clear_neuron zeroed the per-UID slot of Emission, Consensus, Incentive,
Dividends, StakeWeight, Bonds and Weights, but missed Active,
ValidatorTrust, and ValidatorPermit. All three are Vec<_>-per-netuid
storage (Active and ValidatorPermit are Vec<bool> via EmptyBoolVec;
ValidatorTrust is Vec<u16> via EmptyU16Vec) that append_neuron
initialises on a fresh UID, so when replace_neuron reuses a UID it
currently left the old occupant's active=true flag, 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/active state for the freshly registered neuron.

Same class of stale-inheritance bug PR opentensor#755 was introduced to fix;
these three fields were missed there.

- clear_neuron now also zeroes ValidatorTrust[uid] and resets
  ValidatorPermit[uid] = false and Active[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 and
  test_replace_neuron_clears_active mirroring the existing
  test_replace_neuron_resets_last_update style.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request no-spec-version-bump PR does not contain changes that requires bumping the spec version skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants