mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 07:26:51 +00:00
set range for min difficulty changes
This commit is contained in:
@@ -6,19 +6,19 @@ use solana_program::{pubkey, pubkey::Pubkey};
|
||||
pub const ADMIN: Pubkey = pubkey!("HBUh9g46wk2X89CvaNN15UmsznP59rh6od1h8JwYAopk");
|
||||
|
||||
/// The base reward rate to intialize the program with.
|
||||
pub const INITIAL_BASE_REWARD_RATE: u64 = 2u64.pow(10);
|
||||
pub const INITIAL_BASE_REWARD_RATE: u64 = 2u64.pow(6);
|
||||
|
||||
/// The minimum allowed base reward rate, at which point the min difficulty should be increased
|
||||
pub const BASE_REWARD_RATE_MIN_THRESHOLD: u64 = 2;
|
||||
pub const BASE_REWARD_RATE_MIN_THRESHOLD: u64 = 2u64.pow(5);
|
||||
|
||||
/// The maximum allowed base reward rate, at which point the min difficulty should be decreased.
|
||||
pub const BASE_REWARD_RATE_MAX_THRESHOLD: u64 = 2u64.pow(24);
|
||||
pub const BASE_REWARD_RATE_MAX_THRESHOLD: u64 = 2u64.pow(8);
|
||||
|
||||
/// The spam/liveness tolerance in seconds.
|
||||
pub const TOLERANCE: i64 = 5;
|
||||
|
||||
/// The minimum difficulty to initialize the program with.
|
||||
pub const INITIAL_MIN_DIFFICULTY: u32 = 0;
|
||||
pub const INITIAL_MIN_DIFFICULTY: u32 = 8;
|
||||
|
||||
/// The decimal precision of the ORE token.
|
||||
/// There are 100 billion indivisible units per ORE (called "grains").
|
||||
|
||||
@@ -115,7 +115,7 @@ pub fn process_mine<'a, 'info>(
|
||||
// If user has greater than or equal to the max stake on the network, they receive 2x multiplier.
|
||||
// Any stake less than this will receives between 1x and 2x multipler. The multipler is only active
|
||||
// if the miner's last stake deposit was more than one minute ago.
|
||||
if config.max_stake.gt(&0)
|
||||
if config.top_staker_balance.gt(&0)
|
||||
&& proof.balance.gt(&0)
|
||||
&& proof.last_stake_at.saturating_add(ONE_MINUTE).le(&t)
|
||||
{
|
||||
|
||||
@@ -172,7 +172,8 @@ mod tests {
|
||||
|
||||
use crate::calculate_new_reward_rate;
|
||||
use ore_api::consts::{
|
||||
BUS_EPOCH_REWARDS, MAX_EPOCH_REWARDS, SMOOTHING_FACTOR, TARGET_EPOCH_REWARDS,
|
||||
BASE_REWARD_RATE_MIN_THRESHOLD, BUS_EPOCH_REWARDS, MAX_EPOCH_REWARDS, SMOOTHING_FACTOR,
|
||||
TARGET_EPOCH_REWARDS,
|
||||
};
|
||||
|
||||
const FUZZ_SIZE: u64 = 10_000;
|
||||
@@ -201,6 +202,13 @@ mod tests {
|
||||
assert!(new_rate.lt(¤t_rate));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_calculate_new_reward_rate_lower_edge() {
|
||||
let current_rate = BASE_REWARD_RATE_MIN_THRESHOLD;
|
||||
let new_rate = calculate_new_reward_rate(current_rate, TARGET_EPOCH_REWARDS + 1);
|
||||
assert!(new_rate.lt(¤t_rate));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_calculate_new_reward_rate_lower_fuzz() {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
Reference in New Issue
Block a user