Skip to content

Add new subnet identity version with agent_docs_url#2501

Open
bdmason wants to merge 4 commits intoopentensor:devnet-readyfrom
bdmason:feat/subnet-identity-v4-agent-docs-url
Open

Add new subnet identity version with agent_docs_url#2501
bdmason wants to merge 4 commits intoopentensor:devnet-readyfrom
bdmason:feat/subnet-identity-v4-agent-docs-url

Conversation

@bdmason
Copy link
Contributor

@bdmason bdmason commented Mar 16, 2026

Description

Adds a new field agent_docs_url to subnet identities.

Related Issue(s)

NA

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Breaking Change

Any applications reading the old storage item would need to use the new one.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run ./scripts/fix_rust.sh to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Screenshots (if applicable)

Please include any relevant screenshots or GIFs that demonstrate the changes made.

Additional Notes

Please provide any additional information or context that may be helpful for reviewers.

Comment on lines +6 to +56
pub fn migrate_subnet_identity_v3_to_v4<T: Config>() -> Weight {
let migration_name = b"migrate_subnet_identity_v3_to_v4".to_vec();
let mut weight = T::DbWeight::get().reads(1);

if HasMigrationRun::<T>::get(&migration_name) {
log::info!(
"Migration '{:?}' has already run. Skipping.",
String::from_utf8_lossy(&migration_name)
);
return weight;
}

log::info!(
"Running migration '{}'",
String::from_utf8_lossy(&migration_name),
);

let mut migrated_count: u64 = 0;

for (netuid, v3_identity) in SubnetIdentitiesV3::<T>::iter() {
let v4_identity = SubnetIdentityOfV4 {
subnet_name: v3_identity.subnet_name,
github_repo: v3_identity.github_repo,
subnet_contact: v3_identity.subnet_contact,
subnet_url: v3_identity.subnet_url,
discord: v3_identity.discord,
description: v3_identity.description,
logo_url: v3_identity.logo_url,
additional: v3_identity.additional,
agent_docs_url: vec![],
};
SubnetIdentitiesV4::<T>::insert(netuid, v4_identity);
migrated_count += 1;
}

weight = weight.saturating_add(T::DbWeight::get().reads(migrated_count));
weight = weight.saturating_add(T::DbWeight::get().writes(migrated_count));

// Remove old V3 entries
remove_prefix::<T>("SubtensorModule", "SubnetIdentitiesV3", &mut weight);

HasMigrationRun::<T>::insert(&migration_name, true);
weight = weight.saturating_add(T::DbWeight::get().writes(1));

log::info!(
"Migration '{:?}' completed successfully. Migrated {migrated_count:?} subnet identities.",
String::from_utf8_lossy(&migration_name)
);

weight
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done in place for V3.

}

/// Struct for SubnetIdentitiesV4.
pub type SubnetIdentityOfV4 = SubnetIdentityV4;
Copy link
Collaborator

@l0r1s l0r1s Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is useless. What should be defined is SubnetIdentityOf<T> and it should be used across the codebase to avoid having to rename everytime there is a change.

You can get an example here

Comment on lines +2158 to +2161
/// --- MAP ( netuid ) --> SubnetIdentityOfV4
#[pallet::storage]
pub type SubnetIdentitiesV4<T: Config> =
StorageMap<_, Blake2_128Concat, NetUid, SubnetIdentityOfV4, OptionQuery>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed. We shouldn't be adding a new storage map for each version.

@bdmason
Copy link
Contributor Author

bdmason commented Mar 25, 2026

@l0r1s I've made the changes requested. I think this makes the storage item look more consistent, but it does not eliminate the downstream breaking change. It just makes it more subtle.

SubnetIdentitiesV3 keeps the same storage name/key, but its value type changes from SubnetIdentityV3 to SubnetIdentityV4. For typed consumers like Rust indexers using subxt, that is still a breaking
runtime metadata change. Clients generated against the old metadata will continue to look up SubnetIdentitiesV3, but will attempt to decode the value as SubnetIdentityV3; after the upgrade/migration, those
values are V4-encoded and decode will fail at runtime.

We still need to document this as a breaking change for anyone using subxt.

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.

2 participants