Skip to content

fix: remove unused storage maps NextStakeJobId, UsedWork, LargestLocked#2464

Open
Nicknamess96 wants to merge 1 commit intoopentensor:mainfrom
Nicknamess96:fix/remove-unused-storage-maps
Open

fix: remove unused storage maps NextStakeJobId, UsedWork, LargestLocked#2464
Nicknamess96 wants to merge 1 commit intoopentensor:mainfrom
Nicknamess96:fix/remove-unused-storage-maps

Conversation

@Nicknamess96
Copy link

@Nicknamess96 Nicknamess96 commented Feb 26, 2026

Summary

Removes three storage maps that are either completely unused or write-only, reducing chain state bloat:

  • NextStakeJobId — declared but never read or written anywhere; its companion StakeJobs map does not exist
  • UsedWork — written during PoW registration (do_burned_registration, do_registration) but never read, so the intended work-replay protection was never enforced
  • LargestLocked — written during genesis and removed during network dissolution, but never read in production code

Audit methodology

Full ripgrep search across the repository for each identifier (type name, snake_case variants) confirmed:

  • No reads (.get(), .try_get(), .contains_key(), ::iter()) in production code
  • No references in runtime APIs, RPC implementations, or metadata
  • LargestLocked has test-only reads in tests/networks.rs (removed alongside the map)

Files changed

File Change
pallets/subtensor/src/lib.rs Remove 3 storage declarations
pallets/subtensor/src/subnets/registration.rs Remove 2 dead UsedWork::insert calls
pallets/subtensor/src/macros/genesis.rs Remove LargestLocked::insert in genesis
pallets/subtensor/src/coinbase/root.rs Remove LargestLocked::remove in dissolution
pallets/subtensor/src/tests/networks.rs Remove test setup/assertion for LargestLocked

Closes #2397

Test plan

  • Existing tests pass (no production code reads these maps)
  • cargo clippy clean
  • Verify no downstream RPC consumers depend on these storage keys

…Locked

These three storage maps are either completely unused or write-only,
contributing to silent chain state bloat with no functional benefit:

- NextStakeJobId: declared but never read or written; its companion
  StakeJobs map does not exist.
- UsedWork: written to during PoW registration but never read, so the
  intended work-replay protection was never enforced.
- LargestLocked: written during genesis and removed during network
  dissolution, but never read in production code.

Closes opentensor#2397
@Nicknamess96 Nicknamess96 force-pushed the fix/remove-unused-storage-maps branch from cda8dac to 0375938 Compare February 26, 2026 18:08
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.

Audit and remove unused or write-only storage maps

1 participant