Skip to content

Commit

Permalink
rao
Browse files Browse the repository at this point in the history
  • Loading branch information
unconst committed Aug 15, 2024
1 parent e7f9096 commit ed95db2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions pallets/subtensor/src/migrations/migrate_rao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pub fn migrate_rao<T: Config>() -> Weight {
}); // Increase the stake.
TotalStake::<T>::put(TotalStake::<T>::get().saturating_add(lock)); // Increase the total stake.
SubnetMechanism::<T>::insert(netuid, 1); // Convert to dynamic immediately with initialization.
SubnetLocked::<T>::insert(netuid, lock);
LargestLocked::<T>::insert(netuid, lock);
Locks::<T>::insert(
// Lock the initial funds making this key the owner.
(netuid, owner.clone(), owner.clone()), // Sets owner as initial lock.
Expand Down
15 changes: 10 additions & 5 deletions pallets/subtensor/src/rpc_info/dynamic_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,37 @@ use frame_support::pallet_prelude::{Decode, Encode};

#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
pub struct DynamicInfo<T: Config>{
owner: T::AccountId,
netuid: Compact<u16>,
tempo: Compact<u16>,
last_step: Compact<u64>,
owner: T::AccountId,
blocks_since_last_step: Compact<u64>,
emission: Compact<u64>,
alpha_in: Compact<u64>,
alpha_out: Compact<u64>,
tao_in: Compact<u64>,
total_locked: Compact<u64>,
owner_locked: Compact<u64>,
netuid: Compact<u16>,
}

impl<T: Config> Pallet<T> {
pub fn get_dynamic_info(netuid: u16) -> Option<DynamicInfo<T>> {
if !Self::if_subnet_exist(netuid) {return None;}
let last_step: u64 = LastMechansimStepBlock::<T>::get( netuid );
let current_block: u64 = Pallet::<T>::get_current_block_as_u64();
let blocks_since_last_step: u64 = current_block - last_step;
Some(DynamicInfo {
tempo: Tempo::<T>::get( netuid ).into(),
last_step: LastMechansimStepBlock::<T>::get( netuid ).into(),
owner: SubnetOwner::<T>::get( netuid ).into(),
netuid: netuid.into(),
tempo: Tempo::<T>::get( netuid ).into(),
last_step: last_step.into(),
blocks_since_last_step: blocks_since_last_step.into(),
emission: EmissionValues::<T>::get( netuid ).into(),
alpha_in: SubnetAlphaIn::<T>::get( netuid ).into(),
alpha_out: SubnetAlphaOut::<T>::get( netuid ).into(),
tao_in: SubnetTAO::<T>::get( netuid ).into(),
total_locked: SubnetLocked::<T>::get( netuid ).into(),
owner_locked: LargestLocked::<T>::get( netuid ).into(),
netuid: netuid.into(),
})
}
pub fn get_all_dynamic_info() -> Vec<Option<DynamicInfo<T>>> {
Expand Down
4 changes: 3 additions & 1 deletion pallets/subtensor/src/subnets/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ impl<T: Config> Pallet<T> {
NetworkRegisteredAt::<T>::insert(netuid_to_register, current_block);

// --- 14. Init the pool by putting the lock as the initial alpha.
SubnetOwner::<T>::insert(netuid_to_register, coldkey.clone()); // Set the owner.
SubnetTAO::<T>::insert(netuid_to_register, 1); // add the TAO to the pool.
SubnetAlphaIn::<T>::insert(netuid_to_register, actual_tao_lock_amount); // Set the alpha in based on the lock.
let alpha_out = Self::stake_into_subnet(
Expand All @@ -183,6 +182,9 @@ impl<T: Config> Pallet<T> {
netuid_to_register,
actual_tao_lock_amount,
);
SubnetOwner::<T>::insert(netuid_to_register, coldkey.clone());
SubnetLocked::<T>::insert(netuid_to_register, alpha_out);
LargestLocked::<T>::insert(netuid_to_register, alpha_out);
Locks::<T>::insert(
// Lock the initial funds making this key the owner.
(netuid_to_register, hotkey.clone(), coldkey.clone()),
Expand Down
2 changes: 1 addition & 1 deletion scripts/specs/raonet.json

Large diffs are not rendered by default.

0 comments on commit ed95db2

Please sign in to comment.