Skip to content

Commit 0b49118

Browse files
committed
Address nit: rounding
1 parent 97f9a6e commit 0b49118

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ impl<T: Config> Pallet<T> {
199199
mining_emission: u64,
200200
) {
201201
// --- 1. First, calculate the hotkey's share of the emission.
202-
let childkey_take_proportion: I64F64 =
203-
I64F64::from_num(Self::get_childkey_take(hotkey, netuid))
204-
.saturating_div(I64F64::from_num(u16::MAX));
202+
let childkey_take_proportion: I96F32 =
203+
I96F32::from_num(Self::get_childkey_take(hotkey, netuid))
204+
.saturating_div(I96F32::from_num(u16::MAX));
205205
let mut total_childkey_take: u64 = 0;
206206

207207
// --- 2. Track the remaining emission for accounting purposes.
@@ -225,19 +225,21 @@ impl<T: Config> Pallet<T> {
225225
);
226226
let proportion_from_parent: I96F32 =
227227
stake_from_parent.saturating_div(I96F32::from_num(total_hotkey_stake));
228-
let parent_emission: u64 = proportion_from_parent
229-
.saturating_mul(I96F32::from_num(validating_emission))
230-
.to_num::<u64>();
228+
let parent_emission: I96F32 =
229+
proportion_from_parent.saturating_mul(I96F32::from_num(validating_emission));
231230

232231
// --- 4.3 Childkey take as part of parent emission
233232
let child_emission_take: u64 = childkey_take_proportion
234-
.saturating_mul(I64F64::from_num(parent_emission))
233+
.saturating_mul(parent_emission)
235234
.to_num::<u64>();
236-
total_childkey_take = total_childkey_take.saturating_add(child_emission_take);
235+
total_childkey_take =
236+
total_childkey_take.saturating_add(child_emission_take);
237237
// NOTE: Only the validation emission should be split amongst parents.
238238

239239
// --- 4.4 Compute the remaining parent emission after the childkey's share is deducted.
240-
let parent_emission_take: u64 = parent_emission.saturating_sub(child_emission_take);
240+
let parent_emission_take: u64 = parent_emission
241+
.to_num::<u64>()
242+
.saturating_sub(child_emission_take);
241243

242244
// --- 4.5. Accumulate emissions for the parent hotkey.
243245
PendingdHotkeyEmission::<T>::mutate(parent, |parent_accumulated| {

0 commit comments

Comments
 (0)