-
Notifications
You must be signed in to change notification settings - Fork 302
Add new subnet identity version with agent_docs_url #2501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bdmason
wants to merge
4
commits into
opentensor:devnet-ready
Choose a base branch
from
bdmason:feat/subnet-identity-v4-agent-docs-url
base: devnet-ready
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+273
−36
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fbacde3
Add new subnet identity version with agent_docs_url
bdmason a1bd2db
Keep old `SubnetIdentitiesV3` storage key (with internal breaking cha…
bdmason a3ed636
Apply the generic alias
bdmason 81366b7
Merge branch 'devnet-ready' into feat/subnet-identity-v4-agent-docs-url
bdmason File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -289,9 +289,9 @@ pub mod pallet { | |
| pub additional: Vec<u8>, | ||
| } | ||
|
|
||
| /// Struct for SubnetIdentitiesV3. | ||
| /// Struct for SubnetIdentitiesV3. (DEPRECATED for V4) | ||
| pub type SubnetIdentityOfV3 = SubnetIdentityV3; | ||
| /// Data structure for Subnet Identities | ||
| /// Data structure for Subnet Identities (DEPRECATED for V4) | ||
| #[crate::freeze_struct("6a441335f985a0b")] | ||
| #[derive( | ||
| Encode, Decode, DecodeWithMemTracking, Default, TypeInfo, Clone, PartialEq, Eq, Debug, | ||
|
|
@@ -315,6 +315,34 @@ pub mod pallet { | |
| pub additional: Vec<u8>, | ||
| } | ||
|
|
||
| /// Struct for SubnetIdentitiesV4. | ||
| pub type SubnetIdentityOfV4 = SubnetIdentityV4; | ||
| /// Data structure for Subnet Identities | ||
| #[crate::freeze_struct("4b9718ba1a9cb75f")] | ||
| #[derive( | ||
| Encode, Decode, DecodeWithMemTracking, Default, TypeInfo, Clone, PartialEq, Eq, Debug, | ||
| )] | ||
| pub struct SubnetIdentityV4 { | ||
| /// The name of the subnet | ||
| pub subnet_name: Vec<u8>, | ||
| /// The github repository associated with the subnet | ||
| pub github_repo: Vec<u8>, | ||
| /// The subnet's contact | ||
| pub subnet_contact: Vec<u8>, | ||
| /// The subnet's website | ||
| pub subnet_url: Vec<u8>, | ||
| /// The subnet's discord | ||
| pub discord: Vec<u8>, | ||
| /// The subnet's description | ||
| pub description: Vec<u8>, | ||
| /// The subnet's logo | ||
| pub logo_url: Vec<u8>, | ||
| /// Additional information about the subnet | ||
| pub additional: Vec<u8>, | ||
| /// The subnet's agent documentation URL | ||
| pub agent_docs_url: Vec<u8>, | ||
| } | ||
|
|
||
| /// Enum for recycle or burn for the owner_uid(s) | ||
| #[derive(TypeInfo, Encode, Decode, DecodeWithMemTracking, Clone, PartialEq, Eq, Debug)] | ||
| pub enum RecycleOrBurnEnum { | ||
|
|
@@ -2122,11 +2150,16 @@ pub mod pallet { | |
| pub type IdentitiesV2<T: Config> = | ||
| StorageMap<_, Blake2_128Concat, T::AccountId, ChainIdentityOfV2, OptionQuery>; | ||
|
|
||
| /// --- MAP ( netuid ) --> SubnetIdentityOfV3 | ||
| /// --- MAP ( netuid ) --> SubnetIdentityOfV3 (DEPRECATED for V4) | ||
| #[pallet::storage] | ||
| pub type SubnetIdentitiesV3<T: Config> = | ||
| StorageMap<_, Blake2_128Concat, NetUid, SubnetIdentityOfV3, OptionQuery>; | ||
|
|
||
| /// --- MAP ( netuid ) --> SubnetIdentityOfV4 | ||
| #[pallet::storage] | ||
| pub type SubnetIdentitiesV4<T: Config> = | ||
| StorageMap<_, Blake2_128Concat, NetUid, SubnetIdentityOfV4, OptionQuery>; | ||
|
||
|
|
||
| /// ================================= | ||
| /// ==== Axon / Promo Endpoints ===== | ||
| /// ================================= | ||
|
|
||
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
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
56 changes: 56 additions & 0 deletions
56
pallets/subtensor/src/migrations/migrate_subnet_identity_v3_to_v4.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| use super::*; | ||
| use crate::HasMigrationRun; | ||
| use frame_support::{traits::Get, weights::Weight}; | ||
| use scale_info::prelude::string::String; | ||
|
|
||
| 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 | ||
| } | ||
|
Comment on lines
+6
to
+52
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be done in place for V3. |
||
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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