Skip to content

Commit

Permalink
test(networking): update tests for pricing curve tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef committed May 13, 2024
1 parent cfb91da commit 7893725
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions sn_networking/src/record_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,12 @@ pub fn calculate_cost_for_records(quoting_metrics: &QuotingMetrics) -> u64 {
let rewarder = max(1, base_multiplier.powf(reward_steps as f32) as u64);

// 1.05.powf(800) = 9E+16
// Given currently the max_records is set at 2048,
// Given currently the max_records is set at MAX_RECORDS,
// hence setting the multiplier trigger at 60% of the max_records
let exponential_pricing_trigger = 6 * max_records / 10;

let base_multiplier = 1.05_f32;
// Fine tuning here helps to get a desired curve
let base_multiplier = 1.0225_f32;
let multiplier = max(
1,
base_multiplier.powf(records_stored.saturating_sub(exponential_pricing_trigger) as f32)
Expand Down Expand Up @@ -922,7 +923,7 @@ mod tests {
live_time: 1,
});
// at this point we should be at max cost
assert_eq!(sut, 10240);
assert_eq!(sut, 20480);
}
#[test]
fn test_calculate_60_percent_cost_for_records() {
Expand All @@ -934,7 +935,7 @@ mod tests {
live_time: 1,
});
// at this point we should be at max cost
assert_eq!(sut, 12280);
assert_eq!(sut, 24570);
}

#[test]
Expand All @@ -947,7 +948,7 @@ mod tests {
live_time: 1,
});
// at this point we should be at max cost
assert_eq!(sut, 2023120);
assert_eq!(sut, 2528900);
}

#[test]
Expand All @@ -960,7 +961,7 @@ mod tests {
live_time: 1,
});
// at this point we should be at max cost
assert_eq!(sut, 316248770);
assert_eq!(sut, 262645870);
}

#[test]
Expand All @@ -973,7 +974,7 @@ mod tests {
live_time: 1,
});
// at this point we should be at max cost
assert_eq!(sut, 7978447975680);
assert_eq!(sut, 2689140767040);
}

#[test]
Expand All @@ -986,7 +987,7 @@ mod tests {
live_time: 1,
});
// at this point we should be at max cost
assert_eq!(sut, 198121748221132800);
assert_eq!(sut, 27719885856440320);
}

#[test]
Expand Down

0 comments on commit 7893725

Please sign in to comment.