block based sha256 mining

This commit is contained in:
Hardhat Chad
2025-05-10 10:36:37 -07:00
parent 3492feef67
commit ae53d0e829
7 changed files with 136 additions and 896 deletions

View File

@@ -1,25 +0,0 @@
use steel::*;
use super::OreAccount;
/// Bus accounts are responsible for distributing mining rewards. There are 8 busses total
/// to minimize write-lock contention and allow Solana to process mine instructions in parallel.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Bus {
/// The ID of the bus account.
pub id: u64,
/// The remaining rewards this bus has left to payout in the current epoch.
pub rewards: u64,
/// The rewards this bus would have paid out in the current epoch if there no limit.
/// This is used to calculate the updated reward rate.
pub theoretical_rewards: u64,
/// The largest known stake balance seen by the bus this epoch.
#[deprecated(since = "2.8.0", note = "Top balance is no longer tracked or used")]
pub top_balance: u64,
}
account!(OreAccount, Bus);

View File

@@ -6,17 +6,20 @@ use super::OreAccount;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Config {
/// The base reward rate paid out for a hash of minimum difficulty.
pub base_reward_rate: u64,
/// The timestamp of the last reset.
pub last_reset_at: i64,
/// The minimum accepted difficulty.
pub min_difficulty: u64,
/// The best difficulty score of this epoch.
pub best_difficulty: u64,
/// The proof of the best submitted hash of this epoch.
pub best_proof: Pubkey,
/// The challenge of this epoch.
pub challenge: [u8; 32],
/// The target emissions rate in ORE/min.
pub target_emmissions_rate: u64,
pub block_reward: u64,
}
account!(OreAccount, Config);

View File

@@ -1,9 +1,7 @@
mod bus;
mod config;
mod proof;
mod treasury;
pub use bus::*;
pub use config::*;
pub use proof::*;
pub use treasury::*;
@@ -15,17 +13,11 @@ use crate::consts::*;
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum OreAccount {
Bus = 100,
Config = 101,
Proof = 102,
Treasury = 103,
}
/// Fetch the PDA of a bus account.
pub fn bus_pda(id: u8) -> (Pubkey, u8) {
Pubkey::find_program_address(&[BUS, &[id]], &crate::id())
}
/// Derive the PDA of the config account.
pub fn config_pda() -> (Pubkey, u8) {
Pubkey::find_program_address(&[CONFIG], &crate::id())