Skip to content

Commit

Permalink
Merge #9264: 0.13.2 backports
Browse files Browse the repository at this point in the history
f26dab7 Adapt ZMQ/rest serialization to take rpcserialversion arg (instagibbs)
21ccb9f Add option to return non-segwit serialization via rpc (Gregory Sanders)
a710a43 Improvement of documentation of command line parameter 'whitelist' (wodry)
58eab24 [qa] rpc-tests: Apply random offset to portseed (MarcoFalke)
ecd7db5 [qa] test_framework: Exit when tmpdir exists (MarcoFalke)
387ec9d Add script tests for FindAndDelete in pre-segwit and segwit scripts (Johnson Lau)
87fbced Change all instance of 'GMT epoch' to 'Unix epoch' (matthias)
b1e978c instance of 'mem pool' to 'mempool' (S. Matthew English)
ff55a2d Update gitian signing key of jl2012 (Johnson Lau)
28d0f22 Fix calculation of number of bound sockets to use (Matt Corallo)
396c405 Include select.h when WIN32 is not defined (Ivo van der Sangen)
eebc699 bench: Fix subtle counting issue when rescaling iteration count (Wladimir J. van der Laan)
0c09d9f Send tip change notification from invalidateblock (Russell Yanofsky)
6f7841c qt: Avoid OpenSSL certstore-related memory leak (Wladimir J. van der Laan)
e5ad693 qt: Avoid shutdownwindow-related memory leak (Wladimir J. van der Laan)
e4bea4f qt: Avoid splash-screen related memory leak (Wladimir J. van der Laan)
c12f4e9 qt: Prevent thread/memory leak on exiting RPCConsole (Wladimir J. van der Laan)
dc46b10 qt: Plug many memory leaks (Wladimir J. van der Laan)
ff423cc [Qt] Clean up and fix coincontrol tree widget handling (Wladimir J. van der Laan)
6d70a73 [Qt] fix coincontrol sort issue (Jonas Schnelli)
3fffbf7 Doxygen: Set PROJECT_NAME = "Bitcoin Core" (MarcoFalke)
f82c81b fix getnettotals RPC description about timemillis. (Masahiko Hyuga)
6fe3981 net: don't send feefilter messages before the version handshake is complete (Cory Fields)
5f3a12c qt: Use correct conversion function for boost::path datadir (Wladimir J. van der Laan)
08d1c90 Missed one "return false" in recent refactoring in #9067 (UdjinM6)
f27596a Every main()/exit() should return/use one of EXIT_ codes instead of magic numbers (UdjinM6)
f85ee01 Fix exit codes: - `--help`, `--version` etc should exit with `0` i.e. no error ("not enough args" case should still trigger an error) - error reading config file should exit with `1` (UdjinM6)
5bcb05d [rpc] ParseHash: Fail when length is not 64 (MarcoFalke)
973ca1e Fix doxygen comment: the transaction is returned in txOut (Pavel Janík)
6f86b53 [Qt] make warnings label selectable (Jonas Schnelli)
106da69 Sync bitcoin-tx with tx version policy (BtcDrak)
12428b4 add software-properties-common (Steven)
40169dc Set minimum required Boost to 1.47.0 (fanquake)
c134d92 [build-aux] Boost_Base serial 27 (fanquake)
4a974b2 Simple Update to File 'bitcoin-qt.desktop' (matthias)
975ab12 Update INSTALL landing redirection notice for build instructions. (randy-waterhouse)
3a3bcbf Use RelevantServices instead of node_network in AttemptToEvict. (Gregory Maxwell)
ca1fd75 Make orphan parent fetching ask for witnesses. (Gregory Maxwell)
b96a8f7 [qa] Test getblocktemplate default_witness_commitment (Suhas Daftuar)
99477c7 Always add default_witness_commitment with GBT client support (Pieter Wuille)
da5a16b Always drop the least preferred HB peer when adding a new one. (Gregory Maxwell)
094848b log block size and weight correctly. (jnewbery)
d1b4da9 build: fix qt5.7 build under macOS (Cory Fields)
  • Loading branch information
laanwj committed Dec 14, 2016
2 parents e591c10 + f26dab7 commit 423659c
Show file tree
Hide file tree
Showing 63 changed files with 670 additions and 344 deletions.
5 changes: 0 additions & 5 deletions INSTALL

This file was deleted.

5 changes: 5 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Building Bitcoin
================

See doc/build-*.md for instructions on building the various
elements of the Bitcoin Core reference implementation of Bitcoin.
4 changes: 2 additions & 2 deletions build-aux/m4/ax_boost_base.m4
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 26
#serial 27

AC_DEFUN([AX_BOOST_BASE],
[
Expand Down Expand Up @@ -96,7 +96,7 @@ if test "x$want_boost" = "xyes"; then
libsubdirs="lib64 libx32 lib lib64"
;;
ppc64|s390x|sparc64|aarch64|ppc64le)
libsubdirs="lib64 lib lib64 ppc64le"
libsubdirs="lib64 lib lib64"
;;
esac
Expand Down
15 changes: 13 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ else
CXXFLAGS_overridden=no
fi
AC_PROG_CXX
m4_ifdef([AC_PROG_OBJCXX],[AC_PROG_OBJCXX])

dnl By default, libtool for mingw refuses to link static libs into a dll for
dnl fear of mixing pic/non-pic objects, and import/export complications. Since
Expand All @@ -60,6 +59,15 @@ AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
dnl Check if -latomic is required for <std::atomic>
CHECK_ATOMIC

dnl Unless the user specified OBJCXX, force it to be the same as CXX. This ensures
dnl that we get the same -std flags for both.
m4_ifdef([AC_PROG_OBJCXX],[
if test "x${OBJCXX+set}" = "x"; then
OBJCXX="${CXX}"
fi
AC_PROG_OBJCXX
])

dnl Libtool init checks.
LT_INIT([pic-only])

Expand Down Expand Up @@ -607,8 +615,11 @@ fi

if test x$use_boost = xyes; then

dnl Minimum required Boost version
define(MINIMUM_REQUIRED_BOOST, 1.47.0)

dnl Check for boost libs
AX_BOOST_BASE
AX_BOOST_BASE([MINIMUM_REQUIRED_BOOST])
AX_BOOST_SYSTEM
AX_BOOST_FILESYSTEM
AX_BOOST_PROGRAM_OPTIONS
Expand Down
5 changes: 3 additions & 2 deletions contrib/debian/bitcoin-qt.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[Desktop Entry]
Encoding=UTF-8
Name=Bitcoin
Comment=Bitcoin P2P Cryptocurrency
Name=Bitcoin Core
Comment=Connect to the Bitcoin P2P Network
Comment[de]=Verbinde mit dem Bitcoin peer-to-peer Netzwerk
Comment[fr]=Bitcoin, monnaie virtuelle cryptographique pair à pair
Comment[tr]=Bitcoin, eşten eşe kriptografik sanal para birimi
Exec=bitcoin-qt %u
Expand Down
374 changes: 272 additions & 102 deletions contrib/gitian-keys/jl2012-key.pgp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DOXYFILE_ENCODING = UTF-8
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.

PROJECT_NAME = Bitcoin
PROJECT_NAME = "Bitcoin Core"

# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
Expand Down
1 change: 1 addition & 0 deletions doc/build-unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ install necessary parts of boost:
BerkeleyDB is required for the wallet. db4.8 packages are available [here](https://launchpad.net/~bitcoin/+archive/bitcoin).
You can add the repository and install using the following commands:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install libdb4.8-dev libdb4.8++-dev
Expand Down
6 changes: 5 additions & 1 deletion qa/pull-tester/rpc-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,18 @@ def __init__(self, num_tests_parallel, test_list=None, flags=None):
self.test_list = test_list
self.flags = flags
self.num_running = 0
# In case there is a graveyard of zombie bitcoinds, we can apply a
# pseudorandom offset to hopefully jump over them.
# (625 is PORT_RANGE/MAX_NODES)
self.portseed_offset = int(time.time() * 1000) % 625
self.jobs = []

def get_next(self):
while self.num_running < self.num_jobs and self.test_list:
# Add tests
self.num_running += 1
t = self.test_list.pop(0)
port_seed = ["--portseed=%s" % len(self.test_list)]
port_seed = ["--portseed={}".format(len(self.test_list) + self.portseed_offset)]
log_stdout = tempfile.SpooledTemporaryFile(max_size=2**16)
log_stderr = tempfile.SpooledTemporaryFile(max_size=2**16)
self.jobs.append((t,
Expand Down
70 changes: 47 additions & 23 deletions qa/rpc-tests/p2p-segwit.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,16 @@ class SegWitTest(BitcoinTestFramework):
def setup_chain(self):
initialize_chain_clean(self.options.tmpdir, 3)

def add_options(self, parser):
parser.add_option("--oldbinary", dest="oldbinary",
default=None,
help="pre-segwit bitcoind binary for upgrade testing")

def setup_network(self):
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug", "-logtimemicros=1", "-whitelist=127.0.0.1"]))
# Start a node for testing IsStandard rules.
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug", "-logtimemicros=1", "-whitelist=127.0.0.1", "-acceptnonstdtxn=0"]))
connect_nodes(self.nodes[0], 1)

# If an old bitcoind is given, do the upgrade-after-activation test.
self.test_upgrade = False
if (self.options.oldbinary != None):
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug", "-whitelist=127.0.0.1"], binary=self.options.oldbinary))
connect_nodes(self.nodes[0], 2)
self.test_upgrade = True
# Disable segwit's bip9 parameter to simulate upgrading after activation.
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug", "-whitelist=127.0.0.1", "-bip9params=segwit:0:0"]))
connect_nodes(self.nodes[0], 2)

''' Helpers '''
# Build a block on top of node0's tip.
Expand Down Expand Up @@ -1164,7 +1156,7 @@ def test_standardness_v0(self, segwit_activated):
if segwit_activated:
# tx and tx2 were both accepted. Don't bother trying to reclaim the
# P2PKH output; just send tx's first output back to an anyone-can-spend.
sync_mempools(self.nodes)
sync_mempools([self.nodes[0], self.nodes[1]])
tx3.vin = [CTxIn(COutPoint(tx.sha256, 0), b"")]
tx3.vout = [CTxOut(tx.vout[0].nValue-1000, CScript([OP_TRUE]))]
tx3.wit.vtxinwit.append(CTxInWitness())
Expand Down Expand Up @@ -1693,19 +1685,53 @@ def test_witness_sigops(self):

def test_getblocktemplate_before_lockin(self):
print("\tTesting getblocktemplate setting of segwit versionbit (before lockin)")
block_version = (self.nodes[0].getblocktemplate())['version']
assert_equal(block_version & (1 << VB_WITNESS_BIT), 0)
# Node0 is segwit aware, node2 is not.
for node in [self.nodes[0], self.nodes[2]]:
gbt_results = node.getblocktemplate()
block_version = gbt_results['version']
# If we're not indicating segwit support, we should not be signalling
# for segwit activation, nor should we get a witness commitment.
assert_equal(block_version & (1 << VB_WITNESS_BIT), 0)
assert('default_witness_commitment' not in gbt_results)

# Workaround:
# Can either change the tip, or change the mempool and wait 5 seconds
# to trigger a recomputation of getblocktemplate.
self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
txid = int(self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1), 16)
# Using mocktime lets us avoid sleep()
sync_mempools(self.nodes)
self.nodes[0].setmocktime(int(time.time())+10)

block_version = self.nodes[0].getblocktemplate({"rules" : ["segwit"]})['version']
assert(block_version & (1 << VB_WITNESS_BIT) != 0)
self.nodes[0].setmocktime(0) # undo mocktime
self.nodes[2].setmocktime(int(time.time())+10)

for node in [self.nodes[0], self.nodes[2]]:
gbt_results = node.getblocktemplate({"rules" : ["segwit"]})
block_version = gbt_results['version']
if node == self.nodes[2]:
# If this is a non-segwit node, we should still not get a witness
# commitment, nor a version bit signalling segwit.
assert_equal(block_version & (1 << VB_WITNESS_BIT), 0)
assert('default_witness_commitment' not in gbt_results)
else:
# For segwit-aware nodes, check the version bit and the witness
# commitment are correct.
assert(block_version & (1 << VB_WITNESS_BIT) != 0)
assert('default_witness_commitment' in gbt_results)
witness_commitment = gbt_results['default_witness_commitment']

# TODO: this duplicates some code from blocktools.py, would be nice
# to refactor.
# Check that default_witness_commitment is present.
block = CBlock()
witness_root = block.get_merkle_root([ser_uint256(0), ser_uint256(txid)])
check_commitment = uint256_from_str(hash256(ser_uint256(witness_root)+ser_uint256(0)))
from test_framework.blocktools import WITNESS_COMMITMENT_HEADER
output_data = WITNESS_COMMITMENT_HEADER + ser_uint256(check_commitment)
script = CScript([OP_RETURN, output_data])
assert_equal(witness_commitment, bytes_to_hex_str(script))

# undo mocktime
self.nodes[0].setmocktime(0)
self.nodes[2].setmocktime(0)

# Uncompressed pubkeys are no longer supported in default relay policy,
# but (for now) are still valid in blocks.
Expand Down Expand Up @@ -1945,6 +1971,7 @@ def run_test(self):

# Advance to segwit being 'started'
self.advance_to_segwit_started()
sync_blocks(self.nodes)
self.test_getblocktemplate_before_lockin()

sync_blocks(self.nodes)
Expand Down Expand Up @@ -1987,10 +2014,7 @@ def run_test(self):
self.test_signature_version_1()
self.test_non_standard_witness()
sync_blocks(self.nodes)
if self.test_upgrade:
self.test_upgrade_after_activation(self.nodes[2], 2)
else:
print("\tSkipping upgrade-after-activation test (use --oldbinary to enable)")
self.test_upgrade_after_activation(self.nodes[2], 2)
self.test_witness_sigops()


Expand Down
20 changes: 17 additions & 3 deletions qa/rpc-tests/segwit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from test_framework.address import script_to_p2sh, key_to_p2pkh
from test_framework.script import CScript, OP_HASH160, OP_CHECKSIG, OP_0, hash160, OP_EQUAL, OP_DUP, OP_EQUALVERIFY, OP_1, OP_2, OP_CHECKMULTISIG
from io import BytesIO
from test_framework.mininode import FromHex

NODE_0 = 0
NODE_1 = 1
Expand Down Expand Up @@ -83,8 +84,8 @@ def setup_chain(self):

def setup_network(self):
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, ["-logtimemicros", "-debug", "-walletprematurewitness"]))
self.nodes.append(start_node(1, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness"]))
self.nodes.append(start_node(0, self.options.tmpdir, ["-logtimemicros", "-debug", "-walletprematurewitness", "-rpcserialversion=0"]))
self.nodes.append(start_node(1, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-rpcserialversion=2"]))
self.nodes.append(start_node(2, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness"]))
connect_nodes(self.nodes[1], 0)
connect_nodes(self.nodes[2], 1)
Expand Down Expand Up @@ -210,7 +211,20 @@ def run_test(self):
block = self.nodes[2].generate(1) #block 432 (first block with new rules; 432 = 144 * 3)
sync_blocks(self.nodes)
assert_equal(len(self.nodes[2].getrawmempool()), 0)
assert_equal(len(self.nodes[2].getblock(block[0])["tx"]), 5)
segwit_tx_list = self.nodes[2].getblock(block[0])["tx"]
assert_equal(len(segwit_tx_list), 5)

print("Verify block and transaction serialization rpcs return differing serializations depending on rpc serialization flag")
# Note: node1 has version 2, which is simply >0 and will catch future upgrades in tests
assert(self.nodes[2].getblock(block[0], False) != self.nodes[0].getblock(block[0], False))
assert(self.nodes[1].getblock(block[0], False) == self.nodes[2].getblock(block[0], False))
for i in range(len(segwit_tx_list)):
tx = FromHex(CTransaction(), self.nodes[2].gettransaction(segwit_tx_list[i])["hex"])
assert(self.nodes[2].getrawtransaction(segwit_tx_list[i]) != self.nodes[0].getrawtransaction(segwit_tx_list[i]))
assert(self.nodes[1].getrawtransaction(segwit_tx_list[i], 0) == self.nodes[2].getrawtransaction(segwit_tx_list[i]))
assert(self.nodes[0].getrawtransaction(segwit_tx_list[i]) != self.nodes[2].gettransaction(segwit_tx_list[i])["hex"])
assert(self.nodes[1].getrawtransaction(segwit_tx_list[i]) == self.nodes[2].gettransaction(segwit_tx_list[i])["hex"])
assert(self.nodes[0].getrawtransaction(segwit_tx_list[i]) == bytes_to_hex_str(tx.serialize_without_witness()))

print("Verify witness txs without witness data are invalid after the fork")
self.fail_mine(self.nodes[2], wit_ids[NODE_2][WIT_V0][2], False)
Expand Down
7 changes: 1 addition & 6 deletions qa/rpc-tests/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,11 @@ def main(self):

success = False
try:
if not os.path.isdir(self.options.tmpdir):
os.makedirs(self.options.tmpdir)
os.makedirs(self.options.tmpdir, exist_ok=False)
self.setup_chain()

self.setup_network()

self.run_test()

success = True

except JSONRPCException as e:
print("JSONRPC error: "+e.error['message'])
traceback.print_tb(sys.exc_info()[2])
Expand Down
7 changes: 5 additions & 2 deletions src/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ bool State::KeepRunning()
return true;
}
if (elapsed*16 < maxElapsed) {
countMask = ((countMask<<1)|1) & ((1LL<<60)-1);
countMaskInv = 1./(countMask+1);
uint64_t newCountMask = ((countMask<<1)|1) & ((1LL<<60)-1);
if ((count & newCountMask)==0) {
countMask = newCountMask;
countMaskInv = 1./(countMask+1);
}
}
}
lastTime = now;
Expand Down
28 changes: 19 additions & 9 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using namespace std;

static const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900;
static const int CONTINUE_EXECUTION=-1;

std::string HelpMessageCli()
{
Expand Down Expand Up @@ -67,7 +68,11 @@ class CConnectionFailed : public std::runtime_error

};

static bool AppInitRPC(int argc, char* argv[])
//
// This function returns either one of EXIT_ codes when it's expected to stop the process or
// CONTINUE_EXECUTION when it's expected to continue further.
//
static int AppInitRPC(int argc, char* argv[])
{
//
// Parameters
Expand All @@ -85,31 +90,35 @@ static bool AppInitRPC(int argc, char* argv[])
}

fprintf(stdout, "%s", strUsage.c_str());
return false;
if (argc < 2) {
fprintf(stderr, "Error: too few parameters\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
if (!boost::filesystem::is_directory(GetDataDir(false))) {
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
return false;
return EXIT_FAILURE;
}
try {
ReadConfigFile(mapArgs, mapMultiArgs);
} catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false;
return EXIT_FAILURE;
}
// Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause)
try {
SelectBaseParams(ChainNameFromCommandLine());
} catch (const std::exception& e) {
fprintf(stderr, "Error: %s\n", e.what());
return false;
return EXIT_FAILURE;
}
if (GetBoolArg("-rpcssl", false))
{
fprintf(stderr, "Error: SSL mode for RPC (-rpcssl) is no longer supported.\n");
return false;
return EXIT_FAILURE;
}
return true;
return CONTINUE_EXECUTION;
}


Expand Down Expand Up @@ -318,8 +327,9 @@ int main(int argc, char* argv[])
}

try {
if(!AppInitRPC(argc, argv))
return EXIT_FAILURE;
int ret = AppInitRPC(argc, argv);
if (ret != CONTINUE_EXECUTION)
return ret;
}
catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInitRPC()");
Expand Down
Loading

0 comments on commit 423659c

Please sign in to comment.