Add storage leak detection test for subnet dissolution #2414
+430
−0
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.
Summary
test_dissolve_network_no_storage_leakwhich automatically detects per-subnet storage that is not cleaned up when a subnet is dissolvedSwap::ScrapReservoirTaoandSwap::ScrapReservoirAlphanot being cleaned up indo_clear_protocol_liquidity(caught by the new test)How the test works
sp_io::storage::next_key) before subnet creationSubtensorModuleorSwappallets (excluding a known global allowlist) is reported as a leakWhy this is useful
This test is future-proof: when a developer adds a new per-netuid
StorageMapbut forgets to clean it up inremove_network, this test fails automatically with a clear error message naming the leaked storage item — no need to update the test itself.Test plan
cargo test -p pallet-subtensor --lib— 998 tests passcargo clippy --workspace --all-features --all-targets— clean🤖 Generated with Claude Code