Skip to content

Commit c0ea05f

Browse files
committed
[Squash] More validation
1 parent 432979f commit c0ea05f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/validation.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -2935,8 +2935,8 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
29352935
(block.nVersion < 5 && consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_BIP65)) ||
29362936
(block.nVersion < 6 && consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_V3_4)) ||
29372937
(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))) {
29402940
std::string stringErr = strprintf("rejected block version %d at height %d", block.nVersion, nHeight);
29412941
return state.Invalid(false, REJECT_OBSOLETE, "bad-version", stringErr);
29422942
}
@@ -3147,7 +3147,8 @@ static bool CheckInBlockDoubleSpends(const CBlock& block, int nHeight, CValidati
31473147
if (inblock_txes.find(it->hash) != inblock_txes.end()) {
31483148
// the input spent was created as output of another in-block tx
31493149
// 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) {
31513152
return state.DoS(100, error("%s: coinstake input created in the same block", __func__));
31523153
}
31533154
it = spent_outpoints.erase(it);
@@ -3282,12 +3283,17 @@ static bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockInde
32823283
return state.DoS(100, false, REJECT_INVALID);
32833284

32843285
bool isPoS = block.IsProofOfStake();
3286+
bool isShieldPos = block.IsProofOfShieldStake();
32853287
if (isPoS) {
32863288
std::string strError;
32873289
if (!CheckProofOfStake(block, strError, pindexPrev))
32883290
return state.DoS(100, error("%s: proof of stake check failed (%s)", __func__, strError));
32893291
}
32903292

3293+
if (isShieldPos) {
3294+
// TODO: add zkproof check here
3295+
}
3296+
32913297
if (!AcceptBlockHeader(block, state, &pindex, pindexPrev))
32923298
return false;
32933299

@@ -3308,7 +3314,7 @@ static bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockInde
33083314

33093315
int nHeight = pindex->nHeight;
33103316

3311-
if (isPoS) {
3317+
if (isPoS || isShieldPos) {
33123318
// Blocks arrives in order, so if prev block is not the tip then we are on a fork.
33133319
// Extra info: duplicated blocks are skipping this checks, so we don't have to worry about those here.
33143320
bool isBlockFromFork = pindexPrev != nullptr && chainActive.Tip() != pindexPrev;
@@ -3388,7 +3394,6 @@ static bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockInde
33883394
coinstake.GetHash().GetHex()), REJECT_INVALID, "bad-txns-invalid-zpiv");
33893395
}
33903396
}
3391-
33923397
}
33933398

33943399
// Write block to history file

0 commit comments

Comments
 (0)