Skip to content

Fix #2411: finalize_all_subnet_root_dividends has unbounded iteration over all hotkeys#2425

Open
0xRozier wants to merge 1 commit intoopentensor:mainfrom
0xRozier:fix/issue-2411-unbounded-root-claimable-iteration
Open

Fix #2411: finalize_all_subnet_root_dividends has unbounded iteration over all hotkeys#2425
0xRozier wants to merge 1 commit intoopentensor:mainfrom
0xRozier:fix/issue-2411-unbounded-root-claimable-iteration

Conversation

@0xRozier
Copy link

@0xRozier 0xRozier commented Feb 13, 2026

Description

Replace unbounded iter_keys().collect::<Vec<_>>() in
finalize_all_subnet_root_dividends with StorageMap::translate(),
which iterates entries one at a time without allocating all keys in
memory. Empty RootClaimable entries are also cleaned up.

Related Issue(s)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Breaking Change

N/A

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run ./scripts/fix_rust.sh to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Screenshots (if applicable)

N/A

Additional Notes

N/A

…ividends

Replace `iter_keys().collect::<Vec<_>>()` + mutate loop with
`StorageMap::translate()` which processes entries one at a time without
collecting all hotkey keys into memory.

This also removes empty RootClaimable entries (returning None from
translate) instead of leaving behind empty BTreeMaps.

Closes opentensor#2411

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@0xRozier
Copy link
Author

0xRozier commented Feb 18, 2026

Hi, @l0r1s , @sam0x17 , @shamil-gadelshin , @JohnReedV , sorry to ping you all but can someone check this ?

@0xRozier
Copy link
Author

0xRozier commented Mar 10, 2026

@l0r1s Friendly bump — this PR fixes the unbounded memory allocation reported in #2411 by replacing collect::<Vec<_>>() with translate(). The change is small (~20 lines + tests), all checks pass, and the PR body now follows the repo template. Would appreciate a review when you get a chance. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

finalize_all_subnet_root_dividends has unbounded iteration over all hotkeys

1 participant