subtensor icon indicating copy to clipboard operation
subtensor copied to clipboard

Handle AllowancesStorage when subnet deregistration

Open open-junius opened this issue 7 months ago • 4 comments

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 avatar Apr 08 '26 03:04 open-junius

@open-junius thanks for opening the issue. can I work on the issue?

mkdev5 avatar Apr 08 '26 14:04 mkdev5

@open-junius I found RootAlphaDividendsPerSubnet is not cleared too

plind-junior avatar Apr 08 '26 14:04 plind-junior

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.

plind-junior avatar Apr 08 '26 15:04 plind-junior

Or how about Bounded cleanup(clean a limited number of entries per block across multiple blocks)?

plind-junior avatar Apr 08 '26 15:04 plind-junior