Skip to content

Commit adce61b

Browse files
author
Samuel Dare
committed
chore: saturating div , update ema dense
1 parent e0c9f2a commit adce61b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

pallets/subtensor/src/epoch.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ impl<T: Config> Pallet<T> {
832832
consensus_high: I32F32,
833833
consensus_low: I32F32,
834834
) -> (I32F32, I32F32) {
835-
log::info!("alpha_high: {:?}", alpha_high);
836-
log::info!("alpha_low: {:?}", alpha_low);
835+
log::trace!("alpha_high: {:?}", alpha_high);
836+
log::trace!("alpha_low: {:?}", alpha_low);
837837
log::trace!("consensus_high: {:?}", consensus_high);
838838
log::trace!("consensus_low: {:?}", consensus_low);
839839
// Check for division by zero
@@ -846,9 +846,9 @@ impl<T: Config> Pallet<T> {
846846
// Calculate the slope 'a' of the logistic function.
847847
// a = (ln((1 / alpha_high - 1)) - ln((1 / alpha_low - 1))) / (consensus_low - consensus_high)
848848
let a =
849-
(safe_ln((I32F32::from_num(1.0) / alpha_high).saturating_sub(I32F32::from_num(1.0)))
849+
(safe_ln((I32F32::from_num(1.0).saturating_div( alpha_high)).saturating_sub(I32F32::from_num(1.0)))
850850
.saturating_sub(safe_ln(
851-
(I32F32::from_num(1.0) / alpha_low).saturating_sub(I32F32::from_num(1.0)),
851+
(I32F32::from_num(1.0).saturating_div( alpha_low)).saturating_sub(I32F32::from_num(1.0)),
852852
)))
853853
.saturating_div(consensus_low.saturating_sub(consensus_high));
854854
log::trace!("a: {:?}", a);
@@ -1073,10 +1073,6 @@ impl<T: Config> Pallet<T> {
10731073
// Calculate the 75th percentile (high) and 25th percentile (low) of the consensus values.
10741074
let consensus_high = quantile(&consensus, 0.75);
10751075
let consensus_low = quantile(&consensus, 0.25);
1076-
// consensus_low < 0 ||
1077-
// consensus_high <= consensus_low ||
1078-
// alpha_low < 0 ||
1079-
// alpha_high <= alpha_low
10801076
// Further check if the high and low consensus values meet the required conditions.
10811077
if (consensus_high > consensus_low) || consensus_high != 0 || consensus_low < 0 {
10821078
// if (consensus_high > consensus_low) || consensus_high != 0) || consensus_low != 0 {
@@ -1149,7 +1145,7 @@ impl<T: Config> Pallet<T> {
11491145
let consensus_low = quantile(&consensus, 0.25);
11501146

11511147
// Further check if the high and low consensus values meet the required conditions.
1152-
if (consensus_high > consensus_low) && consensus_high != 0 && consensus_low != 0 {
1148+
if (consensus_high > consensus_low) || consensus_high != 0 || consensus_low < 0 {
11531149
log::trace!("Using Liquid Alpha");
11541150

11551151
// Get the high and low alpha values for the network.

0 commit comments

Comments
 (0)