Skip to content

Commit

Permalink
add dynamic block
Browse files Browse the repository at this point in the history
  • Loading branch information
unconst committed Jan 9, 2025
1 parent 8ac655f commit 71b05c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,8 @@ pub mod pallet {
pub type TotalIssuance<T> = StorageValue<_, u64, ValueQuery, DefaultTotalIssuance<T>>;
#[pallet::storage] // --- ITEM ( total_stake )
pub type TotalStake<T> = StorageValue<_, u64, ValueQuery>;
#[pallet::storage] // --- ITEM ( dynamic_block ) -- block when dynamic was turned on.
pub type DynamicBlock<T> = StorageValue<_, u64, ValueQuery>;
#[pallet::storage] // --- DMAP ( netuid ) --> total_volume | The total amount of TAO bought and sold since the start of the network.
pub type SubnetVolume<T: Config> =
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultZeroU64<T>>;
Expand Down Expand Up @@ -970,9 +972,6 @@ pub mod pallet {
#[pallet::storage] // --- DMAP ( netuid ) --> subnet_name | Returns the name of the subnet.
pub type SubnetName<T: Config> =
StorageMap<_, Identity, u16, Vec<u8>, ValueQuery, DefaultUnicodeVecU8<T>>;
#[pallet::storage] // --- DMAP ( netuid ) --> block_at_dtao_transition | Returns the block when the subnet transitioned to DTAO.
pub type DynamicBlock<T: Config> =
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultUnicodeVecU8<T>>;

/// ============================
/// ==== Global Parameters =====
Expand Down
4 changes: 3 additions & 1 deletion pallets/subtensor/src/migrations/migrate_rao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub fn migrate_rao<T: Config>() -> Weight {
.collect();
weight = weight.saturating_add(T::DbWeight::get().reads_writes(netuids.len() as u64, 0));

// Set the Dynamic block.
DynamicBlock::<T>::insert(netuid, Pallet::<T>::get_current_block_as_u64() );

// Migrate all TAO to root.
Stake::<T>::iter().for_each(|(hotkey, coldkey, stake)| {
// Increase SubnetTAO on root.
Expand Down Expand Up @@ -59,7 +62,6 @@ pub fn migrate_rao<T: Config>() -> Weight {
// Set global weight to 18% from the start
TaoWeight::<T>::set(332_041_393_326_771_929);
for netuid in netuids.iter().clone() {
DynamicBlock::<T>::insert(netuid, Pallet::<T>::get_current_block_as_u64() );
if *netuid == 0 {
// Give root a single RAO in pool to avoid any catestrophic division by zero.
SubnetAlphaIn::<T>::insert(netuid, 1);
Expand Down
1 change: 0 additions & 1 deletion pallets/subtensor/src/subnets/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ impl<T: Config> Pallet<T> {
// --- 11. Set the creation terms.
NetworkLastRegistered::<T>::set(current_block);
NetworkRegisteredAt::<T>::insert(netuid_to_register, current_block);
DynamicBlock::<T>::insert( netuid_to_register, current_block );

// --- 14. Init the pool by putting the lock as the initial alpha.
TokenSymbol::<T>::insert(
Expand Down

0 comments on commit 71b05c1

Please sign in to comment.