Skip to content

Commit

Permalink
Fix getblocktemplate bugs (crash and missing spends) (#313)
Browse files Browse the repository at this point in the history
* Fixed getblocktemplate failing

* Fixed absence of spends in getblocktemplate

* Bugfix for testnet

* Version bump to 0.13.7.3

* Update Version to 0.13.7.3
  • Loading branch information
psolstice authored and a-bezrukov committed Nov 27, 2018
1 parent 3512ed6 commit a93f8ed
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 38 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Zcoin v0.13.7.2
=============
Zcoin v0.13.7.3
===============

[![Build Status](https://travis-ci.com/zcoinofficial/zcoin.svg?branch=CI)](https://travis-ci.com/zcoinofficial/zcoin)

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, 2)
define(_CLIENT_VERSION_BUILD, 3)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
15 changes: 0 additions & 15 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,15 +915,6 @@ void BlockAssembler::addPriorityTxs()
typedef std::map<CTxMemPool::txiter, double, CTxMemPool::CompareIteratorByHash>::iterator waitPriIter;
double actualPriority = -1;

unsigned int COUNT_SPEND_ZC_TX = 0;
unsigned int MAX_SPEND_ZC_TX_PER_BLOCK = 0;
if (chainActive.Height() + 1 > HF_ZEROSPEND_FIX) {
MAX_SPEND_ZC_TX_PER_BLOCK = 1;
}
if (nHeight + 1 > SWITCH_TO_MORE_SPEND_TXS) {
MAX_SPEND_ZC_TX_PER_BLOCK = ZC_SPEND_LIMIT;
}

vecPriority.reserve(mempool.mapTx.size());
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
mi != mempool.mapTx.end(); ++mi)
Expand All @@ -937,11 +928,6 @@ void BlockAssembler::addPriorityTxs()
if (tx.IsCoinBase() || !CheckFinalTx(tx))
continue;
if (tx.IsZerocoinSpend()) {

if ((COUNT_SPEND_ZC_TX + tx.vin.size()) > MAX_SPEND_ZC_TX_PER_BLOCK) {
continue;
}

//mempool.countZCSpend--;
// Size limits
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
Expand Down Expand Up @@ -970,7 +956,6 @@ void BlockAssembler::addPriorityTxs()
++nBlockTx;
nBlockSigOpsCost += nTxSigOps;
nFees += nTxFees;
COUNT_SPEND_ZC_TX+=tx.vin.size();
continue;
}
}
Expand Down
20 changes: 0 additions & 20 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,15 +645,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
UniValue transactions(UniValue::VARR);
map<uint256, int64_t> setTxIndex;
int i = 0;
unsigned int COUNT_SPEND_ZC_TX = 0;
unsigned int MAX_SPEND_ZC_TX_PER_BLOCK = 0;
if(chainActive.Height() + 1 > OLD_LIMIT_SPEND_TXS){
MAX_SPEND_ZC_TX_PER_BLOCK = 0;
}

if(chainActive.Height() + 1 > SWITCH_TO_MORE_SPEND_TXS){
MAX_SPEND_ZC_TX_PER_BLOCK = 5;
}

BOOST_FOREACH (CTransaction& tx, pblock->vtx) {
uint256 txHash = tx.GetHash();
Expand All @@ -662,17 +653,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
if (tx.IsCoinBase())
continue;

// https://github.com/zcoinofficial/zcoin/pull/26
// make order independence
// and easy to read for other people
if (tx.IsZerocoinSpend()) {
if (COUNT_SPEND_ZC_TX >= MAX_SPEND_ZC_TX_PER_BLOCK) {
continue;
}

COUNT_SPEND_ZC_TX++;
}

UniValue entry(UniValue::VOBJ);

entry.push_back(Pair("data", EncodeHexTx(tx)));
Expand Down
4 changes: 4 additions & 0 deletions src/versionbits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const struct BIP9DeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION
{
/*.name =*/ "segwit",
/*.gbt_force =*/ false,
},
{
/*.name =*/ "mtp",
/*.gbt_force=*/ true
}
};

Expand Down

0 comments on commit a93f8ed

Please sign in to comment.