Skip to content

Commit 1ab5d4d

Browse files
committed
set root owner for fast time
1 parent 1426ed1 commit 1ab5d4d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
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: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ 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-
7+
use sp_keyring::Sr25519Keyring;
88
#[pallet::genesis_build]
99
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
1010
fn build(&self) {
11+
// Alice's public key
12+
let alice_bytes = Sr25519Keyring::Alice.public();
13+
let alice_key =
14+
T::AccountId::decode(&mut &alice_bytes[..]).expect("Alice account should decode");
15+
let subnet_root_owner = prod_or_fast!(DefaultSubnetOwner::<T>::get(), alice_key);
1116
// Set initial total issuance from balances
1217
TotalIssuance::<T>::put(self.balances_issuance);
1318

@@ -17,6 +22,9 @@ mod genesis {
1722
// Increment the number of total networks.
1823
TotalNetworks::<T>::mutate(|n| *n = n.saturating_add(1));
1924

25+
// Set the root network owner.
26+
SubnetOwner::<T>::insert(NetUid::ROOT, subnet_root_owner);
27+
2028
// Set the number of validators to 1.
2129
SubnetworkN::<T>::insert(NetUid::ROOT, 0);
2230

0 commit comments

Comments
 (0)