Skip to content

Commit

Permalink
Disable zerocoin (#377)
Browse files Browse the repository at this point in the history
* Disable zerocoin protocol
  • Loading branch information
a-bezrukov authored Apr 24, 2019
1 parent be2da8a commit 721e522
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 6 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 13)
define(_CLIENT_VERSION_REVISION, 7)
define(_CLIENT_VERSION_BUILD, 7)
define(_CLIENT_VERSION_BUILD, 8)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
define(_COPYRIGHT_YEAR, 2019)
define(_COPYRIGHT_HOLDERS,[The %s developers])
define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Zcoin Core]])
AC_INIT([Zcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/zcoinofficial/zcoin/issues],[zcoin],[https://zcoin.io/])
Expand Down
6 changes: 6 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class CMainParams : public CChainParams {
consensus.nInitialMTPDifficulty = 0x1c021e57;
consensus.nMTPRewardReduction = 2;

consensus.nDisableZerocoinStartBlock = 157000;

nMaxTipAge = 6 * 60 * 60; // ~144 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin

nPoolMaxTransactions = 3;
Expand Down Expand Up @@ -320,6 +322,8 @@ class CTestNetParams : public CChainParams {
consensus.nInitialMTPDifficulty = 0x2000ffff; // !!!! change it to the real value
consensus.nMTPRewardReduction = 2;

consensus.nDisableZerocoinStartBlock = INT_MAX;

nPoolMaxTransactions = 3;
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes
strSporkPubKey = "046f78dcf911fbd61910136f7f0f8d90578f68d0b3ac973b5040fb7afb501b5939f39b108b0569dca71488f5bbf498d92e4d1194f6f941307ffd95f75e76869f0e";
Expand Down Expand Up @@ -454,6 +458,8 @@ class CRegTestParams : public CChainParams {
consensus.nInitialMTPDifficulty = 0x2070ffff; // !!!! change it to the real value
consensus.nMTPRewardReduction = 2;

consensus.nDisableZerocoinStartBlock = INT_MAX;

pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xbf;
pchMessageStart[2] = 0xb5;
Expand Down
3 changes: 3 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ struct Params {

/** reduction coefficient for rewards after MTP kicks in */
int nMTPRewardReduction;

/** block number to disable zerocoin on consensus level */
int nDisableZerocoinStartBlock;

int64_t DifficultyAdjustmentInterval(bool fMTP = false) const { return nPowTargetTimespan / (fMTP ? nPowTargetSpacingMTP : nPowTargetSpacing); }
uint256 nMinimumChainWork;
Expand Down
10 changes: 6 additions & 4 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,11 @@ CBlockTemplate* BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)

unsigned int COUNT_SPEND_ZC_TX = 0;
unsigned int MAX_SPEND_ZC_TX_PER_BLOCK = 0;
if(!params.IsMain() || nHeight > HF_ZEROSPEND_FIX){
MAX_SPEND_ZC_TX_PER_BLOCK = 1;
}
if(!params.IsMain() ||
nHeight > SWITCH_TO_MORE_SPEND_TXS ||
Params().NetworkIDString() == CBaseChainParams::REGTEST){
MAX_SPEND_ZC_TX_PER_BLOCK = ZC_SPEND_LIMIT;
// uncomment this on sigma release
//MAX_SPEND_ZC_TX_PER_BLOCK = ZC_SPEND_LIMIT;
}

// Collect memory pool transactions into the block
Expand Down Expand Up @@ -405,6 +403,10 @@ CBlockTemplate* BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)
continue;
}

// temporarily disable zerocoin. Re-enable after sigma release
if (tx.IsZerocoinSpend() || tx.IsZerocoinMint())
continue;

if (tx.IsZerocoinSpend()) {
LogPrintf("try to include zerocoinspend tx=%s\n", tx.GetHash().ToString());
LogPrintf("COUNT_SPEND_ZC_TX =%s\n", COUNT_SPEND_ZC_TX);
Expand Down
40 changes: 40 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,11 @@ bool CWallet::EraseFromWallet(uint256 hash) {
return true;
}
bool CWallet::CreateZerocoinMintModel(string &stringError, std::vector<std::pair<int,int>> denominationPairs) {
// temporarily disable zerocoin

stringError = "Zerocoin functionality has been disabled until the pending Sigma release.";
return false;

libzerocoin::CoinDenomination denomination;
// Always use modulus v2
libzerocoin::Params *zcParams = ZCParamsV2;
Expand Down Expand Up @@ -3291,6 +3296,9 @@ bool CWallet::CreateZerocoinMintModel(string &stringError, std::vector<std::pair
}

bool CWallet::CreateZerocoinMintModel(string &stringError, string denomAmount) {
// temporarily disable zerocoin
stringError = "Zerocoin functionality has been disabled until the pending Sigma release.";
return false;

if (!fFileBacked)
return false;
Expand Down Expand Up @@ -3375,6 +3383,10 @@ bool CWallet::CreateZerocoinMintModel(string &stringError, string denomAmount) {
}

bool CWallet::CreateZerocoinSpendModel(string &stringError, string thirdPartyAddress, string denomAmount, bool forceUsed) {
// temporarily disable zerocoin
stringError = "Zerocoin functionality has been disabled until the pending Sigma release.";
return false;

if (!fFileBacked)
return false;

Expand Down Expand Up @@ -3418,6 +3430,10 @@ bool CWallet::CreateZerocoinSpendModel(string &stringError, string thirdPartyAdd
}

bool CWallet::CreateZerocoinSpendModel(CWalletTx& wtx, string &stringError, string& thirdPartyAddress, const vector<string>& denomAmounts, bool forceUsed) {
// temporarily disable zerocoin
stringError = "Zerocoin functionality has been disabled until the pending Sigma release.";
return false;

if (!fFileBacked)
return false;

Expand Down Expand Up @@ -3471,6 +3487,10 @@ bool CWallet::CreateZerocoinMintTransaction(const vector <CRecipient> &vecSend,
CReserveKey &reservekey,
CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason,
const CCoinControl *coinControl, bool sign) {
// temporarily disable zerocoin
strFailReason = "Zerocoin functionality has been disabled until the pending Sigma release.";
return false;

CAmount nValue = 0;
int nChangePosRequest = nChangePosInOut;
unsigned int nSubtractFeeFromAmount = 0;
Expand Down Expand Up @@ -3802,6 +3822,11 @@ bool CWallet::CreateZerocoinSpendTransaction(std::string &thirdPartyaddress, int
CWalletTx &wtxNew, CReserveKey &reservekey, CBigNum &coinSerial,
uint256 &txHash, CBigNum &zcSelectedValue, bool &zcSelectedIsUsed,
std::string &strFailReason, bool forceUsed) {

// temporarily disable zerocoin
strFailReason = "Zerocoin functionality has been disabled until the pending Sigma release.";
return false;

if (nValue <= 0) {
strFailReason = _("Transaction amounts must be positive");
return false;
Expand Down Expand Up @@ -4057,6 +4082,10 @@ bool CWallet::CreateMultipleZerocoinSpendTransaction(std::string &thirdPartyaddr
CWalletTx &wtxNew, CReserveKey &reservekey, vector<CBigNum> &coinSerials, uint256 &txHash, vector<CBigNum> &zcSelectedValues,
std::string &strFailReason, bool forceUsed)
{
// temporarily disable zerocoin
strFailReason = "Zerocoin functionality has been disabled until the pending Sigma release.";
return false;

wtxNew.BindWallet(this);
CMutableTransaction txNew;
{
Expand Down Expand Up @@ -4407,6 +4436,9 @@ bool CWallet::CommitZerocoinSpendTransaction(CWalletTx &wtxNew, CReserveKey &res
string CWallet::MintAndStoreZerocoin(vector<CRecipient> vecSend,
vector<libzerocoin::PrivateCoin> privCoins,
CWalletTx &wtxNew, bool fAskFee) {
// temporarily disable zerocoin
return "Zerocoin functionality has been disabled until the pending Sigma release.";

string strError;
if (IsLocked()) {
strError = _("Error: Wallet locked, unable to create transaction!");
Expand Down Expand Up @@ -4486,6 +4518,8 @@ string CWallet::MintAndStoreZerocoin(vector<CRecipient> vecSend,
* @return
*/
string CWallet::MintZerocoin(CScript pubCoin, int64_t nValue, CWalletTx &wtxNew, bool fAskFee) {
// temporarily disable zerocoin
return "Zerocoin functionality has been disabled until the pending Sigma release.";

LogPrintf("MintZerocoin: value = %s\n", nValue);
// Check amount
Expand Down Expand Up @@ -4546,6 +4580,9 @@ string CWallet::MintZerocoin(CScript pubCoin, int64_t nValue, CWalletTx &wtxNew,
string CWallet::SpendZerocoin(std::string &thirdPartyaddress, int64_t nValue, libzerocoin::CoinDenomination denomination, CWalletTx &wtxNew,
CBigNum &coinSerial, uint256 &txHash, CBigNum &zcSelectedValue,
bool &zcSelectedIsUsed, bool forceUsed) {
// temporarily disable zerocoin
return "Zerocoin functionality has been disabled until the pending Sigma release.";

// Check amount
if (nValue <= 0)
return _("Invalid amount");
Expand Down Expand Up @@ -4617,6 +4654,9 @@ string CWallet::SpendZerocoin(std::string &thirdPartyaddress, int64_t nValue, li
*/
string CWallet::SpendMultipleZerocoin(std::string &thirdPartyaddress, const std::vector<std::pair<int64_t, libzerocoin::CoinDenomination>>& denominations, CWalletTx &wtxNew,
vector<CBigNum> &coinSerials, uint256 &txHash, vector<CBigNum> &zcSelectedValues, bool forceUsed) {
// temporarily disable zerocoin
return "Zerocoin functionality has been disabled until the pending Sigma release.";

CReserveKey reservekey(this);
string strError = "";
if (IsLocked()) {
Expand Down
3 changes: 3 additions & 0 deletions src/zerocoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ bool CheckZerocoinTransaction(const CTransaction &tx,
bool fStatefulZerocoinCheck,
CZerocoinTxInfo *zerocoinTxInfo)
{
if (nHeight >= params.nDisableZerocoinStartBlock)
return state.DoS(100, error("Zerocoin is disabled at this point"));

// Check Mint Zerocoin Transaction
BOOST_FOREACH(const CTxOut &txout, tx.vout) {
if (!txout.scriptPubKey.empty() && txout.scriptPubKey.IsZerocoinMint()) {
Expand Down

0 comments on commit 721e522

Please sign in to comment.