Skip to content

Commit

Permalink
remove some configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
open-junius committed Sep 27, 2024
1 parent f2e7b02 commit 96a09ae
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 121 deletions.
55 changes: 0 additions & 55 deletions node/src/chain_spec/localnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,50 +76,6 @@ fn localnet_genesis(
),
];

let root_validator = (
get_account_id_from_seed::<sr25519::Public>("RootValidator"),
// 10000 TAO
10_000_000_000_000_u128,
);

let subnet_validator = (
get_account_id_from_seed::<sr25519::Public>("SubnetValidator"),
// 2000 TAO
2_000_000_000_000_u128,
);

let miners = [
(
get_account_id_from_seed::<sr25519::Public>("Miner1"),
// 10 TAO
10_000_000_000_u128,
),
(
get_account_id_from_seed::<sr25519::Public>("Miner2"),
// 10 TAO
10_000_000_000_u128,
),
(
get_account_id_from_seed::<sr25519::Public>("Miner3"),
// 10 TAO
10_000_000_000_u128,
),
(
get_account_id_from_seed::<sr25519::Public>("Miner4"),
// 10 TAO
10_000_000_000_u128,
),
(
get_account_id_from_seed::<sr25519::Public>("Miner5"),
// 10 TAO
10_000_000_000_u128,
),
];

balances.push(root_validator.clone());
balances.push(subnet_validator.clone());
balances.append(&mut miners.to_vec());

// Check if the environment variable is set
if let Ok(bt_wallet) = env::var("BT_DEFAULT_TOKEN_WALLET") {
if let Ok(decoded_wallet) = Ss58Codec::from_ss58check(&bt_wallet) {
Expand All @@ -141,7 +97,6 @@ fn localnet_genesis(
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
];

let alice_account = get_account_id_from_seed::<sr25519::Public>("Alice");
serde_json::json!({
"balances": { "balances": balances },
"aura": {
Expand All @@ -163,17 +118,7 @@ fn localnet_genesis(
"members": senate_members,
},
"subtensorModule": {
"initializeNetwork1": true,
"initializeNetwork3": false,
"rootColdkeyValidator": Some(vec![alice_account.clone(), root_validator.0]),
"subnetColdkeyValidator": Some(vec![alice_account.clone(), subnet_validator.0]),
"miners": Some(vec![
(alice_account.clone(), miners[0].0.clone()),
(alice_account.clone(), miners[1].0.clone()),
(alice_account.clone(), miners[2].0.clone()),
(alice_account.clone(), miners[3].0.clone()),
(alice_account.clone(), miners[4].0.clone()),
]),
},
})
}
12 changes: 0 additions & 12 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,28 +1234,16 @@ pub mod pallet {
pub stakes: Vec<(T::AccountId, Vec<(T::AccountId, (u64, u16))>)>,
/// The total issued balance in genesis
pub balances_issuance: u64,
/// Flag to initialize network 1.
pub initialize_network_1: bool,
/// Flag to initialize network 3.
pub initialize_network_3: bool,
/// The root validator account ID.
pub root_coldkey_validator: Option<Vec<T::AccountId>>,
/// The subnet validator account ID.
pub subnet_coldkey_validator: Option<Vec<T::AccountId>>,
/// The miner account IDs.
pub miners: Option<Vec<(T::AccountId, T::AccountId)>>,
}

impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self {
stakes: Default::default(),
balances_issuance: 0,
initialize_network_1: false,
initialize_network_3: true,
root_coldkey_validator: None,
subnet_coldkey_validator: None,
miners: None,
}
}
}
Expand Down
54 changes: 0 additions & 54 deletions pallets/subtensor/src/macros/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,39 +72,6 @@ mod genesis {

let tempo = 99;

// Should be only for localnet
if self.initialize_network_1 {
init_network::<T>(1, tempo);
// Stake 1000 TAO, each validator has 2000 TAO according to localnet configure
let stake_amount = 1_000_000_000_000;
// Add validator for network 1
if let Some(coldkey_validator) = &self.subnet_coldkey_validator {
let coldkey = coldkey_validator
.get(0)
.expect("should config in genesis")
.clone();
let hotkey = coldkey_validator
.get(1)
.expect("should config in genesis")
.clone();
Pallet::<T>::create_account_if_non_existent(&coldkey, &hotkey);
Pallet::<T>::append_neuron(1, &hotkey, 0);
Pallet::<T>::increase_stake_on_coldkey_hotkey_account(
&coldkey,
&hotkey,
stake_amount,
);
}

// Register all miners account, no any stake for miners
if let Some(miners) = &self.miners {
for miner in miners.iter() {
Pallet::<T>::create_account_if_non_existent(&miner.0, &miner.1);
Pallet::<T>::append_neuron(1, &miner.1, 0);
}
}
}

if self.initialize_network_3 {
init_network::<T>(3, tempo);
}
Expand Down Expand Up @@ -166,8 +133,6 @@ mod genesis {

// Get the root network uid.
let root_netuid: u16 = 0;
// Root validator with balance 10_000_000_000_000_u128, half of stake
let stake_amount = 5_000_000_000_000_u64;

// Set the root network as added.
NetworksAdded::<T>::insert(root_netuid, true);
Expand Down Expand Up @@ -198,25 +163,6 @@ mod genesis {

// Set target registrations for validators as 1 per block.
TargetRegistrationsPerInterval::<T>::insert(root_netuid, 1);

// Config the validator for root network
if let Some(coldkey_validator) = &self.root_coldkey_validator {
let coldkey = coldkey_validator
.get(0)
.expect("should config in genesis")
.clone();
let hotkey = coldkey_validator
.get(1)
.expect("should config in genesis")
.clone();
Pallet::<T>::create_account_if_non_existent(&coldkey, &hotkey);
Pallet::<T>::append_neuron(root_netuid, &hotkey, 0);
Pallet::<T>::increase_stake_on_coldkey_hotkey_account(
&coldkey,
&hotkey,
stake_amount,
);
}
}
}
}

0 comments on commit 96a09ae

Please sign in to comment.