Skip to content

feat: gate vault flows on isSubnetDissolving and drop the storage-query precompile#29

Draft
pawel-gebal-reef wants to merge 2 commits into
mainfrom
pg/subnet_dissolution_precompile
Draft

feat: gate vault flows on isSubnetDissolving and drop the storage-query precompile#29
pawel-gebal-reef wants to merge 2 commits into
mainfrom
pg/subnet_dissolution_precompile

Conversation

@pawel-gebal-reef

Copy link
Copy Markdown
Collaborator

Summary

Subtensor's dissolution flow changed: do_dissolve_network now only queues the netuid in DissolveCleanupQueue and cleanup runs asynchronously via on_idleNetworkRegisteredAt persists until mid-cleanup, and the old DissolvedNetworks storage item no longer exists. The vault's raw-storage blackout check therefore read an empty key and always passed, and during the cleanup window the regBlock-based dispatch saw a live-looking subnet whose alpha was about to be destroyed.

  • Read registration blocks and the dissolve state from the subnet precompile (ISubnet at 0x…0803: getNetworkRegistrationBlock, isSubnetDissolving); delete StorageQueryReader and the 0x0807 dependency entirely
  • New _requireNotDissolving gate freezes wrap, unwrap, unwrapForTao, rebalance, sharePrice, previewWrap, previewUnwrap while the netuid sits in the cleanup queue (blackout check formerly inside _redeemDissolvedPosition now covers both the early window — regBlock unchanged — and the late window — regBlock removed, refunds still landing)
  • currentTokenId, createSubnetProxy and the reclaim*Mailbox recovery rails stay deliberately ungated
  • Tests migrate to a staged MockSubnetPrecompile mirroring the real lifecycle (dissolve keeps regBlock; completion zeroes it); new per-entry-point blackout tests incl. late-blackout pinning
  • Dissolution e2e now polls isSubnetDissolving until cleanup completes before asserting TAO refunds

Verification

  • forge fmt --check clean; forge build zero solc warnings (7 pre-known test-file lint notes, 6 on main already)
  • forge test: 258/258
  • forge coverage: AlphaVault.sol 99.41% lines / 95.77% branches / 100% funcs — every new gate branch exercised both directions
  • Reviewed: per-task + whole-branch review, multi-angle self code-review (findings fixed), security review (no findings)

Outstanding

  • Run e2e/localnet-e2e-subnet-dissolved.sh against a localnet built from the new subtensor
  • Decide handling of the 7 test-file forge lint unsafe-typecast notes (annotate vs lint config vs accept)

🤖 Generated with Claude Code

pawel-gebal-reef and others added 2 commits July 10, 2026 10:08
…ry precompile

Subtensor now dissolves subnets asynchronously: the dissolve extrinsic only
queues the netuid while NetworkRegisteredAt persists until mid-cleanup, and
the old DissolvedNetworks storage item is gone, so the raw-storage blackout
check read an empty key and always passed.

- read registration blocks and the dissolve queue via the subnet precompile
  (ISubnet at 0x803) and delete StorageQueryReader
- freeze wrap, unwrap, unwrapForTao, rebalance, sharePrice, previewWrap and
  previewUnwrap while the netuid sits in the dissolve cleanup queue
- migrate unit tests to a staged MockSubnetPrecompile and cover the early
  and late blackout windows per entry point
- wait for cleanup to finish in the dissolution e2e before asserting refunds

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
forge coverage disables the optimizer and its run of the gas tests
overwrote the snapshot with inflated numbers; the optimized profile
shows every measured op ~1.7k gas cheaper than main.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant