@@ -2935,8 +2935,8 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
2935
2935
(block.nVersion < 5 && consensus.NetworkUpgradeActive (nHeight, Consensus::UPGRADE_BIP65)) ||
2936
2936
(block.nVersion < 6 && consensus.NetworkUpgradeActive (nHeight, Consensus::UPGRADE_V3_4)) ||
2937
2937
(block.nVersion < 7 && consensus.NetworkUpgradeActive (nHeight, Consensus::UPGRADE_V4_0)) ||
2938
- (block.nVersion < 8 && consensus.NetworkUpgradeActive (nHeight, Consensus::UPGRADE_V5_0)))
2939
- {
2938
+ (block.nVersion < 8 && consensus.NetworkUpgradeActive (nHeight, Consensus::UPGRADE_V5_0)) ||
2939
+ (block. nVersion < 12 && consensus. NetworkUpgradeActive (nHeight, Consensus::UPGRADE_SHIELD_STAKING))) {
2940
2940
std::string stringErr = strprintf (" rejected block version %d at height %d" , block.nVersion , nHeight);
2941
2941
return state.Invalid (false , REJECT_OBSOLETE, " bad-version" , stringErr);
2942
2942
}
@@ -3147,7 +3147,8 @@ static bool CheckInBlockDoubleSpends(const CBlock& block, int nHeight, CValidati
3147
3147
if (inblock_txes.find (it->hash ) != inblock_txes.end ()) {
3148
3148
// the input spent was created as output of another in-block tx
3149
3149
// this is not allowed for the coinstake input
3150
- if (*it == block.vtx [1 ]->vin [0 ].prevout ) {
3150
+ // this check is not needed in shield staking
3151
+ if (block.IsProofOfStake () && *it == block.vtx [1 ]->vin [0 ].prevout ) {
3151
3152
return state.DoS (100 , error (" %s: coinstake input created in the same block" , __func__));
3152
3153
}
3153
3154
it = spent_outpoints.erase (it);
@@ -3282,12 +3283,17 @@ static bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockInde
3282
3283
return state.DoS (100 , false , REJECT_INVALID);
3283
3284
3284
3285
bool isPoS = block.IsProofOfStake ();
3286
+ bool isShieldPos = block.IsProofOfShieldStake ();
3285
3287
if (isPoS) {
3286
3288
std::string strError;
3287
3289
if (!CheckProofOfStake (block, strError, pindexPrev))
3288
3290
return state.DoS (100 , error (" %s: proof of stake check failed (%s)" , __func__, strError));
3289
3291
}
3290
3292
3293
+ if (isShieldPos) {
3294
+ // TODO: add zkproof check here
3295
+ }
3296
+
3291
3297
if (!AcceptBlockHeader (block, state, &pindex, pindexPrev))
3292
3298
return false ;
3293
3299
@@ -3308,7 +3314,7 @@ static bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockInde
3308
3314
3309
3315
int nHeight = pindex->nHeight ;
3310
3316
3311
- if (isPoS) {
3317
+ if (isPoS || isShieldPos ) {
3312
3318
// Blocks arrives in order, so if prev block is not the tip then we are on a fork.
3313
3319
// Extra info: duplicated blocks are skipping this checks, so we don't have to worry about those here.
3314
3320
bool isBlockFromFork = pindexPrev != nullptr && chainActive.Tip () != pindexPrev;
@@ -3388,7 +3394,6 @@ static bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockInde
3388
3394
coinstake.GetHash ().GetHex ()), REJECT_INVALID, " bad-txns-invalid-zpiv" );
3389
3395
}
3390
3396
}
3391
-
3392
3397
}
3393
3398
3394
3399
// Write block to history file
0 commit comments