From 1ab5d4df7245d38da0ec8ef3fd84be51b027971f Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 24 Oct 2025 09:38:58 +0800 Subject: [PATCH 1/3] set root owner for fast time --- Cargo.lock | 1 + pallets/subtensor/Cargo.toml | 2 ++ pallets/subtensor/src/macros/genesis.rs | 10 +++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 78c1f9d102..296ae30919 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10677,6 +10677,7 @@ dependencies = [ "share-pool", "sp-core", "sp-io", + "sp-keyring", "sp-runtime", "sp-std", "sp-tracing", diff --git a/pallets/subtensor/Cargo.toml b/pallets/subtensor/Cargo.toml index 281f226683..fdd5e5f9ab 100644 --- a/pallets/subtensor/Cargo.toml +++ b/pallets/subtensor/Cargo.toml @@ -42,6 +42,7 @@ approx.workspace = true subtensor-swap-interface.workspace = true runtime-common.workspace = true subtensor-runtime-common = { workspace = true, features = ["approx"] } +sp-keyring.workspace = true pallet-drand.workspace = true pallet-commitments.workspace = true @@ -105,6 +106,7 @@ std = [ "sp-std/std", "sp-tracing/std", "sp-version/std", + "sp-keyring/std", "subtensor-runtime-common/std", "pallet-commitments/std", "pallet-crowdloan/std", diff --git a/pallets/subtensor/src/macros/genesis.rs b/pallets/subtensor/src/macros/genesis.rs index 9d830e36ad..746acea936 100644 --- a/pallets/subtensor/src/macros/genesis.rs +++ b/pallets/subtensor/src/macros/genesis.rs @@ -4,10 +4,15 @@ use frame_support::pallet_macros::pallet_section; /// This can later be imported into the pallet using [`import_section`]. #[pallet_section] mod genesis { - + use sp_keyring::Sr25519Keyring; #[pallet::genesis_build] impl BuildGenesisConfig for GenesisConfig { fn build(&self) { + // Alice's public key + let alice_bytes = Sr25519Keyring::Alice.public(); + let alice_key = + T::AccountId::decode(&mut &alice_bytes[..]).expect("Alice account should decode"); + let subnet_root_owner = prod_or_fast!(DefaultSubnetOwner::::get(), alice_key); // Set initial total issuance from balances TotalIssuance::::put(self.balances_issuance); @@ -17,6 +22,9 @@ mod genesis { // Increment the number of total networks. TotalNetworks::::mutate(|n| *n = n.saturating_add(1)); + // Set the root network owner. + SubnetOwner::::insert(NetUid::ROOT, subnet_root_owner); + // Set the number of validators to 1. SubnetworkN::::insert(NetUid::ROOT, 0); From 649a6d7207247aad73569f78c96e68558eb5a7eb Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 24 Oct 2025 09:50:14 +0800 Subject: [PATCH 2/3] bump version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index b19b7ddf6f..286c3312b6 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -220,7 +220,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 330, + spec_version: 331, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 8fb03246949a5177370ddde089fb10aa4db04536 Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 28 Oct 2025 23:10:39 +0800 Subject: [PATCH 3/3] add root owner hotkey --- pallets/subtensor/src/macros/genesis.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/pallets/subtensor/src/macros/genesis.rs b/pallets/subtensor/src/macros/genesis.rs index 746acea936..7bf8ba2a53 100644 --- a/pallets/subtensor/src/macros/genesis.rs +++ b/pallets/subtensor/src/macros/genesis.rs @@ -4,15 +4,29 @@ use frame_support::pallet_macros::pallet_section; /// This can later be imported into the pallet using [`import_section`]. #[pallet_section] mod genesis { - use sp_keyring::Sr25519Keyring; + use sp_core::crypto::Pair; + use sp_core::sr25519::Pair as Sr25519Pair; + #[pallet::genesis_build] impl BuildGenesisConfig for GenesisConfig { fn build(&self) { // Alice's public key - let alice_bytes = Sr25519Keyring::Alice.public(); - let alice_key = + let alice_bytes = sp_keyring::Sr25519Keyring::Alice.public(); + + // Create Alice's hotkey from seed string + let pair = Sr25519Pair::from_string("//Alice_hk", None) + .expect("Alice hotkey pair should be valid"); + let alice_hk_bytes = pair.public().0; + + let alice_account = T::AccountId::decode(&mut &alice_bytes[..]).expect("Alice account should decode"); - let subnet_root_owner = prod_or_fast!(DefaultSubnetOwner::::get(), alice_key); + let alice_hk_account = T::AccountId::decode(&mut &alice_hk_bytes[..]) + .expect("Alice hotkey account should decode"); + + let subnet_root_owner = prod_or_fast!(DefaultSubnetOwner::::get(), alice_account); + let subnet_root_owner_hotkey = + prod_or_fast!(DefaultSubnetOwner::::get(), alice_hk_account); + // Set initial total issuance from balances TotalIssuance::::put(self.balances_issuance); @@ -25,6 +39,9 @@ mod genesis { // Set the root network owner. SubnetOwner::::insert(NetUid::ROOT, subnet_root_owner); + // Set the root network owner hotkey. + SubnetOwnerHotkey::::insert(NetUid::ROOT, subnet_root_owner_hotkey); + // Set the number of validators to 1. SubnetworkN::::insert(NetUid::ROOT, 0);