Skip to content

Commit

Permalink
fix: genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
MohsenNz committed Jan 8, 2025
1 parent 4d08f10 commit 5d77cae
Showing 1 changed file with 0 additions and 115 deletions.
115 changes: 0 additions & 115 deletions pallets/jungochain/src/macros/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,121 +11,6 @@ mod genesis {
// Set initial total issuance from balances
TotalIssuance::<T>::put(self.balances_issuance);

// Subnet config values
let netuid: u16 = 3;
let tempo = 99;
let max_uids = 4096;

// The functions for initializing new networks/setting defaults cannot be run directly from genesis functions like extrinsics would
// --- Set this network uid to alive.
NetworksAdded::<T>::insert(netuid, true);

// --- Fill tempo memory item.
Tempo::<T>::insert(netuid, tempo);

// --- Fill modality item.
// Only modality 0 exists (text)
NetworkModality::<T>::insert(netuid, 0);

// Make network parameters explicit.
if !Tempo::<T>::contains_key(netuid) {
Tempo::<T>::insert(netuid, Tempo::<T>::get(netuid));
}
if !Kappa::<T>::contains_key(netuid) {
Kappa::<T>::insert(netuid, Kappa::<T>::get(netuid));
}
if !Difficulty::<T>::contains_key(netuid) {
Difficulty::<T>::insert(netuid, Difficulty::<T>::get(netuid));
}
if !MaxAllowedUids::<T>::contains_key(netuid) {
MaxAllowedUids::<T>::insert(netuid, MaxAllowedUids::<T>::get(netuid));
}
if !ImmunityPeriod::<T>::contains_key(netuid) {
ImmunityPeriod::<T>::insert(netuid, ImmunityPeriod::<T>::get(netuid));
}
if !ActivityCutoff::<T>::contains_key(netuid) {
ActivityCutoff::<T>::insert(netuid, ActivityCutoff::<T>::get(netuid));
}
if !EmissionValues::<T>::contains_key(netuid) {
EmissionValues::<T>::insert(netuid, EmissionValues::<T>::get(netuid));
}
if !MaxWeightsLimit::<T>::contains_key(netuid) {
MaxWeightsLimit::<T>::insert(netuid, MaxWeightsLimit::<T>::get(netuid));
}
if !MinAllowedWeights::<T>::contains_key(netuid) {
MinAllowedWeights::<T>::insert(netuid, MinAllowedWeights::<T>::get(netuid));
}
if !RegistrationsThisInterval::<T>::contains_key(netuid) {
RegistrationsThisInterval::<T>::insert(
netuid,
RegistrationsThisInterval::<T>::get(netuid),
);
}
if !POWRegistrationsThisInterval::<T>::contains_key(netuid) {
POWRegistrationsThisInterval::<T>::insert(
netuid,
POWRegistrationsThisInterval::<T>::get(netuid),
);
}
if !BurnRegistrationsThisInterval::<T>::contains_key(netuid) {
BurnRegistrationsThisInterval::<T>::insert(
netuid,
BurnRegistrationsThisInterval::<T>::get(netuid),
);
}

// Set max allowed uids
MaxAllowedUids::<T>::insert(netuid, max_uids);

let mut next_uid: u16 = 0;

for (coldkey, hotkeys) in self.stakes.iter() {
for (hotkey, stake_uid) in hotkeys.iter() {
let (stake, uid) = stake_uid;

// Expand Yuma Consensus with new position.
Rank::<T>::mutate(netuid, |v| v.push(0));
Trust::<T>::mutate(netuid, |v| v.push(0));
Active::<T>::mutate(netuid, |v| v.push(true));
Emission::<T>::mutate(netuid, |v| v.push(0));
Consensus::<T>::mutate(netuid, |v| v.push(0));
Incentive::<T>::mutate(netuid, |v| v.push(0));
Dividends::<T>::mutate(netuid, |v| v.push(0));
LastUpdate::<T>::mutate(netuid, |v| v.push(0));
PruningScores::<T>::mutate(netuid, |v| v.push(0));
ValidatorTrust::<T>::mutate(netuid, |v| v.push(0));
ValidatorPermit::<T>::mutate(netuid, |v| v.push(false));

// Insert account information.
Keys::<T>::insert(netuid, uid, hotkey.clone()); // Make hotkey - uid association.
Uids::<T>::insert(netuid, hotkey.clone(), uid); // Make uid - hotkey association.
BlockAtRegistration::<T>::insert(netuid, uid, 0); // Fill block at registration.
IsNetworkMember::<T>::insert(hotkey.clone(), netuid, true); // Fill network is member.

// Fill stake information.
Owner::<T>::insert(hotkey.clone(), coldkey.clone());

TotalHotkeyStake::<T>::insert(hotkey.clone(), stake);
TotalColdkeyStake::<T>::insert(
coldkey.clone(),
TotalColdkeyStake::<T>::get(coldkey).saturating_add(*stake),
);

// Update total issuance value
TotalIssuance::<T>::put(TotalIssuance::<T>::get().saturating_add(*stake));

Stake::<T>::insert(hotkey.clone(), coldkey.clone(), stake);

next_uid = next_uid.saturating_add(1);
}
}

// Set correct length for Subnet neurons
SubnetworkN::<T>::insert(netuid, next_uid);

// Increase total network count.
Pallet::<T>::increment_total_subnets(netuid);

// Get the root network uid.
let root_netuid: u16 = 0;

Expand Down

0 comments on commit 5d77cae

Please sign in to comment.