refactor: remove unnecessary clone and fix collect element type in do_reset_bonds#2605
Open
greatjourney589 wants to merge 11 commits intoopentensor:devnet-readyfrom
Open
Conversation
Author
|
@open-junius Would appreciate your review on this PR. Fixed 2 minor but real issues. |
Contributor
|
need to run cargo fmt. |
Author
Am I supposed to run it locally and push again? |
Author
|
@open-junius Ran cargo fmt and push again. Request your review. Thanks. |
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.
Description
Remove an unnecessary
.clone()and fix the collected element type indo_reset_bonds.When filtering bond entries for a deregistered hotkey, the original code cloned
bonds_vecbefore iterating (wasteful —.iter()borrows in place) and collected intoVec<&(u16, u16)>instead ofVec<(u16, u16)>. The reference type happened to compile via SCALE'sEncodeLikeblanket impl but does not match theBondsstorage type. Adding.copied()between.filter()and.collect()fixes the element type and makes the clone unnecessary.Related Issue(s)
Type of Change
Breaking Change
N/A
Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyScreenshots (if applicable)
N/A
Additional Notes
The two unit tests added in
tests/epoch.rscover:test_do_reset_bonds_removes_target_uid_from_all_bond_vecs- verifies the deregistered uid is removed from every other neuron's bond vec while unrelated entries are preserved.test_do_reset_bonds_noop_when_disabled- verifies the early-return path whenbonds_resetis disabled leaves storage unchanged.