This commit is contained in:
Hardhat Chad
2025-10-03 10:50:12 -07:00
parent 4d302b43c1
commit 7a52ff73aa
2 changed files with 15 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
# ORE
ORE is a crypto mining game.
ORE is a crypto mining protocol.
## API
@@ -13,6 +13,7 @@ ORE is a crypto mining game.
#### Mining
- [`Automate`](program/src/automate.rs) - Configures a new automation.
- [`Checkpoint`](program/src/checkpoint.rs) - Checkpoints rewards from an prior round.
- [`ClaimORE`](program/src/claim_ore.rs) - Claims ORE mining rewards.
- [`ClaimSOL`](program/src/claim_sol.rs) - Claims SOL mining rewards.
- [`Deploy`](program/src/deploy.rs) Deploys SOL to claim space on the board.
@@ -36,11 +37,11 @@ ORE is a crypto mining game.
## State
- [`Automation`](api/src/state/automation.rs) - Tracks automation configs.
- [`Board`](api/src/state/board.rs) - Holds current game state.
- [`Board`](api/src/state/board.rs) - Tracks the current round number and timestamps.
- [`Config`](api/src/state/config.rs) - Global program configs.
- [`Miner`](api/src/state/miner.rs) - Tracks a miner's game state.
- [`Round`](api/src/state/round.rs) - Tracks the game state of a given round.
- [`Seeker`](api/src/state/seeker.rs) - Tracks whether a Seeker token has been claimed.
- [`Square`](api/src/state/square.rs) - The blockspace state and claims.
- [`Stake`](api/src/state/stake.rs) - Manages a user's staking activity.
- [`Treasury`](api/src/state/treasury.rs) - Mints, burns, and escrows ORE tokens.

View File

@@ -13,52 +13,48 @@ pub fn process_checkpoint(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Program
signer_info.is_signer()?;
let board = board_info.as_account::<Board>(&ore_api::ID)?;
let miner = miner_info.as_account_mut::<Miner>(&ore_api::ID)?;
// If miner has already checkpointed this round, return.
if miner.checkpoint_id == miner.round_id {
return Ok(());
}
// If round account is empty, verify the correct account was provided.
// This can happen if the miner attempted to checkpoint after the round expired and the account was closed.
// In this case, the miner forfeits any potential rewards.
if round_info.data_is_empty() {
// If round account is empty, ensure the correct account was provided.
// This can happen if the miner attempted to checkpoint after the round expired and the account was closed.
// In this case, the miner forfeits any potential rewards.
round_info.has_seeds(&[ROUND, &miner.round_id.to_le_bytes()], &ore_api::ID)?;
miner.checkpoint_id = miner.round_id;
return Ok(());
}
let round = round_info.as_account_mut::<Round>(&ore_api::ID)?;
// Ensure miner round ID matches the provided round.
if round.id != miner.round_id {
return Ok(());
}
treasury_info.as_account::<Treasury>(&ore_api::ID)?;
system_program.is_program(&system_program::ID)?;
// If round is current round, return.
if round.id == board.round_id {
// If round is current round, or the miner round ID does not match the provided round, return.
if round.id == board.round_id || round.id != miner.round_id {
return Ok(());
}
// Ensure round is not expired.
// In this case, the miner forfeits any potential rewards.
if clock.slot >= round.expires_at {
// In this case, the miner forfeits any potential rewards.
miner.checkpoint_id = miner.round_id;
return Ok(());
}
// Get the RNG.
// If the round has no RNG, no one wins.
let Some(r) = round.rng() else {
// If the round has no RNG, no one wins.
miner.checkpoint_id = miner.round_id;
return Ok(());
};
// Calculate bot fee.
// If the round expires in less than 12h, anyone may checkpoint this account and collect the bot fee.
let mut bot_fee = 0;
if clock.slot >= round.expires_at - TWELVE_HOURS_SLOTS {
// The round expires in less than 12h.
// Anyone may checkpoint this account and collect the bot fee.
bot_fee = miner.checkpoint_fee;
miner.checkpoint_fee = 0;
}
@@ -112,14 +108,6 @@ pub fn process_checkpoint(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Program
miner_info.send(bot_fee, &signer_info);
}
// Assert round has sufficient funds for rent.
let account_size = 8 + std::mem::size_of::<Round>();
let required_rent = Rent::get()?.minimum_balance(account_size);
assert!(
round_info.lamports() >= required_rent,
"Round does not have sufficient funds for rent"
);
let account_size = 8 + std::mem::size_of::<Miner>();
let required_rent = Rent::get()?.minimum_balance(account_size);
assert!(