Skip to content

Commit

Permalink
MTP and Exodus bugfix release (#308)
Browse files Browse the repository at this point in the history
* Change all Exodus console output to log file instead

* Added MTP bit to consensus parameter

* Fixed crash when reindexing with unconfirmed spends in wallet

* MTP Malformed proof unit tests

* MTP tests update

* Disable Exodus by default

* Rename Balances page to ExoAssets and move to before Toolbox

* Saving znodes & znode payments cache

* Allow mining only if znode winner is known

* Fix incorrect tooltip for Send page

* Fixed potential deadlock

* Version bump to 0.13.7.2

* Update Exodus option's usage and remove unused one

* Remove Exodus initial scan block filter since we don't use it
  • Loading branch information
psolstice authored and a-bezrukov committed Nov 22, 2018
1 parent aa52ad3 commit 1bd31af
Show file tree
Hide file tree
Showing 40 changed files with 954 additions and 6,188 deletions.
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, 1)
define(_CLIENT_VERSION_BUILD, 2)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
2 changes: 0 additions & 2 deletions src/Makefile.exodus.include
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ EXODUS_H = \
exodus/rpcvalues.h \
exodus/rules.h \
exodus/script.h \
exodus/seedblocks.h \
exodus/sp.h \
exodus/sto.h \
exodus/tally.h \
Expand Down Expand Up @@ -65,7 +64,6 @@ EXODUS_CPP = \
exodus/rpcvalues.cpp \
exodus/rules.cpp \
exodus/script.cpp \
exodus/seedblocks.cpp \
exodus/sp.cpp \
exodus/sto.cpp \
exodus/tally.cpp \
Expand Down
14 changes: 7 additions & 7 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ QT_FORMS_UI = \
qt/forms/metadexcanceldialog.ui \
qt/forms/metadexdialog.ui \
qt/forms/tradehistorydialog.ui \
qt/forms/balancesdialog.ui
qt/forms/exoassetsdialog.ui

QT_MOC_CPP = \
qt/moc_addressbookpage.cpp \
Expand Down Expand Up @@ -175,7 +175,7 @@ QT_MOC_CPP = \
qt/moc_lookupspdialog.cpp \
qt/moc_lookuptxdialog.cpp \
qt/moc_txhistorydialog.cpp \
qt/moc_balancesdialog.cpp \
qt/moc_exoassetsdialog.cpp \
qt/moc_metadexdialog.cpp \
qt/moc_metadexcanceldialog.cpp \
qt/moc_tradehistorydialog.cpp
Expand Down Expand Up @@ -258,7 +258,7 @@ BITCOIN_QT_H = \
qt/lookupspdialog.h \
qt/lookuptxdialog.h \
qt/txhistorydialog.h \
qt/balancesdialog.h \
qt/exoassetsdialog.h \
qt/metadexdialog.h \
qt/metadexcanceldialog.h \
qt/tradehistorydialog.h \
Expand Down Expand Up @@ -294,7 +294,7 @@ RES_ICONS = \
qt/res/icons/edit.png \
qt/res/icons/editcopy.png \
qt/res/icons/editpaste.png \
qt/res/icons/exchange.png \
qt/res/icons/exchange.png \
qt/res/icons/export.png \
qt/res/icons/eye.png \
qt/res/icons/eye_minus.png \
Expand All @@ -317,15 +317,15 @@ RES_ICONS = \
qt/res/icons/exodus_inout.png \
qt/res/icons/exodus_invalid.png \
qt/res/icons/exodus_out.png \
qt/res/icons/exodus_hourglass.png \
qt/res/icons/exodus_hourglass.png \
qt/res/icons/open.png \
qt/res/icons/overview.png \
qt/res/icons/quit.png \
qt/res/icons/receive.png \
qt/res/icons/remove.png \
qt/res/icons/send.png \
qt/res/icons/synced.png \
qt/res/icons/tools.png \
qt/res/icons/tools.png \
qt/res/icons/transaction0.png \
qt/res/icons/transaction2.png \
qt/res/icons/transaction_conflicted.png \
Expand Down Expand Up @@ -400,7 +400,7 @@ BITCOIN_QT_WALLET_CPP = \
qt/lookupspdialog.cpp \
qt/lookuptxdialog.cpp \
qt/txhistorydialog.cpp \
qt/balancesdialog.cpp \
qt/exoassetsdialog.cpp \
qt/metadexdialog.cpp \
qt/metadexcanceldialog.cpp \
qt/tradehistorydialog.cpp
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ BITCOIN_TESTS =\
test/znode_tests.cpp \
test/mtp_trans_tests.cpp \
test/mtp_halving_tests.cpp \
test/mtp_malformed_tests.cpp \
test/mtp_tests.cpp \
test/arith_uint256_tests.cpp \
test/scriptnum10.h \
Expand Down
13 changes: 13 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1479168000; // November 15th, 2016.
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1510704000; // November 15th, 2017.

// Deployment of MTP
consensus.vDeployments[Consensus::DEPLOYMENT_MTP].bit = 12;
consensus.vDeployments[Consensus::DEPLOYMENT_MTP].nStartTime = SWITCH_TO_MTP_BLOCK_HEADER - 2*60; // 2 hours leeway
consensus.vDeployments[Consensus::DEPLOYMENT_MTP].nTimeout = SWITCH_TO_MTP_BLOCK_HEADER + consensus.nMinerConfirmationWindow*2 * 5*60;

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000708f98bf623f02e");

Expand Down Expand Up @@ -271,6 +276,11 @@ class CTestNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1462060800; // May 1st 2016
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1493596800; // May 1st 2017

// Deployment of MTP
consensus.vDeployments[Consensus::DEPLOYMENT_MTP].bit = 12;
consensus.vDeployments[Consensus::DEPLOYMENT_MTP].nStartTime = 1539172800 - 2*60;
consensus.vDeployments[Consensus::DEPLOYMENT_MTP].nTimeout = 1539172800 + consensus.nMinerConfirmationWindow*2 * 5*60;

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000708f98bf623f02e");

Expand Down Expand Up @@ -407,6 +417,9 @@ class CRegTestParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_MTP].bit = 12;
consensus.vDeployments[Consensus::DEPLOYMENT_MTP].nStartTime = INT_MAX;
consensus.vDeployments[Consensus::DEPLOYMENT_MTP].nTimeout = 999999999999ULL;

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");
Expand Down
3 changes: 3 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ enum DeploymentPos
DEPLOYMENT_TESTDUMMY,
DEPLOYMENT_CSV, // Deployment of BIP68, BIP112, and BIP113.
DEPLOYMENT_SEGWIT, // Deployment of BIP141, BIP143, and BIP147.

DEPLOYMENT_MTP, // Deployment of MTP

// NOTE: Also add new deployments to VersionBitsDeploymentInfo in versionbits.cpp
MAX_VERSION_BITS_DEPLOYMENTS
};
Expand Down
1 change: 0 additions & 1 deletion src/exodus/activation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ void CheckLiveActivations(int blockHeight)
if (EXODUS_VERSION < liveActivation.minClientVersion) {
std::string msgText = strprintf("Shutting down due to unsupported feature activation (%d: %s)", liveActivation.featureId, liveActivation.featureName);
PrintToLog(msgText);
PrintToConsole(msgText);
if (!GetBoolArg("-overrideforcedshutdown", false)) {
boost::filesystem::path persistPath = GetDataDir() / "MP_persist";
if (boost::filesystem::exists(persistPath)) boost::filesystem::remove_all(persistPath); // prevent the node being restarted without a reparse after forced shutdown
Expand Down
70 changes: 35 additions & 35 deletions src/exodus/exodus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "exodus/persistence.h"
#include "exodus/rules.h"
#include "exodus/script.h"
#include "exodus/seedblocks.h"
#include "exodus/sp.h"
#include "exodus/tally.h"
#include "exodus/tx.h"
Expand Down Expand Up @@ -149,6 +148,11 @@ static bool writePersistence(int block_now)
return true;
}

bool isExodusEnabled()
{
return GetBoolArg("-exodus", false);
}

std::string exodus::strMPProperty(uint32_t propertyId)
{
std::string str = "*unknown*";
Expand Down Expand Up @@ -1294,7 +1298,7 @@ class ProgressReporter
"Still scanning.. at block %d of %d.\nProgress: %.2f %% (about %s remaining)",
nCurrentBlock, nLastBlock, dProgress, remainingTimeAsString(nRemainingTime));

PrintToConsole(strProgress);
PrintToLog(strProgress);
uiInterface.InitMessage(strProgressUI);
}
};
Expand Down Expand Up @@ -1322,21 +1326,17 @@ static int exodus_initial_scan(int nFirstBlock)
{
int nTimeBetweenProgressReports = GetArg("-exodusprogressfrequency", 30); // seconds
int64_t nNow = GetTime();
unsigned int nTxsTotal = 0;
unsigned int nTxsFoundTotal = 0;
size_t nTxsTotal = 0, nTxsFoundTotal = 0;
int nBlock = 999999;
const int nLastBlock = GetHeight();

// this function is useless if there are not enough blocks in the blockchain yet!
if (nFirstBlock < 0 || nLastBlock < nFirstBlock) return -1;
PrintToConsole("Scanning for transactions in block %d to block %d..\n", nFirstBlock, nLastBlock);
PrintToLog("Scanning for transactions in block %d to block %d..\n", nFirstBlock, nLastBlock);

// used to print the progress to the console and notifies the UI
ProgressReporter progressReporter(chainActive[nFirstBlock], chainActive[nLastBlock]);

// check if using seed block filter should be disabled
bool seedBlockFilterEnabled = GetBoolArg("-exodusseedblockfilter", true);

for (nBlock = nFirstBlock; nBlock <= nLastBlock; ++nBlock)
{
if (ShutdownRequested()) {
Expand All @@ -1356,30 +1356,36 @@ static int exodus_initial_scan(int nFirstBlock)
nNow = GetTime();
}

unsigned int nTxNum = 0;
unsigned int nTxsFoundInBlock = 0;
exodus_handler_block_begin(nBlock, pblockindex);
// Get block to parse.
CBlock block;

if (!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus())) {
break;
}

if (!seedBlockFilterEnabled || !SkipBlock(nBlock)) {
CBlock block;
if (!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus())) break;
// Parse block.
unsigned parsed = 0;

BOOST_FOREACH(const CTransaction&tx, block.vtx) {
if (exodus_handler_tx(tx, nBlock, nTxNum, pblockindex)) ++nTxsFoundInBlock;
++nTxNum;
exodus_handler_block_begin(nBlock, pblockindex);

for (unsigned i = 0; i < block.vtx.size(); i++) {
if (exodus_handler_tx(block.vtx[i], nBlock, i, pblockindex)) {
parsed++;
}
}

nTxsFoundTotal += nTxsFoundInBlock;
nTxsTotal += nTxNum;
exodus_handler_block_end(nBlock, pblockindex, nTxsFoundInBlock);
exodus_handler_block_end(nBlock, pblockindex, parsed);

// Sum total parsed.
nTxsFoundTotal += parsed;
nTxsTotal += block.vtx.size();
}

if (nBlock < nLastBlock) {
PrintToConsole("Scan stopped early at block %d of block %d\n", nBlock, nLastBlock);
PrintToLog("Scan stopped early at block %d of block %d\n", nBlock, nLastBlock);
}

PrintToConsole("%d transactions processed, %d meta transactions found\n", nTxsTotal, nTxsFoundTotal);
PrintToLog("%zu transactions processed, %zu meta transactions found\n", nTxsTotal, nTxsFoundTotal);

return 0;
}
Expand Down Expand Up @@ -2126,8 +2132,6 @@ int exodus_init()
return 0;
}

PrintToConsole("Initializing Exodus v%s [%s]\n", ExodusVersion(), Params().NetworkIDString());

PrintToLog("\nInitializing Exodus v%s [%s]\n", ExodusVersion(), Params().NetworkIDString());
PrintToLog("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));

Expand Down Expand Up @@ -2170,7 +2174,6 @@ int exodus_init()
startClean = true;
} catch (const boost::filesystem::filesystem_error& e) {
PrintToLog("Failed to delete persistence folders: %s\n", e.what());
PrintToConsole("Failed to delete persistence folders: %s\n", e.what());
}
}

Expand Down Expand Up @@ -2199,13 +2202,13 @@ int exodus_init()
}

if (nWaterlineBlock > 0) {
PrintToConsole("Loading persistent state: OK [block %d]\n", nWaterlineBlock);
PrintToLog("Loading persistent state: OK [block %d]\n", nWaterlineBlock);
} else {
std::string strReason = "unknown";
if (wrongDBVersion) strReason = "client version changed";
if (noPreviousState) strReason = "no usable previous state found";
if (startClean) strReason = "-startclean parameter used";
PrintToConsole("Loading persistent state: NONE (%s)\n", strReason);
PrintToLog("Loading persistent state: NONE (%s)\n", strReason);
}

if (nWaterlineBlock < 0) {
Expand Down Expand Up @@ -2251,10 +2254,9 @@ int exodus_init()

// display Exodus balance
int64_t exodus_balance = getMPbalance(exodus_address, EXODUS_PROPERTY_EXODUS, BALANCE);
PrintToLog("Exodus balance after initialization: %s\n", FormatDivisibleMP(exodus_balance));

PrintToConsole("Exodus balance: %s EXODUS\n", FormatDivisibleMP(exodus_balance));
PrintToConsole("Exodus initialization completed\n");
PrintToLog("Exodus balance after initialization: %s\n", FormatDivisibleMP(exodus_balance));
PrintToLog("Exodus initialization completed\n");

return 0;
}
Expand Down Expand Up @@ -2305,8 +2307,6 @@ int exodus_shutdown()
PrintToLog("\nExodus Core shutdown completed\n");
PrintToLog("Shutdown time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));

PrintToConsole("Exodus Core shutdown completed\n");

return 0;
}

Expand Down Expand Up @@ -3161,7 +3161,7 @@ Slice skey, svalue;
skey = it->key();
svalue = it->value();
++count;
PrintToConsole("entry #%8d= %s:%s\n", count, skey.ToString(), svalue.ToString());
PrintToLog("entry #%8d= %s:%s\n", count, skey.ToString(), svalue.ToString());
}

delete it;
Expand Down Expand Up @@ -3398,7 +3398,7 @@ void CMPSTOList::printAll()
skey = it->key();
svalue = it->value();
++count;
PrintToConsole("entry #%8d= %s:%s\n", count, skey.ToString(), svalue.ToString());
PrintToLog("entry #%8d= %s:%s\n", count, skey.ToString(), svalue.ToString());
}

delete it;
Expand Down Expand Up @@ -3745,7 +3745,7 @@ void CMPTradeList::printAll()
skey = it->key();
svalue = it->value();
++count;
PrintToConsole("entry #%8d= %s:%s\n", count, skey.ToString(), svalue.ToString());
PrintToLog("entry #%8d= %s:%s\n", count, skey.ToString(), svalue.ToString());
}

delete it;
Expand Down
10 changes: 6 additions & 4 deletions src/exodus/exodus.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class CExodusTransactionDB : public CDBBase
CExodusTransactionDB(const boost::filesystem::path& path, bool fWipe)
{
leveldb::Status status = Open(path, fWipe);
PrintToConsole("Loading master transactions database: %s\n", status.ToString());
PrintToLog("Loading master transactions database: %s\n", status.ToString());
}

virtual ~CExodusTransactionDB()
Expand Down Expand Up @@ -192,7 +192,7 @@ class CMPSTOList : public CDBBase
CMPSTOList(const boost::filesystem::path& path, bool fWipe)
{
leveldb::Status status = Open(path, fWipe);
PrintToConsole("Loading send-to-owners database: %s\n", status.ToString());
PrintToLog("Loading send-to-owners database: %s\n", status.ToString());
}

virtual ~CMPSTOList()
Expand All @@ -217,7 +217,7 @@ class CMPTradeList : public CDBBase
CMPTradeList(const boost::filesystem::path& path, bool fWipe)
{
leveldb::Status status = Open(path, fWipe);
PrintToConsole("Loading trades database: %s\n", status.ToString());
PrintToLog("Loading trades database: %s\n", status.ToString());
}

virtual ~CMPTradeList()
Expand Down Expand Up @@ -245,7 +245,7 @@ class CMPTxList : public CDBBase
CMPTxList(const boost::filesystem::path& path, bool fWipe)
{
leveldb::Status status = Open(path, fWipe);
PrintToConsole("Loading tx meta-info database: %s\n", status.ToString());
PrintToLog("Loading tx meta-info database: %s\n", status.ToString());
}

virtual ~CMPTxList()
Expand Down Expand Up @@ -299,6 +299,8 @@ int64_t getMPbalance(const std::string& address, uint32_t propertyId, TallyType
int64_t getUserAvailableMPbalance(const std::string& address, uint32_t propertyId);
int64_t getUserFrozenMPbalance(const std::string& address, uint32_t propertyId);

bool isExodusEnabled();

/** Global handler to initialize Exodus Core. */
int exodus_init();

Expand Down
Loading

0 comments on commit 1bd31af

Please sign in to comment.