Skip to content

Commit

Permalink
Fixing wallet txs (#384)
Browse files Browse the repository at this point in the history
* Fixed wallet load problems
* Update version number
  • Loading branch information
a-bezrukov authored Apr 30, 2019
1 parent c58d07d commit 856383a
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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)

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
===================
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/test/mtp_malformed_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down
24 changes: 19 additions & 5 deletions src/test/zerocoin_tests.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -138,10 +141,13 @@ BOOST_AUTO_TEST_CASE(zerocoin_mintspend)
vector<pair<int,int>> denominationPairs;
std::pair<int,int> 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);
Expand Down Expand Up @@ -308,11 +314,14 @@ BOOST_AUTO_TEST_CASE(zerocoin_mintspend_many)
std::pair<int,int> 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);
Expand Down Expand Up @@ -533,6 +542,9 @@ BOOST_AUTO_TEST_CASE(zerocoin_mintspend_many)
}

BOOST_AUTO_TEST_CASE(zerocoin_mintspend_usedinput){

return;

vector<string> denominationsForTx;
vector<pair<int,int>> denominationPairs;
vector<uint256> vtxid;
Expand Down Expand Up @@ -616,6 +628,8 @@ BOOST_AUTO_TEST_CASE(zerocoin_mintspend_usedinput){
}

BOOST_AUTO_TEST_CASE(zerocoin_mintspend_numinputs){
return;

vector<string> denominationsForTx;
vector<uint256> vtxid;
std::vector<CMutableTransaction> MinTxns;
Expand Down
10 changes: 8 additions & 2 deletions src/test/zerocoin_tests2.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions src/test/zerocoin_tests3.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions src/zerocoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 856383a

Please sign in to comment.