Commit 4130b14
Add storage leak detection test for subnet dissolution
Introduces test_dissolve_network_no_storage_leak which automatically
detects per-subnet storage that is not cleaned up when a subnet is
dissolved. The test:
1. Snapshots ALL raw storage keys before subnet creation
2. Creates a subnet, registers neurons, stakes, serves axon/prometheus,
sets childkeys, sets weights, and runs 2 epochs
3. Dissolves the subnet via root
4. Snapshots ALL storage keys after dissolution
5. Diffs the snapshots, filtering to SubtensorModule and Swap pallets,
excluding known global storage items
This is future-proof: when a developer adds a new per-netuid StorageMap
but forgets cleanup in remove_network, this test fails automatically
with a clear error message naming the leaked storage item.
Also fixes Swap::ScrapReservoirTao and Swap::ScrapReservoirAlpha not
being cleaned up in do_clear_protocol_liquidity.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 77b60d4 commit 4130b14
3 files changed
Lines changed: 430 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
366 | 370 | | |
367 | 371 | | |
368 | 372 | | |
369 | 373 | | |
370 | 374 | | |
371 | 375 | | |
| 376 | + | |
372 | 377 | | |
373 | 378 | | |
374 | 379 | | |
| |||
0 commit comments