mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 23:16:52 +00:00
Enable universal boost (#126)
* disable boosts for migration * renable new boosts * take rate * enable universal boost * bump version
This commit is contained in:
39
Cargo.lock
generated
39
Cargo.lock
generated
@@ -1246,9 +1246,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ore-api"
|
||||
version = "3.2.0-boostv3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06956691f3138fabb379f1e991c94eb9f924715efaafbd1af8df07fc451c8ea6"
|
||||
version = "3.6.0-beta"
|
||||
dependencies = [
|
||||
"array-const-fn-init",
|
||||
"bytemuck",
|
||||
@@ -1266,7 +1264,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ore-api"
|
||||
version = "3.5.0"
|
||||
version = "3.6.0-beta"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eff73b3394583f3df7ce0f58e9ec66d890777c6cc6dd739de63f8ec826fd4baf"
|
||||
dependencies = [
|
||||
"array-const-fn-init",
|
||||
"bytemuck",
|
||||
@@ -1284,35 +1284,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ore-boost-api"
|
||||
version = "1.5.0-boostv3"
|
||||
version = "4.0.0-beta"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c423e9bcedb910473119e3a6ee8fa81e73875f3f15df92fc7e0de045091d6fd3"
|
||||
dependencies = [
|
||||
"array-const-fn-init",
|
||||
"bytemuck",
|
||||
"const-crypto",
|
||||
"num_enum",
|
||||
"ore-api 3.2.0-boostv3",
|
||||
"solana-program",
|
||||
"spl-associated-token-account",
|
||||
"spl-token 4.0.2",
|
||||
"static_assertions",
|
||||
"steel",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ore-boost-api"
|
||||
version = "3.0.0"
|
||||
source = "git+https://github.com/regolith-labs/ore-boost.git?rev=924105c#924105c494d950a2e2c3322972d18d6da83a5384"
|
||||
checksum = "d0d09065544f61448a879ee9cc04e1c45a13ba76c38988fce83faa3f7aa31b1f"
|
||||
dependencies = [
|
||||
"array-const-fn-init",
|
||||
"bytemuck",
|
||||
"const-crypto",
|
||||
"fixed",
|
||||
"num_enum",
|
||||
"ore-api 3.2.0-boostv3",
|
||||
"ore-boost-api 1.5.0-boostv3",
|
||||
"ore-api 3.6.0-beta (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-program",
|
||||
"spl-associated-token-account",
|
||||
"spl-token 4.0.2",
|
||||
@@ -1323,12 +1304,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ore-program"
|
||||
version = "3.5.0"
|
||||
version = "3.6.0-beta"
|
||||
dependencies = [
|
||||
"drillx",
|
||||
"mpl-token-metadata",
|
||||
"ore-api 3.5.0",
|
||||
"ore-boost-api 3.0.0",
|
||||
"ore-api 3.6.0-beta",
|
||||
"ore-boost-api",
|
||||
"rand 0.8.5",
|
||||
"solana-program",
|
||||
"spl-associated-token-account",
|
||||
|
||||
@@ -3,11 +3,11 @@ resolver = "2"
|
||||
members = ["api", "program"]
|
||||
|
||||
[workspace.package]
|
||||
version = "3.5.0"
|
||||
version = "3.6.0-beta"
|
||||
edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://ore.supply"
|
||||
description = "Liquid digial gold everyone can mine"
|
||||
description = "Liquid digial gold"
|
||||
documentation = "https://docs.rs/ore-api/latest/ore_api/"
|
||||
repository = "https://github.com/regolith-labs/ore"
|
||||
readme = "./README.md"
|
||||
@@ -22,7 +22,7 @@ drillx = { version = "2.2", features = ["solana"] }
|
||||
mpl-token-metadata = "5.1"
|
||||
num_enum = "0.7.2"
|
||||
ore-api = { path = "api" }
|
||||
ore-boost-api = { version = "3.0", git = "https://github.com/regolith-labs/ore-boost.git", rev = "924105c" }
|
||||
ore-boost-api = "4.0.0-alpha"
|
||||
solana-program = "^2.1"
|
||||
spl-token = { version = "^4", features = ["no-entrypoint"] }
|
||||
spl-associated-token-account = { version = "^6", features = [ "no-entrypoint" ] }
|
||||
|
||||
@@ -56,7 +56,6 @@ pub fn mine(
|
||||
authority: Pubkey,
|
||||
bus: Pubkey,
|
||||
solution: Solution,
|
||||
boost: Pubkey,
|
||||
boost_config: Pubkey,
|
||||
) -> Instruction {
|
||||
let proof = proof_pda(authority).0;
|
||||
@@ -67,9 +66,8 @@ pub fn mine(
|
||||
AccountMeta::new(proof, false),
|
||||
AccountMeta::new_readonly(sysvar::instructions::ID, false),
|
||||
AccountMeta::new_readonly(sysvar::slot_hashes::ID, false),
|
||||
AccountMeta::new_readonly(boost, false),
|
||||
AccountMeta::new(proof_pda(boost).0, false),
|
||||
AccountMeta::new_readonly(boost_config, false),
|
||||
AccountMeta::new(proof_pda(boost_config).0, false),
|
||||
];
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
|
||||
@@ -2,10 +2,7 @@ use std::mem::size_of;
|
||||
|
||||
use drillx::Solution;
|
||||
use ore_api::prelude::*;
|
||||
use ore_boost_api::{
|
||||
consts::{DENOMINATOR_BPS, ROTATION_DURATION},
|
||||
state::{Boost, Config as BoostConfig},
|
||||
};
|
||||
use ore_boost_api::{consts::DENOMINATOR_BPS, state::Config as BoostConfig};
|
||||
use solana_program::{
|
||||
keccak::hashv,
|
||||
sanitize::SanitizeError,
|
||||
@@ -47,14 +44,13 @@ pub fn process_mine(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult {
|
||||
slot_hashes_sysvar.is_sysvar(&sysvar::slot_hashes::ID)?;
|
||||
|
||||
// Load boost accounts.
|
||||
let [boost_info, boost_proof_info, boost_config_info] = boost_accounts else {
|
||||
let [boost_config_info, boost_proof_info] = boost_accounts else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
let boost = boost_info.as_account::<Boost>(&ore_boost_api::ID)?;
|
||||
let boost_config = boost_config_info.as_account::<BoostConfig>(&ore_boost_api::ID)?;
|
||||
let boost_proof = boost_proof_info
|
||||
.as_account_mut::<Proof>(&ore_api::ID)?
|
||||
.assert_mut(|p| p.authority == *boost_info.key)?;
|
||||
.assert_mut(|p| p.authority == *boost_config_info.key)?;
|
||||
|
||||
// Authenticate the proof account.
|
||||
//
|
||||
@@ -96,13 +92,7 @@ pub fn process_mine(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult {
|
||||
// The reward doubles for every bit of difficulty (leading zeros) on the hash. We use the normalized
|
||||
// difficulty so the minimum accepted difficulty pays out at the base reward rate.
|
||||
let normalized_difficulty = difficulty - config.min_difficulty as u32;
|
||||
let mut gross_reward =
|
||||
config.base_reward_rate * 2u64.checked_pow(normalized_difficulty).unwrap();
|
||||
|
||||
// Zero out gross reward if boost is invalid.
|
||||
if boost_config.current != *boost_info.key || t >= boost_config.ts + ROTATION_DURATION {
|
||||
gross_reward = 0;
|
||||
}
|
||||
let gross_reward = config.base_reward_rate * 2u64.checked_pow(normalized_difficulty).unwrap();
|
||||
|
||||
// Apply liveness penalty.
|
||||
//
|
||||
@@ -143,15 +133,8 @@ pub fn process_mine(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult {
|
||||
.min(config.target_emmissions_rate);
|
||||
|
||||
// Split the net reward between the miner and stakers.
|
||||
//
|
||||
// The boost take rate is capped at 50% of the net reward. This protects miners from excessively
|
||||
// large boost incentives that would overly skew the distribution of rewards.
|
||||
let boost_bps = boost.multiplier;
|
||||
let net_boost_reward = if t < boost.expires_at {
|
||||
(net_reward as u128 * boost_bps as u128 / DENOMINATOR_BPS as u128) as u64
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let net_boost_reward =
|
||||
(net_reward as u128 * boost_config.take_rate as u128 / DENOMINATOR_BPS as u128) as u64;
|
||||
let net_miner_reward = net_reward - net_boost_reward;
|
||||
|
||||
// Sanity check the rewards.
|
||||
|
||||
Reference in New Issue
Block a user