Skip to content

Commit

Permalink
add gamma halving
Browse files Browse the repository at this point in the history
  • Loading branch information
camfairchild committed Dec 20, 2024
1 parent e0cade8 commit 170a5aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pallets/subtensor/src/coinbase/block_emission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<T: Config> Pallet<T> {
return Ok(0);
}

// Calculate half of the total supply (10.5 billion * 10^6)
// Calculate half of the total supply (10.5 million * 10^9 RAO) == 1/2 * 21 million TAO
let half_total_supply =
I96F32::from_num(2.0).saturating_mul(I96F32::from_num(10_500_000_000_000_000.0));

Expand Down
10 changes: 10 additions & 0 deletions pallets/subtensor/src/coinbase/block_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,18 @@ impl<T: Config + pallet_drand::Config> Pallet<T> {
let first_time: bool =
!HalvingBlock::<T>::iter().any(|(_, emission)| emission == new_emission);
if first_time {
Self::halve_gamma();
}
}

pub fn halve_gamma() {
for netuid in Self::get_all_subnet_netuids() {
if netuid == Self::get_root_netuid() {
continue; // Skip root netuid.
}
let gamma: u64 = Self::get_raw_global_weight(netuid);
let halved_gamma: u64 = gamma.saturating_div(2);
Self::set_global_weight(halved_gamma, netuid);
}
}
}

0 comments on commit 170a5aa

Please sign in to comment.