Skip to content

Commit 0fee42e

Browse files
authored
Merge pull request #3312 from PastaPastaPasta/backports-0.16-pr6
Backports 0.16 pr6
2 parents 4af4432 + f16a0f7 commit 0fee42e

27 files changed

+359
-89
lines changed

contrib/valgrind.supp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Valgrind suppressions file for Dash.
2+
#
3+
# Includes known Valgrind warnings in our dependencies that cannot be fixed
4+
# in-tree.
5+
#
6+
# Example use:
7+
# $ valgrind --suppressions=contrib/valgrind.supp src/test/test_dash
8+
# $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \
9+
# --show-leak-kinds=all src/test/test_dash --log_level=test_suite
10+
{
11+
Suppress libstdc++ warning - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65434
12+
Memcheck:Leak
13+
match-leak-kinds: reachable
14+
fun:malloc
15+
obj:*/libstdc++.*
16+
fun:call_init.part.0
17+
fun:call_init
18+
fun:_dl_init
19+
obj:*/ld-*.so
20+
}
21+
{
22+
Suppress libdb warning - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=662917
23+
Memcheck:Cond
24+
obj:*/libdb_cxx-*.so
25+
fun:__log_put
26+
obj:*/libdb_cxx-*.so
27+
fun:__log_put_record
28+
}
29+
{
30+
Suppress leveldb warning (leveldb::InitModule()) - https://github.com/google/leveldb/issues/113
31+
Memcheck:Leak
32+
match-leak-kinds: reachable
33+
fun:_Znwm
34+
fun:_ZN7leveldbL10InitModuleEv
35+
}
36+
{
37+
Suppress leveldb warning (leveldb::Env::Default()) - https://github.com/google/leveldb/issues/113
38+
Memcheck:Leak
39+
match-leak-kinds: reachable
40+
fun:_Znwm
41+
...
42+
fun:_ZN7leveldbL14InitDefaultEnvEv
43+
}

contrib/verify-commits/gpg.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ REVSIG=false
99
IFS='
1010
'
1111
if [ "$BITCOIN_VERIFY_COMMITS_ALLOW_SHA1" = 1 ]; then
12-
GPG_RES="$(echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null)"
12+
GPG_RES="$(printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null)"
1313
else
1414
# Note how we've disabled SHA1 with the --weak-digest option, disabling
1515
# signatures - including selfsigs - that use SHA1. While you might think that
@@ -24,15 +24,15 @@ else
2424
case "$LINE" in
2525
"gpg (GnuPG) 1.4.1"*|"gpg (GnuPG) 2.0."*)
2626
echo "Please upgrade to at least gpg 2.1.10 to check for weak signatures" > /dev/stderr
27-
GPG_RES="$(echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null)"
27+
GPG_RES="$(printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null)"
2828
;;
2929
# We assume if you're running 2.1+, you're probably running 2.1.10+
3030
# gpg will fail otherwise
3131
# We assume if you're running 1.X, it is either 1.4.1X or 1.4.20+
3232
# gpg will fail otherwise
3333
esac
3434
done
35-
[ "$GPG_RES" = "" ] && GPG_RES="$(echo "$INPUT" | gpg --trust-model always --weak-digest sha1 "$@" 2>/dev/null)"
35+
[ "$GPG_RES" = "" ] && GPG_RES="$(printf '%s\n' "$INPUT" | gpg --trust-model always --weak-digest sha1 "$@" 2>/dev/null)"
3636
fi
3737
for LINE in $(echo "$GPG_RES"); do
3838
case "$LINE" in
@@ -57,8 +57,8 @@ if ! $VALID; then
5757
exit 1
5858
fi
5959
if $VALID && $REVSIG; then
60-
echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null | grep "\[GNUPG:\] \(NEWSIG\|SIG_ID\|VALIDSIG\)"
60+
printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null | grep "\[GNUPG:\] \(NEWSIG\|SIG_ID\|VALIDSIG\)"
6161
echo "$GOODREVSIG"
6262
else
63-
echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null
63+
printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null
6464
fi

doc/developer-notes.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,37 @@ can be very difficult to track down. Compiling with -DDEBUG_LOCKORDER (configure
168168
CXXFLAGS="-DDEBUG_LOCKORDER -g") inserts run-time checks to keep track of which locks
169169
are held, and adds warnings to the debug.log file if inconsistencies are detected.
170170

171+
**Valgrind suppressions file**
172+
173+
Valgrind is a programming tool for memory debugging, memory leak detection, and
174+
profiling. The repo contains a Valgrind suppressions file
175+
([`valgrind.supp`](https://github.com/dashpay/dash/blob/master/contrib/valgrind.supp))
176+
which includes known Valgrind warnings in our dependencies that cannot be fixed
177+
in-tree. Example use:
178+
179+
```shell
180+
$ valgrind --suppressions=contrib/valgrind.supp src/test/test_dash
181+
$ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \
182+
--show-leak-kinds=all src/test/test_dash --log_level=test_suite
183+
$ valgrind -v --leak-check=full src/dashd -printtoconsole
184+
```
185+
186+
**compiling for test coverage**
187+
188+
LCOV can be used to generate a test coverage report based upon `make check`
189+
execution. LCOV must be installed on your system (e.g. the `lcov` package
190+
on Debian/Ubuntu).
191+
192+
To enable LCOV report generation during test runs:
193+
194+
```shell
195+
./configure --enable-lcov
196+
make
197+
make cov
198+
199+
# A coverage report will now be accessible at `./test_dash.coverage/index.html`.
200+
```
201+
171202
Locking/mutex usage notes
172203
-------------------------
173204

src/chain.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ int static inline GetSkipHeight(int height) {
8080
return (height & 1) ? InvertLowestOne(InvertLowestOne(height - 1)) + 1 : InvertLowestOne(height);
8181
}
8282

83-
CBlockIndex* CBlockIndex::GetAncestor(int height)
83+
const CBlockIndex* CBlockIndex::GetAncestor(int height) const
8484
{
85-
if (height > nHeight || height < 0)
85+
if (height > nHeight || height < 0) {
8686
return nullptr;
87+
}
8788

88-
CBlockIndex* pindexWalk = this;
89+
const CBlockIndex* pindexWalk = this;
8990
int heightWalk = nHeight;
9091
while (heightWalk > height) {
9192
int heightSkip = GetSkipHeight(heightWalk);
@@ -106,9 +107,9 @@ CBlockIndex* CBlockIndex::GetAncestor(int height)
106107
return pindexWalk;
107108
}
108109

109-
const CBlockIndex* CBlockIndex::GetAncestor(int height) const
110+
CBlockIndex* CBlockIndex::GetAncestor(int height)
110111
{
111-
return const_cast<CBlockIndex*>(this)->GetAncestor(height);
112+
return const_cast<CBlockIndex*>(static_cast<const CBlockIndex*>(this)->GetAncestor(height));
112113
}
113114

114115
void CBlockIndex::BuildSkip()

src/compat/byteswap.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ inline uint16_t bswap_16(uint16_t x)
3737
{
3838
return (x >> 8) | (x << 8);
3939
}
40-
#endif // HAVE_DECL_BSWAP16
40+
#endif // HAVE_DECL_BSWAP16 == 0
4141

4242
#if HAVE_DECL_BSWAP_32 == 0
4343
inline uint32_t bswap_32(uint32_t x)
4444
{
4545
return (((x & 0xff000000U) >> 24) | ((x & 0x00ff0000U) >> 8) |
4646
((x & 0x0000ff00U) << 8) | ((x & 0x000000ffU) << 24));
4747
}
48-
#endif // HAVE_DECL_BSWAP32
48+
#endif // HAVE_DECL_BSWAP32 == 0
4949

5050
#if HAVE_DECL_BSWAP_64 == 0
5151
inline uint64_t bswap_64(uint64_t x)
@@ -59,7 +59,7 @@ inline uint64_t bswap_64(uint64_t x)
5959
| ((x & 0x000000000000ff00ull) << 40)
6060
| ((x & 0x00000000000000ffull) << 56));
6161
}
62-
#endif // HAVE_DECL_BSWAP64
62+
#endif // HAVE_DECL_BSWAP64 == 0
6363

6464
#endif // defined(__APPLE__)
6565

src/dbwrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CBitcoinLevelDBLogger : public leveldb::Logger {
6464

6565
assert(p <= limit);
6666
base[std::min(bufsize - 1, (int)(p - base))] = '\0';
67-
LogPrintStr(base);
67+
LogPrintf("leveldb: %s", base);
6868
if (base != buffer) {
6969
delete[] base;
7070
}

src/init.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ void PrepareShutdown()
243243

244244
// Because these depend on each-other, we make sure that neither can be
245245
// using the other before destroying them.
246-
UnregisterValidationInterface(peerLogic.get());
247-
if(g_connman) g_connman->Stop();
246+
if (peerLogic) UnregisterValidationInterface(peerLogic.get());
247+
if (g_connman) g_connman->Stop();
248248
peerLogic.reset();
249249
g_connman.reset();
250250

@@ -441,6 +441,7 @@ std::string HelpMessage(HelpMessageMode mode)
441441
}
442442
strUsage += HelpMessageOpt("-dbcache=<n>", strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache));
443443
strUsage += HelpMessageOpt("-loadblock=<file>", _("Imports blocks from external blk000??.dat file on startup"));
444+
strUsage += HelpMessageOpt("-debuglogfile=<file>", strprintf(_("Specify location of debug log file: this can be an absolute path or a path relative to the data directory (default: %s)"), DEFAULT_DEBUGLOGFILE));
444445
strUsage += HelpMessageOpt("-maxorphantxsize=<n>", strprintf(_("Maximum total size of all orphan transactions in megabytes (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS_SIZE));
445446
strUsage += HelpMessageOpt("-maxmempool=<n>", strprintf(_("Keep the transaction memory pool below <n> megabytes (default: %u)"), DEFAULT_MAX_MEMPOOL_SIZE));
446447
strUsage += HelpMessageOpt("-mempoolexpiry=<n>", strprintf(_("Do not keep transactions in the mempool longer than <n> hours (default: %u)"), DEFAULT_MEMPOOL_EXPIRY));
@@ -1251,11 +1252,6 @@ bool AppInitParameterInteraction()
12511252
fPruneMode = true;
12521253
}
12531254

1254-
RegisterAllCoreRPCCommands(tableRPC);
1255-
#ifdef ENABLE_WALLET
1256-
RegisterWalletRPC(tableRPC);
1257-
#endif
1258-
12591255
nConnectTimeout = gArgs.GetArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
12601256
if (nConnectTimeout <= 0)
12611257
nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
@@ -1523,8 +1519,11 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
15231519
ShrinkDebugFile();
15241520
}
15251521

1526-
if (fPrintToDebugLog)
1527-
OpenDebugLog();
1522+
if (fPrintToDebugLog) {
1523+
if (!OpenDebugLog()) {
1524+
return InitError(strprintf("Could not open debug log file %s", GetDebugLogPath().string()));
1525+
}
1526+
}
15281527

15291528
if (!fLogTimestamps)
15301529
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));
@@ -1572,6 +1571,14 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
15721571

15731572
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
15741573

1574+
/* Register RPC commands regardless of -server setting so they will be
1575+
* available in the GUI RPC console even if external calls are disabled.
1576+
*/
1577+
RegisterAllCoreRPCCommands(tableRPC);
1578+
#ifdef ENABLE_WALLET
1579+
RegisterWalletRPC(tableRPC);
1580+
#endif
1581+
15751582
/* Start the RPC server already. It will be started in "warmup" mode
15761583
* and not really process calls already (but it will signify connections
15771584
* that the server is there and will be ready later). Warmup mode will

src/net_processing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,6 +3388,7 @@ void PeerLogicValidation::ConsiderEviction(CNode *pto, int64_t time_in_seconds)
33883388
LogPrintf("Disconnecting outbound peer %d for old chain, best known block = %s\n", pto->GetId(), state.pindexBestKnownBlock != nullptr ? state.pindexBestKnownBlock->GetBlockHash().ToString() : "<none>");
33893389
pto->fDisconnect = true;
33903390
} else {
3391+
assert(state.m_chain_sync.m_work_header);
33913392
LogPrint(BCLog::NET, "sending getheaders to outbound peer=%d to verify chain work (current best known block:%s, benchmark blockhash: %s)\n", pto->GetId(), state.pindexBestKnownBlock != nullptr ? state.pindexBestKnownBlock->GetBlockHash().ToString() : "<none>", state.m_chain_sync.m_work_header->GetBlockHash().ToString());
33923393
connman->PushMessage(pto, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(state.m_chain_sync.m_work_header->pprev), uint256()));
33933394
state.m_chain_sync.m_sent_getheaders = true;

src/qt/rpcconsole.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,37 @@ void RPCExecutor::request(const QString &command)
403403
{
404404
std::string result;
405405
std::string executableCommand = command.toStdString() + "\n";
406+
407+
// Catch the console-only-help command before RPC call is executed and reply with help text as-if a RPC reply.
408+
if(executableCommand == "help-console\n")
409+
{
410+
Q_EMIT reply(RPCConsole::CMD_REPLY, QString(("\n"
411+
"This console accepts RPC commands using the standard syntax.\n"
412+
" example: getblockhash 0\n\n"
413+
414+
"This console can also accept RPC commands using parenthesized syntax.\n"
415+
" example: getblockhash(0)\n\n"
416+
417+
"Commands may be nested when specified with the parenthesized syntax.\n"
418+
" example: getblock(getblockhash(0) 1)\n\n"
419+
420+
"A space or a comma can be used to delimit arguments for either syntax.\n"
421+
" example: getblockhash 0\n"
422+
" getblockhash,0\n\n"
423+
424+
"Named results can be queried with a non-quoted key string in brackets.\n"
425+
" example: getblock(getblockhash(0) true)[tx]\n\n"
426+
427+
"Results without keys can be queried using an integer in brackets.\n"
428+
" example: getblock(getblockhash(0),true)[tx][0]\n\n")));
429+
return;
430+
}
406431
if(!RPCConsole::RPCExecuteCommandLine(result, executableCommand))
407432
{
408433
Q_EMIT reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
409434
return;
410435
}
436+
411437
Q_EMIT reply(RPCConsole::CMD_REPLY, QString::fromStdString(result));
412438
}
413439
catch (UniValue& objError)
@@ -678,6 +704,7 @@ void RPCConsole::setClientModel(ClientModel *model)
678704
wordList << ("help " + commandList[i]).c_str();
679705
}
680706

707+
wordList << "help-console";
681708
wordList.sort();
682709
autoCompleter = new QCompleter(wordList, this);
683710
autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
@@ -843,10 +870,11 @@ void RPCConsole::clear(bool clearHistory)
843870

844871
message(CMD_REPLY, (tr("Welcome to the %1 RPC console.").arg(tr(PACKAGE_NAME)) + "<br>" +
845872
tr("Use up and down arrows to navigate history, and %1 to clear screen.").arg("<b>"+clsKey+"</b>") + "<br>" +
846-
tr("Type <b>help</b> for an overview of available commands.")) +
847-
"<br><span class=\"secwarning\">" +
873+
tr("Type %1 for an overview of available commands.").arg("<b>help</b>") + "<br>" +
874+
tr("For more information on using this console type %1.").arg("<b>help-console</b>") +
875+
"<br><span class=\"secwarning\"><br>" +
848876
tr("WARNING: Scammers have been active, telling users to type commands here, stealing their wallet contents. Do not use this console without fully understanding the ramifications of a command.") +
849-
"</span>",
877+
"</span>"),
850878
true);
851879
}
852880

src/qt/transactionfilterproxy.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
2020
QSortFilterProxyModel(parent),
2121
dateFrom(MIN_DATE.toTime_t()),
2222
dateTo(MAX_DATE.toTime_t()),
23-
addrPrefix(),
23+
m_search_string(),
2424
typeFilter(COMMON_TYPES),
2525
watchOnlyFilter(WatchOnlyFilter_All),
2626
instantsendFilter(InstantSendFilter_All),
@@ -40,6 +40,7 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
4040
bool lockedByInstantSend = index.data(TransactionTableModel::InstantSendRole).toBool();
4141
QString address = index.data(TransactionTableModel::AddressRole).toString();
4242
QString label = index.data(TransactionTableModel::LabelRole).toString();
43+
QString txid = index.data(TransactionTableModel::TxIDRole).toString();
4344
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
4445
int status = index.data(TransactionTableModel::StatusRole).toInt();
4546

@@ -57,8 +58,11 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
5758
return false;
5859
if(datetime < dateFrom || datetime > dateTo)
5960
return false;
60-
if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive))
61+
if (!address.contains(m_search_string, Qt::CaseInsensitive) &&
62+
! label.contains(m_search_string, Qt::CaseInsensitive) &&
63+
! txid.contains(m_search_string, Qt::CaseInsensitive)) {
6164
return false;
65+
}
6266
if(amount < minAmount)
6367
return false;
6468

@@ -72,9 +76,10 @@ void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime
7276
invalidateFilter();
7377
}
7478

75-
void TransactionFilterProxy::setAddressPrefix(const QString &_addrPrefix)
79+
void TransactionFilterProxy::setSearchString(const QString &search_string)
7680
{
77-
this->addrPrefix = _addrPrefix;
81+
if (m_search_string == search_string) return;
82+
m_search_string = search_string;
7883
invalidateFilter();
7984
}
8085

0 commit comments

Comments
 (0)