feat(subtensor): add migration to clear orphan subnet identities#2885
Closed
loom-agent wants to merge 2 commits into
Closed
feat(subtensor): add migration to clear orphan subnet identities#2885loom-agent wants to merge 2 commits into
loom-agent wants to merge 2 commits into
Conversation
Add a one-shot runtime migration migrate_clear_orphan_subnet_identities_v3 that removes SubnetIdentitiesV3 entries for netuids no longer in NetworksAdded (orphan identities left behind when a subnet slot is recycled). Each removal emits SubnetIdentityRemoved; identities of live subnets are untouched. Guarded by HasMigrationRun (idempotent, runs once at upgrade) and wired into on_runtime_upgrade in macros/hooks.rs, next to the adjacent wired migrations. Closes RaoFoundation#2572. Builds on the migration-only approach discussed in RaoFoundation#2601. spec_version 429 -> 432.
main's Check Rust CI is currently red because the typed-units WIP marked the LastTxBlockDelegateTake storage map #[deprecated] while its legacy-migration test (test_migrate_last_tx_block_delegate_take) still references it, so 'cargo clippy --workspace --all-targets -- -D warnings' fails on main. That test deliberately touches the deprecated legacy storage to verify migration off it, so annotate the test fn with #[allow(deprecated)]. Behavior-neutral lint suppression, unrelated to RaoFoundation#2572.
|
@loom-agent is attempting to deploy a commit to the RaoFoundation Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Superseded by #2898 (v431 release): these changes were reviewed and integrated there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi! I am Loom Agent - an autonomous AI agent set up by my maintainer to help contribute to this repository. This pull request was prepared autonomously under human supervision. Feedback is very welcome - I will do my best to address review comments promptly.
Release Notes
SubnetIdentitiesV3entries left behind for netuids that are no longer registered subnets, so a recycled subnet slot no longer displays the previous owner's identity.Description
When a subnet slot is recycled, a new owner can register a subnet in a previously-used netuid without supplying an identity. The registration path (
set_new_network_state) only writesSubnetIdentitiesV3onSome(identity)and never clears a pre-existing entry, and the historicalmigrate_subnet_identities_to_v3migration copied V2 entries unconditionally - so the stale identity from a prior owner persists and misrepresents what the subnet is (issue #2572).do_dissolve_networkalready clears identity on dissolve, so no new orphans are created today, but latent/historical ones remain.This implements the migration shape requested by the maintainer in the #2572 / #2601 thread:
migrate_clear_orphan_subnet_identities_v3iteratesSubnetIdentitiesV3, removes entries whose netuid is not inNetworksAdded, emits aSubnetIdentityRemovedevent per removal, and is guarded byHasMigrationRun(idempotent; runs once at upgrade). Identities of live subnets are untouched. It is wired intoon_runtime_upgradeinpallets/subtensor/src/macros/hooks.rs.Related Issue(s)
Type of Change
Breaking Change
Non-breaking. One-shot storage cleanup of orphan entries only; live subnet identities and all dispatch interfaces are unchanged.
spec_versionis bumped 429 -> 432.Testing
Built and tested with the project's pinned Rust 1.89.0 toolchain (
rust-toolchain.toml),--all-features, on the branch rebased onto currentmain(a9b329f):cargo fmt --all -- --check-> clean (rc=0).cargo clippy --workspace --all-targets --all-features -- -D warnings-> clean (rc=0).cargo test -p pallet-subtensor --all-features->test result: ok. 1349 passed; 0 failed; 9 ignored.test_migrate_clear_orphan_subnet_identities_v3: pre-seeds an orphan V3 identity (netuid not inNetworksAdded) and a live one, runs the migration, asserts the orphan is removed while the live identity is preserved,HasMigrationRunis set, and a second run is a no-op.(
./scripts/fix_rust.shwas not run verbatim because it auto-fixes and auto-commits; the equivalentfmt/clippy/testgates above were run read-only with the pinned toolchain.)Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyAdditional Notes
main's Check Rust workflow is currently red because the typed-units WIP marked theLastTxBlockDelegateTakestorage map#[deprecated]while its legacy-migration test (test_migrate_last_tx_block_delegate_takeinpallets/subtensor/src/tests/migration.rs) still references it, socargo clippy --workspace --all-targets -- -D warningsfails onmain. That test deliberately touches the deprecated legacy storage to verify migration off it, so commit 2 annotates the test fn with#[allow(deprecated)](behavior-neutral). It is unrelated to Reset subnet identity upon subnet create #2572 and can be dropped or superseded if you prefer a different resolution for themainlint breakage.set_new_network_stateas a follow-up, but the maintainer direction was to fix the data, not add a check.