fix(validator): realign persisted scores to metagraph size on load_state#1607
Open
RealDiligent wants to merge 4 commits into
Open
fix(validator): realign persisted scores to metagraph size on load_state#1607RealDiligent wants to merge 4 commits into
RealDiligent wants to merge 4 commits into
Conversation
load_state() restored scores/hotkeys from state.npz without resizing to the current metagraph.n, causing IndexError or misaligned on-chain weights after subnet growth or shrink. Realign persisted scores on load and consolidate metagraph resize handling in resync_metagraph(). Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Author
|
CI validated on fork (964 tests passed, lint/pyright clean): https://github.com/RealDiligent/gittensor/actions/runs/28982027511 https://github.com/RealDiligent/gittensor/actions/runs/28982026612 |
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Fixes #1606
Summary
Fixes validator crashes and misaligned weight emission after a subnet resize followed by validator restart.
Root cause
load_state()restoredscores/hotkeysfromstate.npzwithout validating length against the currentmetagraph.n.resync_metagraph()only handled growth at runtime and could index past the live metagraph on shrink.Fix approach
_align_scores_to_metagraph()to resize persisted scores, zero replaced hotkeys, and matchmetagraph.n.load_state()andresync_metagraph().Impact
Validators survive routine subnet resizes across restarts instead of crashing or emitting wrong weights.
Risk / tradeoffs
Test plan
test_align_scores_grows_with_metagraphtest_align_scores_shrinks_with_metagraphtest_align_scores_zeros_replaced_hotkeytest_load_state_realigns_persisted_scores_to_current_metagraphTests+Lintworkflows