From 856383a83e3f847e8739a50b395c2ee6d78cc027 Mon Sep 17 00:00:00 2001 From: a-bezrukov <36845392+a-bezrukov@users.noreply.github.com> Date: Tue, 30 Apr 2019 12:35:13 +0300 Subject: [PATCH] Fixing wallet txs (#384) * Fixed wallet load problems * Update version number --- README.md | 6 +++--- configure.ac | 2 +- src/chainparams.cpp | 2 +- src/test/mtp_malformed_tests.cpp | 6 +++--- src/test/zerocoin_tests.cpp | 24 +++++++++++++++++++----- src/test/zerocoin_tests2.cpp | 10 ++++++++-- src/test/zerocoin_tests3.cpp | 10 ++++++++-- src/zerocoin.cpp | 7 +++++-- 8 files changed, 48 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index bccfe611dd..0ce9020449 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Zcoin v0.13.7.9 +Zcoin v0.13.7.10 =============== [![Build Status](https://travis-ci.com/zcoinofficial/zcoin.svg?branch=CI)](https://travis-ci.com/zcoinofficial/zcoin) @@ -6,9 +6,9 @@ Zcoin v0.13.7.9 What is Zcoin? -------------- -[Zcoin](https://zcoin.io) is the first full implementation of the Zerocoin Protocol, which allows users to have complete privacy via Zero-Knowledge cryptographic proofs. It is worth noting that Zcoin is unrelated to other cryptocurrencies utilizing the Zerocash Protocol. Although Zerocash is a development from Zerocoin, their respective implementations are not simple forks of each other, but rely on different cryptographic assumptions with various tradeoffs. Both approaches supplement each other quite nicely, and a good way to describe them would be sibling projects. +[Zcoin](https://zcoin.io) is a privacy focused cryptocurrency that utilizes zero knowledge proofs which allows users to destroy coins and then redeem them later for brand new ones with no transaction history. It was the first project to implement the Zerocoin protocol and is now transitioning to the [Sigma protocol](https://zcoin.io/what-is-sigma-and-why-is-it-replacing-zerocoin-in-zcoin/) which has no trusted setup and small proof sizes. Zcoin also utilises [Dandelion++](https://arxiv.org/abs/1805.11060) to obscure the originating IP of transactions without relying on any external services such as TOR/i2P. -The Zerocoin Protocol is being actively researched and improved, such as removing the trustless setup and reducing proof sizes. +Zcoin developed and utilizes [Merkle Tree Proofs (MTP)](https://arxiv.org/pdf/1606.03588.pdf) as its Proof-of-Work algorithm which aims to be memory hard with fast verification. Running with Docker =================== diff --git a/configure.ac b/configure.ac index f6f2ecfbc7..bf67b57cb9 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MINOR, 13) define(_CLIENT_VERSION_REVISION, 7) -define(_CLIENT_VERSION_BUILD, 9) +define(_CLIENT_VERSION_BUILD, 10) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2019) define(_COPYRIGHT_HOLDERS,[The %s developers]) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index f3d049d111..c0187df7da 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -322,7 +322,7 @@ class CTestNetParams : public CChainParams { consensus.nInitialMTPDifficulty = 0x2000ffff; // !!!! change it to the real value consensus.nMTPRewardReduction = 2; - consensus.nDisableZerocoinStartBlock = INT_MAX; + consensus.nDisableZerocoinStartBlock = 50500; nPoolMaxTransactions = 3; nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes diff --git a/src/test/mtp_malformed_tests.cpp b/src/test/mtp_malformed_tests.cpp index 563dbd0526..016b5eaee8 100644 --- a/src/test/mtp_malformed_tests.cpp +++ b/src/test/mtp_malformed_tests.cpp @@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(mtp_malformed) mybufstream.clear(); mybufstream << *bMtp.mtpHashData; mybufstream.insert(mybufstream.begin(), 0); - BOOST_CHECK_EXCEPTION(mybufstream >> outh, std::runtime_error, no_check); + BOOST_CHECK_EXCEPTION(mybufstream >> outh, std::ios_base::failure, [](const std::ios_base::failure&) { return true; }); mybufstream.clear(); mybufstream << *bMtp.mtpHashData; @@ -230,12 +230,12 @@ BOOST_AUTO_TEST_CASE(mtp_malformed) mybufstream << *bMtp.mtpHashData; for(auto &it : mybufstream) it = rand()%256; - BOOST_CHECK_EXCEPTION(mybufstream >> outh, std::runtime_error, no_check); + BOOST_CHECK_EXCEPTION(mybufstream >> outh, std::ios_base::failure, [](const std::ios_base::failure&) { return true; }); mybufstream.clear(); mybufstream << *bMtp.mtpHashData; mybufstream.resize(mybufstream.size()/2); - BOOST_CHECK_EXCEPTION(mybufstream >> outh, std::runtime_error, no_check); + BOOST_CHECK_EXCEPTION(mybufstream >> outh, std::ios_base::failure, [](const std::ios_base::failure&) { return true; }); Params(CBaseChainParams::REGTEST).SetRegTestMtpSwitchTime(INT_MAX); } diff --git a/src/test/zerocoin_tests.cpp b/src/test/zerocoin_tests.cpp index b723949662..10aa9d931d 100644 --- a/src/test/zerocoin_tests.cpp +++ b/src/test/zerocoin_tests.cpp @@ -1,3 +1,6 @@ +//In late April 2019 the Zerocoin functionality has been disabled. +//The tests are changed so to verify it is disabled but change as little functionality as possible +//The initial functionality is left in here after comment //DZC #include "util.h" #include "clientversion.h" @@ -138,10 +141,13 @@ BOOST_AUTO_TEST_CASE(zerocoin_mintspend) vector> denominationPairs; std::pair denominationPair(stoi(denomination), 1); denominationPairs.push_back(denominationPair); - BOOST_CHECK_MESSAGE(pwalletMain->CreateZerocoinMintModel(stringError, denominationPairs), stringError + " - Create Mint failed"); + //DZC BOOST_CHECK_MESSAGE(pwalletMain->CreateZerocoinMintModel(stringError, denominationPairs), stringError + " - Create Mint failed"); + BOOST_CHECK_MESSAGE(!pwalletMain->CreateZerocoinMintModel(stringError, denominationPairs), stringError + " - Create Mint not failed"); //Verify Mint gets in the mempool - BOOST_CHECK_MESSAGE(mempool.size() == 1, "Mint was not added to mempool"); + //DZC BOOST_CHECK_MESSAGE(mempool.size() == 1, "Mint was not added to mempool"); + BOOST_CHECK_MESSAGE(mempool.size() == 0, "Mint was added to mempool"); + return; int previousHeight = chainActive.Height(); CBlock b = CreateAndProcessBlock(MinTxns, scriptPubKey); @@ -308,11 +314,14 @@ BOOST_AUTO_TEST_CASE(zerocoin_mintspend_many) std::pair denominationPair(stoi(denominationsForTx[i]), 1); denominationPairs.push_back(denominationPair); } - - BOOST_CHECK_MESSAGE(pwalletMain->CreateZerocoinMintModel(stringError, denominationPairs), stringError + " - Create Mint failed"); + + //DZC BOOST_CHECK_MESSAGE(pwalletMain->CreateZerocoinMintModel(stringError, denominationPairs), stringError + " - Create Mint failed"); + BOOST_CHECK_MESSAGE(!pwalletMain->CreateZerocoinMintModel(stringError, denominationPairs), stringError + " - Create Mint not failed"); //Verify mint tx get added in the mempool - BOOST_CHECK_MESSAGE(mempool.size() == 1, "Mint tx was not added to mempool"); + //DZC BOOST_CHECK_MESSAGE(mempool.size() == 1, "Mint tx was not added to mempool"); + BOOST_CHECK_MESSAGE(mempool.size() == 0, "Mint tx was added to mempool"); + return; int previousHeight = chainActive.Height(); b = CreateAndProcessBlock(MinTxns, scriptPubKey); @@ -533,6 +542,9 @@ BOOST_AUTO_TEST_CASE(zerocoin_mintspend_many) } BOOST_AUTO_TEST_CASE(zerocoin_mintspend_usedinput){ + + return; + vector denominationsForTx; vector> denominationPairs; vector vtxid; @@ -616,6 +628,8 @@ BOOST_AUTO_TEST_CASE(zerocoin_mintspend_usedinput){ } BOOST_AUTO_TEST_CASE(zerocoin_mintspend_numinputs){ + return; + vector denominationsForTx; vector vtxid; std::vector MinTxns; diff --git a/src/test/zerocoin_tests2.cpp b/src/test/zerocoin_tests2.cpp index b86b723fee..c0d52bcad8 100644 --- a/src/test/zerocoin_tests2.cpp +++ b/src/test/zerocoin_tests2.cpp @@ -1,3 +1,6 @@ +//In late April 2019 the Zerocoin functionality has been disabled. +//The tests are changed so to verify it is disabled but change as little functionality as possible +//The initial functionality is left in here after comment //DZC #include "util.h" #include "clientversion.h" @@ -133,10 +136,13 @@ BOOST_AUTO_TEST_CASE(zerocoin_mintspend2) //Block 110 create 5 mints //Verify Mint is successful for(int i = 0; i < 5; i++) - BOOST_CHECK_MESSAGE(pwalletMain->CreateZerocoinMintModel(stringError, denomination.c_str()), stringError + " - Create Mint failed"); + //DZC BOOST_CHECK_MESSAGE(pwalletMain->CreateZerocoinMintModel(stringError, denomination.c_str()), stringError + " - Create Mint failed"); + BOOST_CHECK_MESSAGE(!pwalletMain->CreateZerocoinMintModel(stringError, denomination.c_str()), stringError + " - Create Mint not failed"); //Put 5 in the same block - BOOST_CHECK_MESSAGE(mempool.size() == 5, "Mints were not added to mempool"); + //DZC BOOST_CHECK_MESSAGE(mempool.size() == 5, "Mints were not added to mempool"); + BOOST_CHECK_MESSAGE(mempool.size() == 0, "Mints were added to mempool"); + return; vtxid.clear(); mempool.queryHashes(vtxid); diff --git a/src/test/zerocoin_tests3.cpp b/src/test/zerocoin_tests3.cpp index f016976f4e..31d477bc66 100644 --- a/src/test/zerocoin_tests3.cpp +++ b/src/test/zerocoin_tests3.cpp @@ -1,3 +1,6 @@ +//In late April 2019 the Zerocoin functionality has been disabled. +//The tests are changed so to verify it is disabled but change as little functionality as possible +//The initial functionality is left in here after comment //DZC #include "util.h" #include "clientversion.h" @@ -134,10 +137,13 @@ BOOST_AUTO_TEST_CASE(zerocoin_mintspend) pwalletMain->SetBroadcastTransactions(true); //Verify Mint is successful - BOOST_CHECK_MESSAGE(pwalletMain->CreateZerocoinMintModel(stringError, denomination.c_str()), stringError + " - Create Mint failed"); + //DZC BOOST_CHECK_MESSAGE(pwalletMain->CreateZerocoinMintModel(stringError, denomination.c_str()), stringError + " - Create Mint failed"); + BOOST_CHECK_MESSAGE(!pwalletMain->CreateZerocoinMintModel(stringError, denomination.c_str()), stringError + " - Create Mint not failed"); //Verify Mint gets in the mempool - BOOST_CHECK_MESSAGE(mempool.size() == 1, "Mint was not added to mempool"); + //DZC BOOST_CHECK_MESSAGE(mempool.size() == 1, "Mint was not added to mempool"); + BOOST_CHECK_MESSAGE(mempool.size() == 0, "Mint was added to mempool"); + return; int previousHeight = chainActive.Height(); CBlock b = CreateAndProcessBlock(MinTxns, scriptPubKey3); diff --git a/src/zerocoin.cpp b/src/zerocoin.cpp index 6d48601c46..15ab671a6d 100644 --- a/src/zerocoin.cpp +++ b/src/zerocoin.cpp @@ -528,8 +528,11 @@ bool CheckZerocoinTransaction(const CTransaction &tx, bool fStatefulZerocoinCheck, CZerocoinTxInfo *zerocoinTxInfo) { - if ((tx.IsZerocoinSpend() || tx.IsZerocoinMint()) && nHeight >= params.nDisableZerocoinStartBlock) - return state.DoS(1, error("Zerocoin is disabled at this point")); + if (tx.IsZerocoinSpend() || tx.IsZerocoinMint()) { + if ((nHeight != INT_MAX && nHeight >= params.nDisableZerocoinStartBlock) // transaction is a part of block: disable after specific block number + || (nHeight == INT_MAX && !isVerifyDB)) // transaction is accepted to the memory pool: always disable + return state.DoS(1, error("Zerocoin is disabled at this point")); + } // Check Mint Zerocoin Transaction BOOST_FOREACH(const CTxOut &txout, tx.vout) {