From ddf33f624df11b7211e203d67dbb63cbda71144f Mon Sep 17 00:00:00 2001 From: div72 Date: Mon, 8 Apr 2024 20:11:39 +0300 Subject: [PATCH] staking: add a missing check --- src/gridcoin/staking/kernel.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gridcoin/staking/kernel.cpp b/src/gridcoin/staking/kernel.cpp index 7f1952140d..ccb154862e 100644 --- a/src/gridcoin/staking/kernel.cpp +++ b/src/gridcoin/staking/kernel.cpp @@ -603,21 +603,21 @@ bool GRC::CheckProofOfStakeV8( CTransaction txPrev; if (!ReadStakedInput(txdb, prevout.hash, header, txPrev, pindexPrev)) - return tx.DoS(1, error("%s: read staked input failed", __func__)); + return tx.DoS(10, error("%s: read staked input failed", __func__)); if (!VerifySignature(txPrev, tx, 0, 0)) return tx.DoS(100, error("%s: VerifySignature failed on coinstake %s", __func__, tx.GetHash().ToString())); // Check times if (tx.nTime < txPrev.nTime) - return error("%s: nTime violation", __func__); + return tx.DoS(100, error("%s: nTime violation", __func__)); if (header.nTime + nStakeMinAge > tx.nTime) - return error("%s: min age violation", __func__); + return tx.DoS(100, error("%s: min age violation", __func__)); if (Block.nVersion >= 12) { if (tx.nTime != MaskStakeTime(tx.nTime)) { - return error("%s: mask violation", __func__); + return tx.DoS(100, error("%s: mask violation", __func__)); } } @@ -649,5 +649,9 @@ bool GRC::CheckProofOfStakeV8( ); // Now check if proof-of-stake hash meets target protocol - return bnHashProof <= bnTarget; + if (bnHashProof > bnTarget) { + return tx.DoS(100, error("%s: invalid proof (proof: %s, target: %s)", __func__, bnHashProof.GetHex(), bnTarget.GetHex())); + } + + return true; }