Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,7 @@ qa/pull-tester/test.*/*
.project
/doc/doxygen/
/nbproject/

.idea
CMakeLists.txt
cmake-build-debug
3 changes: 2 additions & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class CMainParams : public CChainParams
nLastPOWBlock = 259200;
nModifierUpdateBlock = 615800;
nZerocoinStartHeight = 863787;
nZerocoinStartTime = 1508214600; // October 17, 2017 4:30:00 AM
nBlockEnforceSerialRange = 895400; //Enforce serial range starting this block
nBlockRecalculateAccumulators = 908000; //Trigger a recalculation of accumulators
nBlockFirstFraudulent = 891737; //First block that bad serials emerged
Expand Down Expand Up @@ -289,7 +290,7 @@ class CTestNetParams : public CMainParams
strSporkKey = "04348C2F50F90267E64FACC65BFDC9D0EB147D090872FB97ABAE92E9A36E6CA60983E28E741F8E7277B11A7479B626AC115BA31463AC48178A5075C5A9319D4A38";
strObfuscationPoolDummyAddress = "y57cqfGRkekRyDRNeJiLtYVEbvhXrNbmox";
nStartMasternodePayments = 1420837558; //Fri, 09 Jan 2015 21:05:58 GMT
nBudget_Fee_Confirmations = 3; // Number of confirmations for the finalization fee. We have to make this very short
nBudget_Fee_Confirmations = 3; // Number of confirmations for the finalization fee. We have to make this very short
// here because we only have a 8 block finalization window on testnet
}
const Checkpoints::CCheckpointData& Checkpoints() const
Expand Down
3 changes: 3 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class CChainParams
int Zerocoin_Block_RecalculateAccumulators() const { return nBlockRecalculateAccumulators; }
int Zerocoin_Block_FirstFraudulent() const { return nBlockFirstFraudulent; }
int Zerocoin_Block_LastGoodCheckpoint() const { return nBlockLastGoodCheckpoint; }
int Zerocoin_StartTime() const { return nZerocoinStartTime; }

protected:
CChainParams() {}
Expand Down Expand Up @@ -166,6 +167,8 @@ class CChainParams
int nZerocoinHeaderVersion;
int64_t nBudget_Fee_Confirmations;
int nZerocoinStartHeight;
int nZerocoinStartTime;

int nBlockEnforceSerialRange;
int nBlockRecalculateAccumulators;
int nBlockFirstFraudulent;
Expand Down
51 changes: 22 additions & 29 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,9 +1315,6 @@ std::list<libzerocoin::CoinDenomination> ZerocoinSpendListFromBlock(const CBlock

bool CheckZerocoinMint(const uint256& txHash, const CTxOut& txout, CValidationState& state, bool fCheckOnly)
{
if(!fCheckOnly && GetAdjustedTime() < GetSporkValue(SPORK_17_ENABLE_ZEROCOIN))
return state.DoS(100, error("CheckZerocoinMint(): Zerocoin transactions are not allowed yet"));

PublicCoin pubCoin(Params().Zerocoin_Params());
if(!TxOutToPublicCoin(txout, pubCoin, state))
return state.DoS(100, error("CheckZerocoinMint(): TxOutToPublicCoin() failed"));
Expand Down Expand Up @@ -1355,9 +1352,6 @@ bool IsZerocoinSpendUnknown(CoinSpend coinSpend, uint256 hashTx, CValidationStat

bool CheckZerocoinSpend(const CTransaction tx, bool fVerifySignature, CValidationState& state)
{
if(GetAdjustedTime() < GetSporkValue(SPORK_17_ENABLE_ZEROCOIN))
return state.DoS(100, error("CheckZerocoinSpend(): Zerocoin transactions are not allowed yet"));

//max needed non-mint outputs should be 2 - one for redemption address and a possible 2nd for change
if (tx.vout.size() > 2) {
int outs = 0;
Expand Down Expand Up @@ -1457,9 +1451,7 @@ bool CheckTransaction(const CTransaction& tx, bool fZerocoinActive, bool fReject
REJECT_INVALID, "bad-txns-vout-empty");

// Size limits
unsigned int nMaxSize = MAX_BLOCK_SIZE_LEGACY;
if(GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN))
nMaxSize = MAX_ZEROCOIN_TX_SIZE;
unsigned int nMaxSize = MAX_ZEROCOIN_TX_SIZE;

if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > nMaxSize)
return state.DoS(100, error("CheckTransaction() : size limits failed"),
Expand Down Expand Up @@ -1604,11 +1596,11 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa
if (pfMissingInputs)
*pfMissingInputs = false;

//Temporarily disable zerocoin
if (tx.ContainsZerocoins())
return state.DoS(10, error("AcceptToMemoryPool : Zerocoin transactions temporarily disabled"));
//Temporarily disable zerocoin for maintenance
if (GetAdjustedTime() > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE) && tx.ContainsZerocoins())
return state.DoS(10, error("AcceptToMemoryPool : Zerocoin transactions are temporarily disabled for maintenance"), REJECT_INVALID, "bad-tx");

if (!CheckTransaction(tx, GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN), true, state))
if (!CheckTransaction(tx, chainActive.Height() >= Params().Zerocoin_StartHeight(), true, state))
return state.DoS(100, error("AcceptToMemoryPool: : CheckTransaction failed"), REJECT_INVALID, "bad-tx");

// Coinbase is only valid in a block, not as a loose transaction
Expand Down Expand Up @@ -1739,7 +1731,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa
// merely non-standard transaction.
if (!tx.IsZerocoinSpend()) {
unsigned int nSigOps = GetLegacySigOpCount(tx);
unsigned int nMaxSigOps = GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_TX_SIGOPS_CURRENT : MAX_TX_SIGOPS_LEGACY;
unsigned int nMaxSigOps = MAX_TX_SIGOPS_CURRENT;
nSigOps += GetP2SHSigOpCount(tx, view);
if(nSigOps > nMaxSigOps)
return state.DoS(0,
Expand Down Expand Up @@ -1839,7 +1831,8 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact
if (pfMissingInputs)
*pfMissingInputs = false;

if (!CheckTransaction(tx, GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN), true, state))

if (!CheckTransaction(tx, chainActive.Height() >= Params().Zerocoin_StartHeight(), true, state))
return error("AcceptableInputs: : CheckTransaction failed");

// Coinbase is only valid in a block, not as a loose transaction
Expand Down Expand Up @@ -1941,7 +1934,7 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact
// MAX_BLOCK_SIGOPS; we still consider this an invalid rather than
// merely non-standard transaction.
unsigned int nSigOps = GetLegacySigOpCount(tx);
unsigned int nMaxSigOps = GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_TX_SIGOPS_CURRENT : MAX_TX_SIGOPS_LEGACY;
unsigned int nMaxSigOps = MAX_TX_SIGOPS_CURRENT;
nSigOps += GetP2SHSigOpCount(tx, view);
if (nSigOps > nMaxSigOps)
return state.DoS(0,
Expand Down Expand Up @@ -3288,7 +3281,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
blockundo.vtxundo.reserve(block.vtx.size() - 1);
CAmount nValueOut = 0;
CAmount nValueIn = 0;
unsigned int nMaxBlockSigOps = block.nTime > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_BLOCK_SIGOPS_CURRENT : MAX_BLOCK_SIGOPS_LEGACY;
unsigned int nMaxBlockSigOps = MAX_BLOCK_SIGOPS_CURRENT;
for (unsigned int i = 0; i < block.vtx.size(); i++) {
const CTransaction& tx = block.vtx[i];

Expand All @@ -3298,10 +3291,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
return state.DoS(100, error("ConnectBlock() : too many sigops"),
REJECT_INVALID, "bad-blk-sigops");

//Temporarily shut off zerocoin transactions
if (pindex->nHeight >= Params().Zerocoin_Block_EnforceSerialRange() && tx.ContainsZerocoins())
return state.DoS(100, error("ConnectBlock() : zerocoin transactions are disabled"));

//Temporarily disable zerocoin transactions for maintenance
if (block.nTime > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE) && !IsInitialBlockDownload() && tx.ContainsZerocoins()) {
return state.DoS(100, error("ConnectBlock() : zerocoin transactions are currently in maintenance mode"));
}
if (tx.IsZerocoinSpend()) {
int nHeightTx = 0;
if (IsTransactionInChain(tx.GetHash(), nHeightTx)) {
Expand Down Expand Up @@ -4320,14 +4313,14 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool f
return state.DoS(50, error("CheckBlockHeader() : proof of work failed"),
REJECT_INVALID, "high-hash");

// Version 4 header must be used when SPORK_17_ENABLE_ZEROCOIN is activated. And never before.
if (block.GetBlockTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN)) {
if (block.nVersion < Params().Zerocoin_HeaderVersion())
return state.DoS(50, error("CheckBlockHeader() : block version must be above 4 after SPORK_17"),
// Version 4 header must be used after Params().Zerocoin_StartHeight(). And never before.
if (block.GetBlockTime() > Params().Zerocoin_StartTime()) {
if(block.nVersion < Params().Zerocoin_HeaderVersion())
return state.DoS(50, error("CheckBlockHeader() : block version must be above 4 after ZerocoinStartHeight"),
REJECT_INVALID, "block-version");
} else {
if (block.nVersion >= Params().Zerocoin_HeaderVersion())
return state.DoS(50, error("CheckBlockHeader() : block version must be below 4 before SPORK_17"),
return state.DoS(50, error("CheckBlockHeader() : block version must be below 4 before ZerocoinStartHeight"),
REJECT_INVALID, "block-version");
}

Expand Down Expand Up @@ -4371,7 +4364,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
// because we receive the wrong transactions for it.

// Size limits
unsigned int nMaxBlockSize = GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_BLOCK_SIZE_CURRENT : MAX_BLOCK_SIZE_LEGACY;
unsigned int nMaxBlockSize = MAX_BLOCK_SIZE_CURRENT;
if (block.vtx.empty() || block.vtx.size() > nMaxBlockSize || ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION) > nMaxBlockSize)
return state.DoS(100, error("CheckBlock() : size limits failed"),
REJECT_INVALID, "bad-blk-length");
Expand Down Expand Up @@ -4450,7 +4443,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
}

// Check transactions
bool fZerocoinActive = block.nTime > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN);
bool fZerocoinActive = block.GetBlockTime() > Params().Zerocoin_StartTime();
vector<CBigNum> vBlockSerials;
for (const CTransaction& tx : block.vtx) {
if (!CheckTransaction(tx, fZerocoinActive, chainActive.Height() + 1 >= Params().Zerocoin_Block_EnforceSerialRange(), state))
Expand Down Expand Up @@ -5927,7 +5920,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// available. If not, ask the first peer connected for them.
if (!pSporkDB->SporkExists(SPORK_14_NEW_PROTOCOL_ENFORCEMENT) &&
!pSporkDB->SporkExists(SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) &&
!pSporkDB->SporkExists(SPORK_17_ENABLE_ZEROCOIN)) {
!pSporkDB->SporkExists(SPORK_16_ZEROCOIN_MAINTENANCE_MODE)) {
LogPrintf("Required sporks not found, asking peer to send them\n");
pfrom->PushMessage("getsporks");
}
Expand Down
12 changes: 8 additions & 4 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
pblock->nVersion = GetArg("-blockversion", pblock->nVersion);

// Make sure to create the correct block version after zerocoin is enabled
bool fZerocoinActive = GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN);
bool fZerocoinActive = GetAdjustedTime() >= Params().Zerocoin_StartTime();
if (fZerocoinActive)
pblock->nVersion = 4;
else
Expand Down Expand Up @@ -154,7 +154,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
// Largest block you're willing to create:
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE);
// Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity:
unsigned int nBlockMaxSizeNetwork = pblock->nTime > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_BLOCK_SIZE_CURRENT : MAX_BLOCK_SIZE_LEGACY;
unsigned int nBlockMaxSizeNetwork = MAX_BLOCK_SIZE_CURRENT;
nBlockMaxSize = std::max((unsigned int)1000, std::min((nBlockMaxSizeNetwork - 1000), nBlockMaxSize));

// How much of the block should be dedicated to high-priority transactions,
Expand Down Expand Up @@ -188,8 +188,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
for (map<uint256, CTxMemPoolEntry>::iterator mi = mempool.mapTx.begin();
mi != mempool.mapTx.end(); ++mi) {
const CTransaction& tx = mi->second.GetTx();
if (tx.IsCoinBase() || tx.IsCoinStake() || !IsFinalTx(tx, nHeight) || tx.ContainsZerocoins())
if (tx.IsCoinBase() || tx.IsCoinStake() || !IsFinalTx(tx, nHeight)){
continue;
}
if(GetAdjustedTime() > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE) && tx.ContainsZerocoins()){
continue;
}

COrphan* porphan = NULL;
double dPriority = 0;
Expand Down Expand Up @@ -289,7 +293,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
continue;

// Legacy limits on sigOps:
unsigned int nMaxBlockSigOps = GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_BLOCK_SIGOPS_CURRENT : MAX_BLOCK_SIGOPS_LEGACY;
unsigned int nMaxBlockSigOps = MAX_BLOCK_SIGOPS_CURRENT;
unsigned int nTxSigOps = GetLegacySigOpCount(tx);
if (nBlockSigOps + nTxSigOps >= nMaxBlockSigOps)
continue;
Expand Down
Loading