From 465643c2c9a3557c6655793f37a4fc67d1a62913 Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Thu, 23 May 2024 03:41:30 +0000 Subject: [PATCH] last hash --- src/processor/claim.rs | 3 --- src/processor/mine.rs | 1 + src/processor/register.rs | 2 +- src/state/proof.rs | 4 ++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/processor/claim.rs b/src/processor/claim.rs index f4f080f..0115276 100644 --- a/src/processor/claim.rs +++ b/src/processor/claim.rs @@ -54,9 +54,6 @@ pub fn process_claim<'a, 'info>( .checked_sub(amount) .ok_or(OreError::ClaimTooLarge)?; - // Update timestamp - proof.last_claim_at = clock.unix_timestamp; - // Distribute tokens from treasury to beneficiary solana_program::program::invoke_signed( &spl_token::instruction::transfer( diff --git a/src/processor/mine.rs b/src/processor/mine.rs index 87ce4c0..1c45280 100644 --- a/src/processor/mine.rs +++ b/src/processor/mine.rs @@ -169,6 +169,7 @@ pub fn process_mine<'a, 'info>( proof.balance = proof.balance.saturating_add(reward_actual); // Hash recent slot hash into the next challenge to prevent pre-mining attacks + proof.last_hash = hash.h; proof.challenge = hashv(&[ hash.h.as_slice(), &slot_hashes_sysvar.data.borrow()[0..size_of::()], diff --git a/src/processor/register.rs b/src/processor/register.rs index e556f84..74fa0d7 100644 --- a/src/processor/register.rs +++ b/src/processor/register.rs @@ -72,7 +72,7 @@ pub fn process_register<'a, 'info>( &slot_hashes_info.data.borrow()[0..size_of::()], ]) .0; - proof.last_claim_at = clock.unix_timestamp; + proof.last_hash = [0; 32]; proof.last_hash_at = clock.unix_timestamp; proof.last_stake_at = clock.unix_timestamp; proof.total_hashes = 0; diff --git a/src/state/proof.rs b/src/state/proof.rs index 78c819c..5cc2f9c 100644 --- a/src/state/proof.rs +++ b/src/state/proof.rs @@ -21,8 +21,8 @@ pub struct Proof { /// The current mining challenge. pub challenge: [u8; 32], - /// The last time this account claimed rewards. - pub last_claim_at: i64, + /// The last hash the miner provided. + pub last_hash: [u8; 32], /// The last time this account provided a hash. pub last_hash_at: i64,