Handle AllowancesStorage when subnet deregistration
Is your feature request related to a problem? Please describe.
AllowancesStorage is introduced in #2478, but not handled during subnet deregistration.
Describe the solution you'd like
It is a double map, the netuid is part of second key. need to consider how to clean up efficiently.
Describe alternatives you've considered
No response
Additional context
No response
@open-junius thanks for opening the issue. can I work on the issue?
@open-junius I found RootAlphaDividendsPerSubnet is not cleared too
Instead of cleaning up allowances on deregistration, we can lazily invalidate them using a generation counter:
Add SubnetGeneration: Map<netuid, u64>, incremented each time a netuid is registered Include the generation in the allowance key: (approver, (spender, netuid, generation)) → amount On transferStakeFrom, check that the stored generation matches the current one — if not, treat as zero Zero writes on deregistration, one extra read on consumption. Stale entries become inert automatically.
Or how about Bounded cleanup(clean a limited number of entries per block across multiple blocks)?