Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2b24786
Merge #13773: wallet: Fix accidental use of the comma operator
Jul 26, 2018
5698ebb
Merge #13803: doc: add note to contributor docs about warranted PR's
Jul 30, 2018
1ecce00
Merge #13843: [trivial] Add doxygen-compatible comments to CAffectedK…
laanwj Aug 7, 2018
b04090d
Merge #13913: qa: Remove redundant checkmempool/checkblockindex extra…
Aug 11, 2018
69c601c
Merge #13939: lint: Make format string linter understand basic templa…
Aug 13, 2018
08835d3
Merge #13905: docs: fixed bitcoin-cli -help output for help2man
Aug 13, 2018
3265924
Merge #13953: fix deprecation in bitcoin-util-test.py
Aug 13, 2018
aa5e2c2
Merge #13963: tests: Replace usage of tostring() with tobytes()
laanwj Aug 14, 2018
5e0feca
Merge #13974: [trivial] Fix typo in CDiskBlockPos struct's ToString
Aug 15, 2018
a4bf001
Merge #14006: Add const modifier to HTTPRequest methods
laanwj Aug 21, 2018
32b571b
Merge #14063: Move cs_main locking annotations from .cpp to .h
Aug 26, 2018
ee68324
Merge #14069: qa: Use assert not BOOST_CHECK_* from multithreaded tests
Aug 26, 2018
6bf1fbb
Merge #14071: qa: Stop txindex thread before calling destructor
Aug 27, 2018
70519e0
Merge #14031: Make IS_TRIVIALLY_CONSTRUCTIBLE consistent on GCC < 5, …
laanwj Aug 27, 2018
5773399
Merge #14030: Remove ambiguity in construction of prevector
laanwj Aug 27, 2018
b619f99
Merge #14051: [Tests] Make combine_logs.py handle multi-line logs
laanwj Aug 28, 2018
2d91eb7
Merge #14028: Explicitly initialize prevector _union
laanwj Aug 29, 2018
12adb05
Merge #14020: Add tests for RPC help
Aug 29, 2018
2de80ac
Merge #14037: Add README.md to linux release tarballs
laanwj Aug 31, 2018
cd5a39c
Merge #14088: tests: Don't assert(...) with side effects
laanwj Aug 31, 2018
7c120a7
Merge #10605: Add AssertLockHeld assertions in CWallet::ListCoins
Aug 31, 2018
1a8f904
Merge #14135: doc: correct GetDifficulty doc after #13288
laanwj Sep 4, 2018
fa7ef87
Merge #14129: Trivial: update clang thread-safety docs url
laanwj Sep 4, 2018
f9a16ff
prevent clean / accidental merging of bitcoin#13782
PastaPastaPasta Jun 29, 2021
e01d766
fix macos compilation by including an extern to cs_main
PastaPastaPasta Jul 1, 2021
6fae032
fix rpc_help.py
PastaPastaPasta Jul 1, 2021
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
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ At this stage one should expect comments and review from other contributors. You
can add more commits to your pull request by committing them locally and pushing
to your fork until you have satisfied all feedback.

Note: Code review is a burdensome but important part of the development process, and as such, certain types of pull requests are rejected. In general, if the **improvements** do not warrant the **review effort** required, the PR has a high chance of being rejected. It is up to the PR author to convince the reviewers that the changes warrant the review effort, and if reviewers are "Concept NAK'ing" the PR, the author may need to present arguments and/or do research backing their suggested changes.

Squashing Commits
---------------------------
If your pull request is accepted for merging, you may be asked by a maintainer
Expand Down
1 change: 1 addition & 0 deletions contrib/gitian-descriptors/gitian-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ script: |
rm -rf ${DISTNAME}/lib/pkgconfig
find ${DISTNAME}/bin -type f -executable -exec ../contrib/devtools/split-debug.sh {} {} {}.dbg \;
find ${DISTNAME}/lib -type f -exec ../contrib/devtools/split-debug.sh {} {} {}.dbg \;
cp ../doc/README.md ${DISTNAME}/
find ${DISTNAME} -not -name "*.dbg" | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}.tar.gz
find ${DISTNAME} -name "*.dbg" | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}-debug.tar.gz
cd ../../
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-win-signer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ suites:
architectures:
- "amd64"
packages:
- "libssl-dev"
- "libssl-dev" # do not merge bitcoin#13782, see https://github.com/dashpay/dash/pull/3894
- "autoconf"
- "automake"
- "libtool"
Expand Down
2 changes: 1 addition & 1 deletion src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct CDiskBlockPos

std::string ToString() const
{
return strprintf("CBlockDiskPos(nFile=%i, nPos=%i)", nFile, nPos);
return strprintf("CDiskBlockPos(nFile=%i, nPos=%i)", nFile, nPos);
}

};
Expand Down
6 changes: 3 additions & 3 deletions src/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

// GCC 4.8 is missing some C++11 type_traits,
// https://www.gnu.org/software/gcc/gcc-5/changes.html
#if defined(__GNUC__) && __GNUC__ < 5
#define IS_TRIVIALLY_CONSTRUCTIBLE std::is_trivial
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
#define IS_TRIVIALLY_CONSTRUCTIBLE std::has_trivial_default_constructor
#else
#define IS_TRIVIALLY_CONSTRUCTIBLE std::is_trivially_constructible
#define IS_TRIVIALLY_CONSTRUCTIBLE std::is_trivially_default_constructible
#endif

#ifdef WIN32
Expand Down
4 changes: 2 additions & 2 deletions src/dash-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ static void SetupCliArgs()
gArgs.AddArg("-rpcuser=<user>", "Username for JSON-RPC connections", false, OptionsCategory::OPTIONS);
gArgs.AddArg("-rpcwait", "Wait for RPC server to start", false, OptionsCategory::OPTIONS);
gArgs.AddArg("-rpcwallet=<walletname>", "Send RPC for non-default wallet on RPC server (needs to exactly match corresponding -wallet option passed to bitcoind)", false, OptionsCategory::OPTIONS);
gArgs.AddArg("-stdin", "Read extra arguments from standard input, one per line until EOF/Ctrl-D (recommended for sensitive information such as passphrases). When combined with -stdinrpcpass, the first line from standard input is used for the RPC password.", false, OptionsCategory::OPTIONS);
gArgs.AddArg("-stdinrpcpass", strprintf("Read RPC password from standard input as a single line. When combined with -stdin, the first line from standard input is used for the RPC password."), false, OptionsCategory::OPTIONS);
gArgs.AddArg("-stdin", "Read extra arguments from standard input, one per line until EOF/Ctrl-D (recommended for sensitive information such as passphrases). When combined with -stdinrpcpass, the first line from standard input is used for the RPC password.", false, OptionsCategory::OPTIONS);
gArgs.AddArg("-stdinrpcpass", "Read RPC password from standard input as a single line. When combined with -stdin, the first line from standard input is used for the RPC password.", false, OptionsCategory::OPTIONS);

SetupChainParamsBaseOptions();

Expand Down
8 changes: 4 additions & 4 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ HTTPRequest::~HTTPRequest()
// evhttpd cleans up the request, as long as a reply was sent.
}

std::pair<bool, std::string> HTTPRequest::GetHeader(const std::string& hdr)
std::pair<bool, std::string> HTTPRequest::GetHeader(const std::string& hdr) const
{
const struct evkeyvalq* headers = evhttp_request_get_input_headers(req);
assert(headers);
Expand Down Expand Up @@ -608,7 +608,7 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply)
req = nullptr; // transferred back to main thread
}

CService HTTPRequest::GetPeer()
CService HTTPRequest::GetPeer() const
{
evhttp_connection* con = evhttp_request_get_connection(req);
CService peer;
Expand All @@ -622,12 +622,12 @@ CService HTTPRequest::GetPeer()
return peer;
}

std::string HTTPRequest::GetURI()
std::string HTTPRequest::GetURI() const
{
return evhttp_request_get_uri(req);
}

HTTPRequest::RequestMethod HTTPRequest::GetRequestMethod()
HTTPRequest::RequestMethod HTTPRequest::GetRequestMethod() const
{
switch (evhttp_request_get_command(req)) {
case EVHTTP_REQ_GET:
Expand Down
8 changes: 4 additions & 4 deletions src/httpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,21 @@ class HTTPRequest

/** Get requested URI.
*/
std::string GetURI();
std::string GetURI() const;

/** Get CService (address:ip) for the origin of the http request.
*/
CService GetPeer();
CService GetPeer() const;

/** Get request method.
*/
RequestMethod GetRequestMethod();
RequestMethod GetRequestMethod() const;

/**
* Get the request header specified by hdr, or an empty string.
* Return a pair (isPresent,string).
*/
std::pair<bool, std::string> GetHeader(const std::string& hdr);
std::pair<bool, std::string> GetHeader(const std::string& hdr) const;

/**
* Read request body.
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ WalletTxStatus MakeWalletTxStatus(const CWalletTx& wtx)
WalletTxStatus result;
auto mi = ::mapBlockIndex.find(wtx.hashBlock);
CBlockIndex* block = mi != ::mapBlockIndex.end() ? mi->second : nullptr;
result.block_height = (block ? block->nHeight : std::numeric_limits<int>::max()),
result.block_height = (block ? block->nHeight : std::numeric_limits<int>::max());
result.blocks_to_maturity = wtx.GetBlocksToMaturity();
result.depth_in_main_chain = wtx.GetDepthInMainChain();
result.time_received = wtx.nTimeReceived;
Expand Down
10 changes: 5 additions & 5 deletions src/prevector.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,32 +265,32 @@ class prevector {

prevector() : _size(0), _union{{}} {}

explicit prevector(size_type n) : _size(0) {
explicit prevector(size_type n) : prevector() {
resize(n);
}

explicit prevector(size_type n, const T& val = T()) : _size(0) {
explicit prevector(size_type n, const T& val) : prevector() {
change_capacity(n);
_size += n;
fill(item_ptr(0), n, val);
}

template<typename InputIterator>
prevector(InputIterator first, InputIterator last) : _size(0) {
prevector(InputIterator first, InputIterator last) : prevector() {
size_type n = last - first;
change_capacity(n);
_size += n;
fill(item_ptr(0), first, last);
}

prevector(const prevector<N, T, Size, Diff>& other) : _size(0) {
prevector(const prevector<N, T, Size, Diff>& other) : prevector() {
size_type n = other.size();
change_capacity(n);
_size += n;
fill(item_ptr(0), other.begin(), other.end());
}

prevector(prevector<N, T, Size, Diff>&& other) : _size(0) {
prevector(prevector<N, T, Size, Diff>&& other) : prevector() {
swap(other);
}

Expand Down
3 changes: 1 addition & 2 deletions src/rpc/blockchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class CBlockIndex;
class UniValue;

/**
* Get the difficulty of the net wrt to the given block index, or the chain tip if
* not provided.
* Get the difficulty of the net wrt to the given block index.
*
* @return A floating point number that is a multiple of the main net minimum
* difficulty (4295032833 hashes).
Expand Down
6 changes: 4 additions & 2 deletions src/test/scheduler_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ BOOST_AUTO_TEST_CASE(singlethreadedscheduler_ordered)
// the callbacks should run in exactly the order in which they were enqueued
for (int i = 0; i < 100; ++i) {
queue1.AddToProcessQueue([i, &counter1]() {
BOOST_CHECK_EQUAL(i, counter1++);
bool expectation = i == counter1++;
assert(expectation);
});

queue2.AddToProcessQueue([i, &counter2]() {
BOOST_CHECK_EQUAL(i, counter2++);
bool expectation = i == counter2++;
assert(expectation);
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/txindex_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
BOOST_ERROR("Read incorrect tx");
}
}

txindex.Stop(); // Stop thread before calling destructor
}

BOOST_AUTO_TEST_SUITE_END()
2 changes: 1 addition & 1 deletion src/threadsafety.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// TL;DR Add GUARDED_BY(mutex) to member variables. The others are
// rarely necessary. Ex: int nFoo GUARDED_BY(cs_foo);
//
// See http://clang.llvm.org/docs/LanguageExtensions.html#threadsafety
// See https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
// for documentation. The clang compiler can do advanced static analysis
// of locking when given the -Wthread-safety option.
#define LOCKABLE __attribute__((lockable))
Expand Down
3 changes: 2 additions & 1 deletion src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <boost/signals2/signal.hpp>

class CBlockIndex;
extern CCriticalSection cs_main;

/** Fake height value used in Coin to signify they are only in the memory pool (since 0.8) */
static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
Expand Down Expand Up @@ -580,7 +581,7 @@ class CTxMemPool
bool removeSpentIndex(const uint256 txhash);

void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN);
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
void removeProTxPubKeyConflicts(const CTransaction &tx, const CKeyID &keyId);
void removeProTxPubKeyConflicts(const CTransaction &tx, const CBLSPublicKey &pubKey);
Expand Down
16 changes: 13 additions & 3 deletions src/wallet/test/wallet_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)

// Confirm ListCoins initially returns 1 coin grouped under coinbaseKey
// address.
auto list = wallet->ListCoins();
std::map<CTxDestination, std::vector<COutput>> list;
{
LOCK2(cs_main, wallet->cs_wallet);
list = wallet->ListCoins();
}
BOOST_CHECK_EQUAL(list.size(), 1U);
BOOST_CHECK_EQUAL(boost::get<CKeyID>(list.begin()->first).ToString(), coinbaseAddress);
BOOST_CHECK_EQUAL(list.begin()->second.size(), 1U);
Expand All @@ -337,7 +341,10 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
// coinbaseKey pubkey, even though the change address has a different
// pubkey.
AddTx(CRecipient{GetScriptForRawPubKey({}), 1 * COIN, false /* subtract fee */});
list = wallet->ListCoins();
{
LOCK2(cs_main, wallet->cs_wallet);
list = wallet->ListCoins();
}
BOOST_CHECK_EQUAL(list.size(), 1U);
BOOST_CHECK_EQUAL(boost::get<CKeyID>(list.begin()->first).ToString(), coinbaseAddress);
BOOST_CHECK_EQUAL(list.begin()->second.size(), 2U);
Expand All @@ -363,7 +370,10 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
}
// Confirm ListCoins still returns same result as before, despite coins
// being locked.
list = wallet->ListCoins();
{
LOCK2(cs_main, wallet->cs_wallet);
list = wallet->ListCoins();
}
BOOST_CHECK_EQUAL(list.size(), 1U);
BOOST_CHECK_EQUAL(boost::get<CKeyID>(list.begin()->first).ToString(), coinbaseAddress);
BOOST_CHECK_EQUAL(list.begin()->second.size(), 2U);
Expand Down
23 changes: 13 additions & 10 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,25 @@ std::string COutput::ToString() const
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->tx->vout[i].nValue));
}

/** A class to identify which pubkeys a script and a keystore have in common. */
class CAffectedKeysVisitor : public boost::static_visitor<void> {
private:
const CKeyStore &keystore;
std::vector<CKeyID> &vKeys;

public:
/**
* @param[in] keystoreIn The CKeyStore that is queried for the presence of a pubkey.
* @param[out] vKeysIn A vector to which a script's pubkey identifiers are appended if they are in the keystore.
*/
CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector<CKeyID> &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {}

/**
* Apply the visitor to each destination in a script, recursively to the redeemscript
* in the case of p2sh destinations.
* @param[in] script The CScript from which destinations are extracted.
* @post Any CKeyIDs that script and keystore have in common are appended to the visitor's vKeys.
*/
void Process(const CScript &script) {
txnouttype type;
std::vector<CTxDestination> vDest;
Expand Down Expand Up @@ -2989,20 +3000,12 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe, const

std::map<CTxDestination, std::vector<COutput>> CWallet::ListCoins() const
{
// TODO: Add AssertLockHeld(cs_wallet) here.
//
// Because the return value from this function contains pointers to
// CWalletTx objects, callers to this function really should acquire the
// cs_wallet lock before calling it. However, the current caller doesn't
// acquire this lock yet. There was an attempt to add the missing lock in
// https://github.com/bitcoin/bitcoin/pull/10340, but that change has been
// postponed until after https://github.com/bitcoin/bitcoin/pull/10244 to
// avoid adding some extra complexity to the Qt code.
AssertLockHeld(cs_main);
AssertLockHeld(cs_wallet);

std::map<CTxDestination, std::vector<COutput>> result;
std::vector<COutput> availableCoins;

LOCK2(cs_main, cs_wallet);
AvailableCoins(availableCoins);

for (auto& coin : availableCoins) {
Expand Down
4 changes: 3 additions & 1 deletion src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class CWalletTx;
struct FeeCalculation;
enum class FeeEstimateMode;

extern CCriticalSection cs_main;

/** (client) version numbers for particular wallet features */
enum WalletFeature
{
Expand Down Expand Up @@ -877,7 +879,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
/**
* Return list of available coins and locked coins grouped by non-change output address.
*/
std::map<CTxDestination, std::vector<COutput>> ListCoins() const;
std::map<CTxDestination, std::vector<COutput>> ListCoins() const EXCLUSIVE_LOCKS_REQUIRED(cs_main, cs_wallet);

/**
* Find non-change parent output.
Expand Down
18 changes: 14 additions & 4 deletions test/functional/combine_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys

# Matches on the date format at the start of the log event
TIMESTAMP_PATTERN = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z")
TIMESTAMP_PATTERN = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{6})?Z")

LogEvent = namedtuple('LogEvent', ['timestamp', 'source', 'event'])

Expand Down Expand Up @@ -84,11 +84,17 @@ def get_log_events(source, logfile):
if time_match:
if event:
yield LogEvent(timestamp=timestamp, source=source, event=event.rstrip())
event = line
timestamp = time_match.group()
if time_match.group(1) is None:
# timestamp does not have microseconds. Add zeroes.
timestamp_micro = timestamp.replace("Z", ".000000Z")
line = line.replace(timestamp, timestamp_micro)
timestamp = timestamp_micro
event = line
# if it doesn't have a timestamp, it's a continuation line of the previous log.
else:
event += "\n" + line
# Add the line. Prefix with space equivalent to the source + timestamp so log lines are aligned
event += " " + line
# Flush the final event
yield LogEvent(timestamp=timestamp, source=source, event=event.rstrip())
except FileNotFoundError:
Expand All @@ -107,7 +113,11 @@ def print_logs(log_events, color=False, html=False):
colors["reset"] = "\033[0m" # Reset font color

for event in log_events:
print("{0} {1: <5} {2} {3}".format(colors[event.source.rstrip()], event.source, event.event, colors["reset"]))
lines = event.event.splitlines()
print("{0} {1: <5} {2} {3}".format(colors[event.source.rstrip()], event.source, lines[0], colors["reset"]))
if len(lines) > 1:
for line in lines[1:]:
print("{0}{1}{2}".format(colors[event.source.rstrip()], line, colors["reset"]))

else:
try:
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def reindex(self, justchainstate=False):
self.nodes[0].generate(3)
blockcount = self.nodes[0].getblockcount()
self.stop_nodes()
extra_args = [["-reindex-chainstate" if justchainstate else "-reindex", "-checkblockindex=1"]]
extra_args = [["-reindex-chainstate" if justchainstate else "-reindex"]]
self.start_nodes(extra_args)
wait_until(lambda: self.nodes[0].getblockcount() == blockcount)
self.log.info("Success")
Expand Down
1 change: 0 additions & 1 deletion test/functional/mempool_accept.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.extra_args = [[
'-checkmempool',
'-txindex',
'-reindex', # Need reindex for txindex
'-acceptnonstdtxn=0', # Try to mimic main-net
Expand Down
Loading