Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version bump and fix duplicates #894

Merged
merged 2 commits into from
Aug 18, 2020
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
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ BITCOIN_CORE_H = \
hdmint/wallet.h \
zerocoin.h \
sigma.h \
blacklists.h \
coin_containers.h \
zerocoin_params.h \
addresstype.h \
Expand Down
1,670 changes: 1,670 additions & 0 deletions src/blacklists.h

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ class CMainParams : public CChainParams {
consensus.stage2ZnodeShare = 35;
consensus.stage2DevelopmentFundAddress = "aFrAVZFr8pva5mG8XKaUH8EXcFVVNxLiuB";

consensus.nStartBlacklist = 293990;
consensus.nStartDuplicationCheck = 293526;

consensus.nMajorityEnforceBlockUpgrade = 750;
consensus.nMajorityRejectBlockOutdated = 950;
consensus.nMajorityWindow = 1000;
Expand Down Expand Up @@ -366,6 +369,7 @@ class CMainParams : public CChainParams {
consensus.nSigmaStartBlock = ZC_SIGMA_STARTING_BLOCK;
consensus.nSigmaPaddingBlock = ZC_SIGMA_PADDING_BLOCK;
consensus.nDisableUnpaddedSigmaBlock = ZC_SIGMA_DISABLE_UNPADDED_BLOCK;
consensus.nStartSigmaBlacklist = 293790;
consensus.nOldSigmaBanBlock = ZC_OLD_SIGMA_BAN_BLOCK;
consensus.nZerocoinV2MintMempoolGracefulPeriod = ZC_V2_MINT_GRACEFUL_MEMPOOL_PERIOD;
consensus.nZerocoinV2MintGracefulPeriod = ZC_V2_MINT_GRACEFUL_PERIOD;
Expand Down Expand Up @@ -409,6 +413,8 @@ class CTestNetParams : public CChainParams {
consensus.stage2ZnodeShare = 35;
consensus.stage2DevelopmentFundAddress = "TUuKypsbbnHHmZ2auC2BBWfaP1oTEnxjK2";

consensus.nStartBlacklist = 0;
consensus.nStartDuplicationCheck = 0;
consensus.nMajorityEnforceBlockUpgrade = 51;
consensus.nMajorityRejectBlockOutdated = 75;
consensus.nMajorityWindow = 100;
Expand Down Expand Up @@ -571,6 +577,7 @@ class CTestNetParams : public CChainParams {
consensus.nSigmaStartBlock = 1;
consensus.nSigmaPaddingBlock = 1;
consensus.nDisableUnpaddedSigmaBlock = 1;
consensus.nStartSigmaBlacklist = 1;
consensus.nOldSigmaBanBlock = 1;

consensus.nZerocoinV2MintMempoolGracefulPeriod = ZC_V2_MINT_TESTNET_GRACEFUL_MEMPOOL_PERIOD;
Expand Down Expand Up @@ -612,6 +619,8 @@ class CRegTestParams : public CChainParams {
consensus.nSubsidyHalvingInterval = 420000;
consensus.nSubsidyHalvingStopBlock = 3646849;

consensus.nStartBlacklist = 0;
consensus.nStartDuplicationCheck = 0;
consensus.stage2DevelopmentFundShare = 15;
consensus.stage2ZnodeShare = 35;

Expand Down Expand Up @@ -752,6 +761,7 @@ class CRegTestParams : public CChainParams {
consensus.nSigmaStartBlock = 400;
consensus.nSigmaPaddingBlock = 550;
consensus.nDisableUnpaddedSigmaBlock = 510;
consensus.nStartSigmaBlacklist = 1;
consensus.nOldSigmaBanBlock = 450;
consensus.nZerocoinV2MintMempoolGracefulPeriod = 2;
consensus.nZerocoinV2MintGracefulPeriod = 5;
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 14
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 3
#define CLIENT_VERSION_BUILD 4

//! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
5 changes: 5 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ struct Params {
/** percentage of block subsidy going to znode */
int stage2ZnodeShare;

int nStartDuplicationCheck;
int nStartBlacklist;

/** Used to check majorities for block version upgrade */
int nMajorityEnforceBlockUpgrade;
int nMajorityRejectBlockOutdated;
Expand Down Expand Up @@ -223,6 +226,8 @@ struct Params {

int nDisableUnpaddedSigmaBlock;

int nStartSigmaBlacklist;

// The block number after which old sigma clients are banned.
int nOldSigmaBanBlock;

Expand Down
23 changes: 19 additions & 4 deletions src/sigma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "znode-sync.h"
#include "primitives/zerocoin.h"

#include "blacklists.h"

#include <atomic>
#include <sstream>
#include <chrono>
Expand Down Expand Up @@ -277,6 +279,12 @@ bool CheckSigmaSpendTransaction(
if (index->sigmaMintedPubCoins.count(denominationAndId) > 0) {
BOOST_FOREACH(const sigma::PublicCoin& pubCoinValue,
index->sigmaMintedPubCoins[denominationAndId]) {
if (nHeight >= params.nStartSigmaBlacklist) {
std::vector<unsigned char> vch = pubCoinValue.getValue().getvch();
if(sigma_blacklist.count(HexStr(vch.begin(), vch.end())) > 0) {
continue;
}
}
anonymity_set.push_back(pubCoinValue);
}
}
Expand Down Expand Up @@ -1049,10 +1057,17 @@ int CSigmaState::GetCoinSetForSpend(
// remember block hash
blockHash_out = block->GetBlockHash();
}
numberOfCoins += block->sigmaMintedPubCoins[denomAndId].size();
coins_out.insert(coins_out.end(),
block->sigmaMintedPubCoins[denomAndId].begin(),
block->sigmaMintedPubCoins[denomAndId].end());
BOOST_FOREACH(const sigma::PublicCoin& pubCoinValue,
block->sigmaMintedPubCoins[denomAndId]) {
if (chainActive.Height() > ::Params().GetConsensus().nStartSigmaBlacklist) {
std::vector<unsigned char> vch = pubCoinValue.getValue().getvch();
if(sigma_blacklist.count(HexStr(vch.begin(), vch.end())) > 0) {
continue;
}
coins_out.push_back(pubCoinValue);
numberOfCoins++;
}
}
}
}
if (block == coinGroup.firstBlock) {
Expand Down
24 changes: 22 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
#include "znodeman.h"
#include "coins.h"

#include "blacklists.h"

#include "sigma/coinspend.h"
#include "sigma/remint.h"
#include "warnings.h"
Expand Down Expand Up @@ -603,7 +605,8 @@ bool CheckTransaction(const CTransaction &tx, CValidationState &state, bool fChe
}

// Check for duplicate inputs - note that this check is slow so we skip it in CheckBlock
if (fCheckDuplicateInputs) {
bool const check_di = nHeight != INT_MAX && nHeight > ::Params().GetConsensus().nStartDuplicationCheck;
if (fCheckDuplicateInputs || check_di) {
std::set<COutPoint> vInOutPoints;
if (tx.IsZerocoinSpend() || tx.IsSigmaSpend() || tx.IsZerocoinRemint()) {
std::set<CScript> spendScripts;
Expand Down Expand Up @@ -648,6 +651,14 @@ bool CheckTransaction(const CTransaction &tx, CValidationState &state, bool fChe
return false;
}

if(nHeight != INT_MAX && nHeight >= ::Params().GetConsensus().nStartBlacklist) {
for (const auto& vin : tx.vin) {
if(txid_blacklist.count(vin.prevout.hash.GetHex()) > 0) {
return state.DoS(100, error("Spending this tx is temporarily disabled"),
REJECT_INVALID, "bad-txns-zerocoin");
}
}
}
return true;
}

Expand Down Expand Up @@ -749,6 +760,11 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
}
}

if (tx.IsSigmaMint() || tx.IsSigmaSpend()) {
return state.DoS(100, error("Sigma is temporarily disabled"),
REJECT_INVALID, "bad-txns-zerocoin");
}

if (!CheckTransaction(tx, state, true, hash, false, INT_MAX, isCheckWalletTransaction)) {
LogPrintf("CheckTransaction() failed!");
return false; // state filled in by CheckTransaction
Expand Down Expand Up @@ -3879,12 +3895,16 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
if (nHeight == INT_MAX)
nHeight = ZerocoinGetNHeight(block.GetBlockHeader());

for (CTransactionRef tx : block.vtx)
for (CTransactionRef tx : block.vtx) {
if (nHeight >= consensusParams.nStartSigmaBlacklist && (tx->IsSigmaMint() || tx->IsSigmaSpend())) {
return state.DoS(100, error("Sigma is temporarily disabled"), REJECT_INVALID, "bad-txns-zerocoin");
}
// We don't check transactions against zerocoin state here, we'll check it again later in ConnectBlock
if (!CheckTransaction(*tx, state, false, tx->GetHash(), isVerifyDB, nHeight, false, false, NULL, NULL))
return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(),
strprintf("Transaction check failed (tx hash %s) %s", tx->GetHash().ToString(), state.GetDebugMessage()));

}
unsigned int nSigOps = 0;
for (const auto& tx : block.vtx)
{
Expand Down