Skip to content

Commit b710d30

Browse files
authored
Merge pull request #2153 from opentensor/set-root-owner-fast-runtime
set root owner for fast time
2 parents 5025669 + 8fb0324 commit b710d30

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pallets/subtensor/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ approx.workspace = true
4242
subtensor-swap-interface.workspace = true
4343
runtime-common.workspace = true
4444
subtensor-runtime-common = { workspace = true, features = ["approx"] }
45+
sp-keyring.workspace = true
4546

4647
pallet-drand.workspace = true
4748
pallet-commitments.workspace = true
@@ -105,6 +106,7 @@ std = [
105106
"sp-std/std",
106107
"sp-tracing/std",
107108
"sp-version/std",
109+
"sp-keyring/std",
108110
"subtensor-runtime-common/std",
109111
"pallet-commitments/std",
110112
"pallet-crowdloan/std",

pallets/subtensor/src/macros/genesis.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,29 @@ use frame_support::pallet_macros::pallet_section;
44
/// This can later be imported into the pallet using [`import_section`].
55
#[pallet_section]
66
mod genesis {
7+
use sp_core::crypto::Pair;
8+
use sp_core::sr25519::Pair as Sr25519Pair;
79

810
#[pallet::genesis_build]
911
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
1012
fn build(&self) {
13+
// Alice's public key
14+
let alice_bytes = sp_keyring::Sr25519Keyring::Alice.public();
15+
16+
// Create Alice's hotkey from seed string
17+
let pair = Sr25519Pair::from_string("//Alice_hk", None)
18+
.expect("Alice hotkey pair should be valid");
19+
let alice_hk_bytes = pair.public().0;
20+
21+
let alice_account =
22+
T::AccountId::decode(&mut &alice_bytes[..]).expect("Alice account should decode");
23+
let alice_hk_account = T::AccountId::decode(&mut &alice_hk_bytes[..])
24+
.expect("Alice hotkey account should decode");
25+
26+
let subnet_root_owner = prod_or_fast!(DefaultSubnetOwner::<T>::get(), alice_account);
27+
let subnet_root_owner_hotkey =
28+
prod_or_fast!(DefaultSubnetOwner::<T>::get(), alice_hk_account);
29+
1130
// Set initial total issuance from balances
1231
TotalIssuance::<T>::put(self.balances_issuance);
1332

@@ -17,6 +36,12 @@ mod genesis {
1736
// Increment the number of total networks.
1837
TotalNetworks::<T>::mutate(|n| *n = n.saturating_add(1));
1938

39+
// Set the root network owner.
40+
SubnetOwner::<T>::insert(NetUid::ROOT, subnet_root_owner);
41+
42+
// Set the root network owner hotkey.
43+
SubnetOwnerHotkey::<T>::insert(NetUid::ROOT, subnet_root_owner_hotkey);
44+
2045
// Set the number of validators to 1.
2146
SubnetworkN::<T>::insert(NetUid::ROOT, 0);
2247

0 commit comments

Comments
 (0)