remove staking program

This commit is contained in:
Hardhat Chad
2024-07-01 14:14:42 -05:00
parent d53f76c639
commit a7c6da1881
31 changed files with 40 additions and 48 deletions

31
api/src/state/bus.rs Normal file
View File

@@ -0,0 +1,31 @@
use bytemuck::{Pod, Zeroable};
use shank::ShankAccount;
use crate::utils::{impl_account_from_bytes, impl_to_bytes, Discriminator};
use super::AccountDiscriminator;
/// Bus accounts are responsible for distributing mining rewards.
/// There are 8 busses total to minimize write-lock contention and allow for parallel mine operations.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, ShankAccount, 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.
/// Used to calculate the updated reward rate.
pub theoretical_rewards: u64,
}
impl Discriminator for Bus {
fn discriminator() -> u8 {
AccountDiscriminator::Bus.into()
}
}
impl_to_bytes!(Bus);
impl_account_from_bytes!(Bus);

36
api/src/state/config.rs Normal file
View File

@@ -0,0 +1,36 @@
use bytemuck::{Pod, Zeroable};
use shank::ShankAccount;
use solana_program::pubkey::Pubkey;
use crate::utils::{impl_account_from_bytes, impl_to_bytes, Discriminator};
use super::AccountDiscriminator;
/// Config is a singleton account which manages admin configurable variables.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, ShankAccount, Zeroable)]
pub struct Config {
/// The admin authority with permission to update the difficulty.
pub admin: Pubkey,
/// 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 largest known stake balance on the network.
pub max_stake: u64,
/// The address of the proof account with the highest stake balance.
pub top_staker: Pubkey,
}
impl Discriminator for Config {
fn discriminator() -> u8 {
AccountDiscriminator::Config.into()
}
}
impl_to_bytes!(Config);
impl_account_from_bytes!(Config);

20
api/src/state/mod.rs Normal file
View File

@@ -0,0 +1,20 @@
mod bus;
mod config;
mod proof;
mod treasury;
pub use bus::*;
pub use config::*;
pub use proof::*;
pub use treasury::*;
use num_enum::{IntoPrimitive, TryFromPrimitive};
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum AccountDiscriminator {
Bus = 100,
Config = 101,
Proof = 102,
Treasury = 103,
}

49
api/src/state/proof.rs Normal file
View File

@@ -0,0 +1,49 @@
use bytemuck::{Pod, Zeroable};
use shank::ShankAccount;
use solana_program::pubkey::Pubkey;
use crate::utils::{impl_account_from_bytes, impl_to_bytes, Discriminator};
use super::AccountDiscriminator;
/// Proof accounts track a miner's current hash, claimable rewards, and lifetime stats.
/// Every miner is allowed one proof account which is required by the program to mine or claim rewards.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, ShankAccount, Zeroable)]
pub struct Proof {
/// The signer authorized to use this proof.
pub authority: Pubkey,
/// The quantity of tokens this miner has staked or earned.
pub balance: u64,
/// The current mining challenge.
pub challenge: [u8; 32],
/// The last hash the miner provided.
pub last_hash: [u8; 32],
/// The last time this account provided a hash.
pub last_hash_at: i64,
/// The last time stake was deposited into this account.
pub last_stake_at: i64,
/// The keypair which has permission to submit hashes for mining.
pub miner: Pubkey,
/// The total lifetime hashes provided by this miner.
pub total_hashes: u64,
/// The total lifetime rewards distributed to this miner.
pub total_rewards: u64,
}
impl Discriminator for Proof {
fn discriminator() -> u8 {
AccountDiscriminator::Proof.into()
}
}
impl_to_bytes!(Proof);
impl_account_from_bytes!(Proof);

21
api/src/state/treasury.rs Normal file
View File

@@ -0,0 +1,21 @@
use bytemuck::{Pod, Zeroable};
use shank::ShankAccount;
use crate::utils::{impl_account_from_bytes, impl_to_bytes, Discriminator};
use super::AccountDiscriminator;
/// Treasury is a singleton account which manages all program wide variables.
/// It is the mint authority for the Ore token and also the authority of the program-owned token account.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, ShankAccount, Zeroable)]
pub struct Treasury {}
impl Discriminator for Treasury {
fn discriminator() -> u8 {
AccountDiscriminator::Treasury.into()
}
}
impl_to_bytes!(Treasury);
impl_account_from_bytes!(Treasury);