scaffolding boosts

This commit is contained in:
Hardhat Chad
2024-08-24 13:57:00 +00:00
parent 7e7b72874c
commit 618a15ae1b
4 changed files with 33 additions and 1 deletions

16
Cargo.lock generated
View File

@@ -1302,6 +1302,21 @@ dependencies = [
"thiserror",
]
[[package]]
name = "ore-boost-api"
version = "0.1.0"
dependencies = [
"array-const-fn-init",
"bytemuck",
"const-crypto",
"num_enum",
"ore-utils",
"solana-program",
"spl-token",
"static_assertions",
"thiserror",
]
[[package]]
name = "ore-program"
version = "2.1.9"
@@ -1309,6 +1324,7 @@ dependencies = [
"drillx",
"mpl-token-metadata",
"ore-api",
"ore-boost-api",
"ore-utils",
"rand 0.8.5",
"solana-program",

View File

@@ -20,6 +20,7 @@ drillx = { version = "2.0.0", features = ["solana"] }
mpl-token-metadata = "4.1.2"
num_enum = "0.7.2"
ore-api = { path = "api", version = "2.1.9" }
ore-boost-api = { path = "../ore-boost/api", version = "0.1.0" }
ore-utils = { path = "utils", features = ["spl"], version = "2.1.9" }
solana-program = "^1.18"
spl-token = { version = "^4", features = ["no-entrypoint"] }

View File

@@ -21,6 +21,7 @@ default = []
drillx.workspace = true
mpl-token-metadata.workspace = true
ore-api.workspace = true
ore-boost-api.workspace = true
ore-utils.workspace = true
solana-program.workspace = true
spl-token.workspace = true

View File

@@ -9,6 +9,7 @@ use ore_api::{
loaders::*,
state::{Bus, Config, Proof},
};
use ore_boost_api::state::{Boost, Stake};
use ore_utils::*;
use solana_program::program::set_return_data;
#[allow(deprecated)]
@@ -31,8 +32,9 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
let args = Mine::try_from_bytes(data)?;
// Load accounts.
let (required_accounts, optional_accounts) = accounts.split_at(6);
let [signer, bus_info, config_info, proof_info, instructions_sysvar, slot_hashes_sysvar] =
accounts
required_accounts
else {
return Err(ProgramError::NotEnoughAccountKeys);
};
@@ -129,6 +131,18 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
}
}
if !optional_accounts.is_empty() {
let [boost_info, stake_info] = optional_accounts else {
return Err(ProgramError::NotEnoughAccountKeys);
};
let boost_data = boost_info.data.borrow();
let boost = Boost::try_from_bytes(&boost_data)?;
let stake_data = stake_info.data.borrow();
let stake = Stake::try_from_bytes(&stake_data)?;
}
// Apply liveness penalty.
//
// The liveness penalty exists to ensure there is no "invisible" hashpower on the network. It