Skip to content

Commit 1e5a33d

Browse files
committed
[Refactor] Consensus: wrapped serials params (nSupplyBeforeFakeSerial)
1 parent 70c4ae5 commit 1e5a33d

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/chainparams.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ class CMainParams : public CChainParams
192192
consensus.height_start_ZC_SerialsV2 = 1153160;
193193
consensus.height_ZC_RecalcAccumulators = 908000;
194194

195+
// Zerocoin-related params
196+
consensus.ZC_WrappedSerialsSupply = 4131563 * COIN; // zerocoin supply at height_last_ZC_WrappedSerials
197+
195198
/**
196199
* The message start string is designed to be unlikely to occur in normal data.
197200
* The characters are rarely used upper ASCII, not valid as UTF-8, and produce
@@ -225,9 +228,6 @@ class CMainParams : public CChainParams
225228
nEnforceNewSporkKey = 1566860400; //!> Sporks signed after Monday, August 26, 2019 11:00:00 PM GMT must use the new spork key
226229
nRejectOldSporkKey = 1569538800; //!> Fully reject old spork key after Thursday, September 26, 2019 11:00:00 PM GMT
227230

228-
// Fake Serial Attack
229-
nSupplyBeforeFakeSerial = 4131563 * COIN; // zerocoin supply at height_last_ZC_WrappedSerials
230-
231231
// Note that of those with the service bits flag, most only support a subset of possible options
232232
vSeeds.push_back(CDNSSeedData("fuzzbawls.pw", "pivx.seed.fuzzbawls.pw")); // Primary DNS Seeder from Fuzzbawls
233233
vSeeds.push_back(CDNSSeedData("fuzzbawls.pw", "pivx.seed2.fuzzbawls.pw")); // Secondary DNS Seeder from Fuzzbawls
@@ -329,6 +329,9 @@ class CTestNetParams : public CMainParams
329329
consensus.height_start_ZC_SerialsV2 = 444020;
330330
consensus.height_ZC_RecalcAccumulators = 999999999;
331331

332+
// Zerocoin-related params
333+
consensus.ZC_WrappedSerialsSupply = 0; // WrappedSerials only on main net
334+
332335
/**
333336
* The message start string is designed to be unlikely to occur in normal data.
334337
* The characters are rarely used upper ASCII, not valid as UTF-8, and produce
@@ -359,9 +362,6 @@ class CTestNetParams : public CMainParams
359362
nEnforceNewSporkKey = 1566860400; //!> Sporks signed after Monday, August 26, 2019 11:00:00 PM GMT must use the new spork key
360363
nRejectOldSporkKey = 1569538800; //!> Reject old spork key after Thursday, September 26, 2019 11:00:00 PM GMT
361364

362-
// Fake Serial Attack
363-
nSupplyBeforeFakeSerial = 0;
364-
365365
vFixedSeeds.clear();
366366
vSeeds.clear();
367367
vSeeds.push_back(CDNSSeedData("fuzzbawls.pw", "pivx-testnet.seed.fuzzbawls.pw"));
@@ -447,6 +447,9 @@ class CRegTestParams : public CTestNetParams
447447
consensus.height_start_ZC_SerialsV2 = 300;
448448
consensus.height_ZC_RecalcAccumulators = 999999999;
449449

450+
// Zerocoin-related params
451+
consensus.ZC_WrappedSerialsSupply = 0; // WrappedSerials only on main net
452+
450453

451454
/**
452455
* The message start string is designed to be unlikely to occur in normal data.

src/chainparams.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ class CChainParams
107107
bool IsRegTestNet() const { return NetworkID() == CBaseChainParams::REGTEST; }
108108

109109
/** Zerocoin **/
110-
std::string Zerocoin_Modulus() const { return zerocoinModulus; }
111110
libzerocoin::ZerocoinParams* Zerocoin_Params(bool useModulusV1) const;
112111
int Zerocoin_MaxSpendsPerTransaction() const { return nMaxZerocoinSpendsPerTransaction; }
113112
int Zerocoin_MaxPublicSpendsPerTransaction() const { return nMaxZerocoinPublicSpendsPerTransaction; }
@@ -123,9 +122,6 @@ class CChainParams
123122
int PivxBadBlocknBits() const { return nPivxBadBlocknBits; }
124123
int Zerocoin_StartTime() const { return nZerocoinStartTime; }
125124

126-
// fake serial attack
127-
CAmount GetSupplyBeforeFakeSerial() const { return nSupplyBeforeFakeSerial; }
128-
129125
CAmount InvalidAmountFiltered() const { return nInvalidAmountFiltered; };
130126

131127

@@ -183,9 +179,6 @@ class CChainParams
183179
int64_t nProposalEstablishmentTime;
184180

185181
CAmount nMinColdStakingAmount;
186-
187-
// fake serial attack
188-
CAmount nSupplyBeforeFakeSerial = 0;
189182
};
190183

191184
/**

src/consensus/params.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ struct Params {
5050
int height_start_ZC_SerialsV2;
5151
int height_ZC_RecalcAccumulators;
5252

53+
// Zerocoin-related params
54+
CAmount ZC_WrappedSerialsSupply;
55+
5356
int64_t TargetTimespan(const bool fV2 = true) const { return fV2 ? nTargetTimespanV2 : nTargetTimespan; }
5457
uint256 ProofOfStakeLimit(const bool fV2) const { return fV2 ? posLimitV2 : posLimitV1; }
5558
bool MoneyRange(const CAmount& nValue) const { return (nValue >= 0 && nValue <= nMaxMoneyOut); }

src/consensus/zerocoin_verify.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,9 @@ bool UpdateZPIVSupply(const CBlock& block, CBlockIndex* pindex, bool fJustCheck)
352352

353353
// Update Wrapped Serials amount
354354
// A one-time event where only the zPIV supply was off (due to serial duplication off-chain on main net)
355-
if (Params().NetworkID() == CBaseChainParams::MAIN && pindex->nHeight == Params().GetConsensus().height_last_ZC_WrappedSerials + 1
356-
&& pindex->GetZerocoinSupply() < Params().GetSupplyBeforeFakeSerial() + GetWrapppedSerialInflationAmount()) {
355+
const Consensus::Params& consensus = Params().GetConsensus();
356+
if (Params().NetworkID() == CBaseChainParams::MAIN && pindex->nHeight == consensus.height_last_ZC_WrappedSerials + 1
357+
&& pindex->GetZerocoinSupply() < consensus.ZC_WrappedSerialsSupply + GetWrapppedSerialInflationAmount()) {
357358
for (auto denom : libzerocoin::zerocoinDenomList) {
358359
pindex->mapZerocoinSupply.at(denom) += GetWrapppedSerialInflation(denom);
359360
}

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ bool AppInit2()
15271527

15281528
// Supply needs to be exactly GetSupplyBeforeFakeSerial + GetWrapppedSerialInflationAmount
15291529
CBlockIndex* pblockindex = chainActive[consensus.height_last_ZC_WrappedSerials + 1];
1530-
CAmount zpivSupplyCheckpoint = Params().GetSupplyBeforeFakeSerial() + GetWrapppedSerialInflationAmount();
1530+
CAmount zpivSupplyCheckpoint = consensus.ZC_WrappedSerialsSupply + GetWrapppedSerialInflationAmount();
15311531

15321532
if (pblockindex->GetZerocoinSupply() < zpivSupplyCheckpoint) {
15331533
// Trigger reindex due wrapping serials

0 commit comments

Comments
 (0)