@@ -2503,6 +2503,9 @@ int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Para
25032503 if (IsCommunityFundAmountV2Enabled (pindexPrev,Params ().GetConsensus ()))
25042504 nVersion |= nCFundAmountV2Mask;
25052505
2506+ if (IsStaticRewardEnabled (pindexPrev,Params ().GetConsensus ()))
2507+ nVersion |= nStaticRewardVersionMask;
2508+
25062509 return nVersion;
25072510}
25082511
@@ -2917,6 +2920,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
29172920
29182921 }
29192922
2923+ if (IsStaticRewardEnabled (pindex->pprev , Params ().GetConsensus ()) && nStakeReward != Params ().GetConsensus ().nStaticReward )
2924+ return state.DoS (100 , error (" ConnectBlock(): block has incorrect block reward (actual=%d vs consensus=%d)" ,
2925+ nStakeReward, Params ().GetConsensus ().nStaticReward ),
2926+ REJECT_INVALID, " bad-static-stake-amount" );
2927+
29202928 }
29212929
29222930 std::vector<CScriptCheck> vChecks;
@@ -4648,6 +4656,18 @@ bool IsCommunityFundLocked(const CBlockIndex* pindexPrev, const Consensus::Param
46484656 return (VersionBitsState (pindexPrev, params, Consensus::DEPLOYMENT_COMMUNITYFUND, versionbitscache) == THRESHOLD_LOCKED_IN);
46494657}
46504658
4659+ bool IsStaticRewardLocked (const CBlockIndex* pindexPrev, const Consensus::Params& params)
4660+ {
4661+ LOCK (cs_main);
4662+ return (VersionBitsState (pindexPrev, params, Consensus::DEPLOYMENT_STATIC_REWARD, versionbitscache) == THRESHOLD_LOCKED_IN);
4663+ }
4664+
4665+ bool IsStaticRewardEnabled (const CBlockIndex* pindexPrev, const Consensus::Params& params)
4666+ {
4667+ LOCK (cs_main);
4668+ return (VersionBitsState (pindexPrev, params, Consensus::DEPLOYMENT_STATIC_REWARD, versionbitscache) == THRESHOLD_ACTIVE);
4669+ }
4670+
46514671// Compute at which vout of the block's coinbase transaction the witness
46524672// commitment occurs, or -1 if not found.
46534673static int GetWitnessCommitmentIndex (const CBlock& block)
@@ -4750,6 +4770,10 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
47504770 return state.Invalid (false , REJECT_OBSOLETE, strprintf (" bad-version(0x%08x)" , block.nVersion ),
47514771 " rejected no nsync block" );
47524772
4773+ if ((block.nVersion & nStaticRewardVersionMask) != nStaticRewardVersionMask && IsStaticRewardEnabled (pindexPrev,Params ().GetConsensus ()))
4774+ return state.Invalid (false , REJECT_OBSOLETE, strprintf (" bad-version(0x%08x)" , block.nVersion ),
4775+ " rejected no static reward block" );
4776+
47534777 return true ;
47544778}
47554779
@@ -8638,23 +8662,29 @@ bool CheckKernel(CBlockIndex* pindexPrev, unsigned int nBits, int64_t nTime, con
86388662// staker's coin stake reward based on coin age spent (coin-days)
86398663int64_t GetProofOfStakeReward (int nHeight, int64_t nCoinAge, int64_t nFees, CBlockIndex* pindexPrev)
86408664{
8641- int64_t nRewardCoinYear;
8642- nRewardCoinYear = MAX_MINT_PROOF_OF_STAKE;
8643-
8644- if (nHeight-1 < 7 * Params ().GetConsensus ().nDailyBlockCount )
8645- nRewardCoinYear = 1 * MAX_MINT_PROOF_OF_STAKE;
8646- else if (nHeight-1 < (365 * Params ().GetConsensus ().nDailyBlockCount ))
8647- nRewardCoinYear = 0.5 * MAX_MINT_PROOF_OF_STAKE;
8648- else if (nHeight-1 < (730 * Params ().GetConsensus ().nDailyBlockCount ))
8649- nRewardCoinYear = 0.5 * MAX_MINT_PROOF_OF_STAKE;
8650- else if (IsCommunityFundAccumulationEnabled (pindexPrev, Params ().GetConsensus (), false ))
8651- nRewardCoinYear = 0.4 * MAX_MINT_PROOF_OF_STAKE;
8652- else
8653- nRewardCoinYear = 0.5 * MAX_MINT_PROOF_OF_STAKE;
8654-
8655- int64_t nSubsidy = nCoinAge * nRewardCoinYear / 365 ;
8656-
8657- return nSubsidy + nFees;
8665+ int64_t nSubsidy;
8666+
8667+ if (IsStaticRewardEnabled (pindexPrev, Params ().GetConsensus ())){
8668+ nSubsidy = Params ().GetConsensus ().nStaticReward ;
8669+ } else {
8670+ int64_t nRewardCoinYear;
8671+ nRewardCoinYear = MAX_MINT_PROOF_OF_STAKE;
8672+
8673+ if (nHeight-1 < 7 * Params ().GetConsensus ().nDailyBlockCount )
8674+ nRewardCoinYear = 1 * MAX_MINT_PROOF_OF_STAKE;
8675+ else if (nHeight-1 < (365 * Params ().GetConsensus ().nDailyBlockCount ))
8676+ nRewardCoinYear = 0.5 * MAX_MINT_PROOF_OF_STAKE;
8677+ else if (nHeight-1 < (730 * Params ().GetConsensus ().nDailyBlockCount ))
8678+ nRewardCoinYear = 0.5 * MAX_MINT_PROOF_OF_STAKE;
8679+ else if (IsCommunityFundAccumulationEnabled (pindexPrev, Params ().GetConsensus (), false ))
8680+ nRewardCoinYear = 0.4 * MAX_MINT_PROOF_OF_STAKE;
8681+ else
8682+ nRewardCoinYear = 0.5 * MAX_MINT_PROOF_OF_STAKE;
8683+
8684+ nSubsidy = nCoinAge * nRewardCoinYear / 365 ;
8685+ }
8686+
8687+ return nSubsidy + nFees;
86588688}
86598689
86608690unsigned int ComputeMaxBits (arith_uint256 bnTargetLimit, unsigned int nBase, int64_t nTime)
0 commit comments