Skip to content

Commit 216a317

Browse files
committed
[zPIV] testnet publicSpend enforcement height set.
[zPIV] v1 serials validation was not checked against the publicSpend height.
1 parent 0393227 commit 216a317

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/chainparams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ class CTestNetParams : public CMainParams
298298
nRejectOldSporkKey = 1522454400; //!> Reject old spork key after Saturday, March 31, 2018 12:00:00 AM GMT
299299

300300
// Public coin spend enforcement
301-
nPublicZCSpends = 1086574;
301+
nPublicZCSpends = 1818300;
302302

303303
// Fake Serial Attack
304304
nFakeSerialBlockheightEnd = -1;

src/main.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -988,10 +988,10 @@ bool isBlockBetweenFakeSerialAttackRange(int nHeight)
988988
return nHeight <= Params().Zerocoin_Block_EndFakeSerial();
989989
}
990990

991-
bool CheckPublicCoinSpendEnforced(int blockHeight, bool isPrivZerocoinSpend, bool isPublicSpend) {
991+
bool CheckPublicCoinSpendEnforced(int blockHeight, bool isPublicSpend) {
992992
if (blockHeight >= Params().Zerocoin_Block_Public_Spend_Enabled()) {
993993
// reject old coin spend
994-
if (isPrivZerocoinSpend) {
994+
if (!isPublicSpend) {
995995
return error("%s: failed to add block with older zc spend version", __func__);
996996
}
997997

@@ -1042,11 +1042,14 @@ bool ContextualCheckZerocoinSpendNoSerialCheck(const CTransaction& tx, const Coi
10421042
}
10431043
}
10441044

1045-
//Reject V1 old serials.
1046-
if (spend->getVersion() < libzerocoin::PrivateCoin::PUBKEY_VERSION) {
1047-
return error("%s : zPIV v1 serial spend not spendable\n", __func__,
1048-
spend->getCoinSerialNumber().GetHex(), tx.GetHash().GetHex());
1045+
if (pindex->nHeight >= Params().Zerocoin_Block_Public_Spend_Enabled()) {
1046+
//Reject V1 old serials.
1047+
if (spend->getVersion() < libzerocoin::PrivateCoin::PUBKEY_VERSION) {
1048+
return error("%s : zPIV v1 serial spend not spendable, serial %s, tx %s\n", __func__,
1049+
spend->getCoinSerialNumber().GetHex(), tx.GetHash().GetHex());
1050+
}
10491051
}
1052+
10501053
//Reject serial's that are not in the acceptable value range
10511054
if (!spend->HasValidSerial(Params().Zerocoin_Params(false))) {
10521055
// Up until this block our chain was not checking serials correctly..
@@ -1416,7 +1419,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa
14161419
}
14171420

14181421
// Check enforcement
1419-
if (!CheckPublicCoinSpendEnforced(chainActive.Height(), isPrivZerocoinSpend, isPublicSpend)){
1422+
if (!CheckPublicCoinSpendEnforced(chainActive.Height(), isPublicSpend)){
14201423
return state.Invalid(error("%s: AcceptToMemoryPool failed for tx %s", __func__,
14211424
tx.GetHash().GetHex()), REJECT_INVALID, "bad-txns-invalid-zpiv");
14221425
}
@@ -3250,7 +3253,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
32503253
continue;
32513254

32523255
// Check enforcement
3253-
if (!CheckPublicCoinSpendEnforced(pindex->nHeight, isPrivZerocoinSpend, isPublicSpend)){
3256+
if (!CheckPublicCoinSpendEnforced(pindex->nHeight, isPublicSpend)){
32543257
return false;
32553258
}
32563259

@@ -4811,7 +4814,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
48114814
if (isPrivZerocoinSpend || isPublicSpend) {
48124815

48134816
// Check enforcement
4814-
if (!CheckPublicCoinSpendEnforced(pindex->nHeight, isPrivZerocoinSpend, isPublicSpend)){
4817+
if (!CheckPublicCoinSpendEnforced(pindex->nHeight, isPublicSpend)){
48154818
return false;
48164819
}
48174820

src/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ bool ReindexAccumulators(list<uint256>& listMissingCheckpoints, string& strError
374374
bool isBlockBetweenFakeSerialAttackRange(int nHeight);
375375

376376
// Public coin spend
377-
bool CheckPublicCoinSpendEnforced(int blockHeight, bool isPrivZerocoinSpend, bool isPublicSpend);
377+
bool CheckPublicCoinSpendEnforced(int blockHeight, bool isPublicSpend);
378378

379379
/**
380380
* Check if transaction will be final in the next block to be created.

0 commit comments

Comments
 (0)