Merge branch 'hardhat/no-crown' of https://github.com/regolith-labs/ore into hardhat/no-crown

This commit is contained in:
Hardhat Chad
2024-07-20 20:45:15 +00:00
3 changed files with 19 additions and 13 deletions

View File

@@ -2,25 +2,23 @@ use array_const_fn_init::array_const_fn_init;
use const_crypto::ed25519;
use solana_program::{pubkey, pubkey::Pubkey};
/// The admin allowed to initialize the program.
pub const ADMIN: Pubkey = pubkey!("HBUh9g46wk2X89CvaNN15UmsznP59rh6od1h8JwYAopk");
/// The authority allowed to initialize the program.
pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("HBUh9g46wk2X89CvaNN15UmsznP59rh6od1h8JwYAopk");
/// The reward rate to intialize the program with.
pub const INITIAL_BASE_REWARD_RATE: u64 = 2u64.pow(25); // 10u64.pow(3u32);
/// The base reward rate to intialize the program with.
pub const INITIAL_BASE_REWARD_RATE: u64 = 2u64.pow(6);
/// The minimum threshold for the base reward rate, at which point the min difficulty should be increased
// TODO 2^8 (0.00000000256)
pub const BASE_REWARD_RATE_MIN_THRESHOLD: u64 = 2u64.pow(24);
/// The minimum allowed base reward rate, at which point the min difficulty should be increased
pub const BASE_REWARD_RATE_MIN_THRESHOLD: u64 = 2u64.pow(5);
/// The maximum threshold for the base reward rate, at which point the min difficulty should be decreased.
// TODO 2^32 (0.04294967296)
pub const BASE_REWARD_RATE_MAX_THRESHOLD: u64 = 2u64.pow(26);
/// 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(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; // 8;
pub const INITIAL_MIN_DIFFICULTY: u32 = 8;
/// The decimal precision of the ORE token.
/// There are 100 billion indivisible units per ORE (called "grains").

View File

@@ -91,7 +91,7 @@ pub fn process_initialize<'a, 'info>(
load_sysvar(rent_sysvar, sysvar::rent::id())?;
// Check signer
if signer.key.ne(&ADMIN) {
if signer.key.ne(&INITIALIZER_ADDRESS) {
return Err(ProgramError::MissingRequiredSignature);
}

View File

@@ -180,7 +180,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;
@@ -209,6 +210,13 @@ mod tests {
assert!(new_rate.lt(&current_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(&current_rate));
}
#[test]
fn test_calculate_new_reward_rate_lower_fuzz() {
let mut rng = rand::thread_rng();