From 6d1bece0eb8f5eaa62253089e75c882cc9beb6c0 Mon Sep 17 00:00:00 2001 From: Blas Rodriguez Irizar Date: Tue, 16 Jul 2024 23:14:24 +0200 Subject: [PATCH 1/2] move spam rejection earlier to reduce cu usage --- program/src/mine.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/program/src/mine.rs b/program/src/mine.rs index cf016e0..cce2ff1 100644 --- a/program/src/mine.rs +++ b/program/src/mine.rs @@ -86,6 +86,14 @@ pub fn process_mine<'a, 'info>( return Err(OreError::HashInvalid.into()); } + // Reject spam transactions. + let t: i64 = clock.unix_timestamp; + let t_target = proof.last_hash_at.saturating_add(ONE_MINUTE); + let t_spam = t_target.saturating_sub(TOLERANCE); + if t.lt(&t_spam) { + return Err(OreError::Spam.into()); + } + // Validate hash satisfies the minimnum difficulty. let hash = solution.to_hash(); let difficulty = hash.difficulty(); @@ -102,7 +110,6 @@ pub fn process_mine<'a, 'info>( // If user has greater than or equal to the max stake on the network, they receive 2x multiplier. // Any stake less than this will receives between 1x and 2x multipler. The multipler is only active // if the miner's last stake deposit was more than one minute ago. - let t = clock.unix_timestamp; if config.max_stake.gt(&0) && proof.last_stake_at.saturating_add(ONE_MINUTE).le(&t) { let staking_reward = (reward as u128) .checked_mul(proof.balance.min(config.max_stake) as u128) @@ -112,13 +119,6 @@ pub fn process_mine<'a, 'info>( reward = reward.checked_add(staking_reward).unwrap(); } - // Reject spam transactions. - let t_target = proof.last_hash_at.saturating_add(ONE_MINUTE); - let t_spam = t_target.saturating_sub(TOLERANCE); - if t.lt(&t_spam) { - return Err(OreError::Spam.into()); - } - // Apply liveness penalty. let t_liveness = t_target.saturating_add(TOLERANCE); if t.gt(&t_liveness) { From 2ec5af2e8152bda2f49b373bfa3177e340d06056 Mon Sep 17 00:00:00 2001 From: Hardhat Chad <155858888+HardhatChad@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:40:13 -0500 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 816aaeb..da63398 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ORE -**ORE is a fair-launch, proof-of-work, digital currency everyone can mine.** +**ORE is a fair launch, proof of work, digital currency everyone can mine.** ## API