Skip to content

Commit 8e9bae9

Browse files
authored
Merge pull request #1858 from codablock/pr_backport_bitcoin_0.14-8
Backport missing PRs from Bitcoin 0.14 - Part 8
2 parents e8a710c + e5daae2 commit 8e9bae9

File tree

122 files changed

+3626
-1463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+3626
-1463
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ libconftest.dylib*
6262
*.o
6363
*.o-*
6464
*.patch
65-
.dash
6665
*.a
6766
*.pb.cc
6867
*.pb.h

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ script:
9494
- mkdir build && cd build
9595
- ../configure $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false)
9696
- make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false )
97+
- make distdir
9798
- export LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib
9899
- if [ "$RUN_TESTS" = "true" ]; then travis_wait 30 make $MAKEJOBS check VERBOSE=1; fi
99100
- if [ "$RUN_TESTS" = "true" ]; then qa/pull-tester/rpc-tests.py --coverage; fi

Makefile.am

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ DIST_DOCS = $(wildcard doc/*.md) $(wildcard doc/release-notes/*.md)
4343
DIST_CONTRIB = $(top_srcdir)/contrib/dash-cli.bash-completion \
4444
$(top_srcdir)/contrib/dash-tx.bash-completion \
4545
$(top_srcdir)/contrib/dashd.bash-completion \
46-
$(top_srcdir)/contrib/init \
47-
$(top_srcdir)/contrib/rpm
46+
$(top_srcdir)/contrib/init
4847

4948
BIN_CHECKS=$(top_srcdir)/contrib/devtools/symbol-check.py \
5049
$(top_srcdir)/contrib/devtools/security-check.py
@@ -112,9 +111,16 @@ osx_volname:
112111
echo $(OSX_VOLNAME) >$@
113112

114113
if BUILD_DARWIN
115-
$(OSX_DMG): $(OSX_APP_BUILT) $(OSX_PACKAGING)
114+
$(OSX_DMG): $(OSX_APP_BUILT) $(OSX_PACKAGING) $(OSX_BACKGROUND_IMAGE)
116115
$(PYTHON) $(OSX_DEPLOY_SCRIPT) $(OSX_APP) -add-qt-tr $(OSX_QT_TRANSLATIONS) -translations-dir=$(QT_TRANSLATION_DIR) -dmg -fancy $(OSX_FANCY_PLIST) -verbose 2 -volname $(OSX_VOLNAME)
117116

117+
$(OSX_BACKGROUND_IMAGE).png: contrib/macdeploy/$(OSX_BACKGROUND_SVG)
118+
sed 's/PACKAGE_NAME/$(PACKAGE_NAME)/' < "$<" | $(RSVG_CONVERT) -f png -d 36 -p 36 -o $@
119+
$(OSX_BACKGROUND_IMAGE)@2x.png: contrib/macdeploy/$(OSX_BACKGROUND_SVG)
120+
sed 's/PACKAGE_NAME/$(PACKAGE_NAME)/' < "$<" | $(RSVG_CONVERT) -f png -d 72 -p 72 -o $@
121+
$(OSX_BACKGROUND_IMAGE): $(OSX_BACKGROUND_IMAGE).png $(OSX_BACKGROUND_IMAGE)@2x.png
122+
tiffutil -cathidpicheck $^ -out $@
123+
118124
deploydir: $(OSX_DMG)
119125
else
120126
APP_DIST_DIR=$(top_builddir)/dist

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ case $host in
320320
fi
321321
fi
322322

323+
AC_PATH_PROGS([RSVG_CONVERT], [rsvg-convert rsvg],rsvg-convert)
323324
AC_CHECK_PROG([BREW],brew, brew)
324325
if test x$BREW = xbrew; then
325326
dnl These Homebrew packages may be keg-only, meaning that they won't be found
@@ -415,6 +416,8 @@ if test x$use_lcov = xyes; then
415416
AC_MSG_ERROR("lcov testing requested but genhtml not found")
416417
fi
417418
LCOV="$LCOV --gcov-tool=$GCOV"
419+
AX_CHECK_LINK_FLAG([[--coverage]], [LDFLAGS="$LDFLAGS --coverage"],
420+
[AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")])
418421
AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"],
419422
[AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")])
420423
fi
@@ -833,6 +836,13 @@ else
833836
fi
834837
fi
835838

839+
save_CXXFLAGS="${CXXFLAGS}"
840+
CXXFLAGS="${CXXFLAGS} ${CRYPTO_CFLAGS} ${SSL_CFLAGS}"
841+
AC_CHECK_DECLS([EVP_MD_CTX_new],,,[AC_INCLUDES_DEFAULT
842+
#include <openssl/x509_vfy.h>
843+
])
844+
CXXFLAGS="${save_CXXFLAGS}"
845+
836846
dnl univalue check
837847

838848
need_bundled_univalue=yes

contrib/debian/examples/dash.conf

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,30 @@
6767
# This option can be specified multiple times (default: bind to all interfaces)
6868
#rpcbind=<addr>
6969

70-
# You must set rpcuser and rpcpassword to secure the JSON-RPC api
70+
# If no rpcpassword is set, rpc cookie auth is sought. The default `-rpccookiefile` name
71+
# is .cookie and found in the `-datadir` being used for dashd. This option is typically used
72+
# when the server and client are run as the same user.
73+
#
74+
# If not, you must set rpcuser and rpcpassword to secure the JSON-RPC api. The first
75+
# method(DEPRECATED) is to set this pair for the server and client:
7176
#rpcuser=Ulysseys
7277
#rpcpassword=YourSuperGreatPasswordNumber_DO_NOT_USE_THIS_OR_YOU_WILL_GET_ROBBED_385593
78+
#
79+
# The second method `rpcauth` can be added to server startup argument. It is set at intialization time
80+
# using the output from the script in share/rpcuser/rpcuser.py after providing a username:
81+
#
82+
# ./share/rpcuser/rpcuser.py alice
83+
# String to be appended to dash.conf:
84+
# rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc02b724e5d095828e0bc8b2456e9ac8757ae3211a5d9b16a22ae
85+
# Your password:
86+
# DONT_USE_THIS_YOU_WILL_GET_ROBBED_8ak1gI25KFTvjovL3gAM967mies3E=
87+
#
88+
# On client-side, you add the normal user/password pair to send commands:
89+
#rpcuser=alice
90+
#rpcpassword=DONT_USE_THIS_YOU_WILL_GET_ROBBED_8ak1gI25KFTvjovL3gAM967mies3E=
91+
#
92+
# You can even add multiple entries of these to the server conf file, and client can use any of them:
93+
# rpcauth=bob:b2dd077cb54591a2f3139e69a897ac$4e71f08d48b4347cf8eff3815c0e25ae2e9a4340474079f55705f40574f4ec99
7394

7495
# How many seconds Dash Core will wait for a complete RPC HTTP request.
7596
# after the HTTP connection is established.

contrib/linearize/README.md

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Linearize
2-
Construct a linear, no-fork, best version of the blockchain.
2+
Construct a linear, no-fork, best version of the Dash blockchain. The scripts
3+
run using Python 3 but are compatible with Python 2.
34

45
## Step 0: Install dash_hash
56

@@ -10,27 +11,42 @@ https://github.com/dashpay/dash_hash
1011
$ ./linearize-hashes.py linearize.cfg > hashlist.txt
1112

1213
Required configuration file settings for linearize-hashes:
13-
* RPC: rpcuser, rpcpassword
14+
* RPC: `rpcuser`, `rpcpassword`
1415

1516
Optional config file setting for linearize-hashes:
16-
* RPC: host, port
17-
* Block chain: min_height, max_height
17+
* RPC: `host` (Default: `127.0.0.1`)
18+
* RPC: `port` (Default: `9998`)
19+
* Blockchain: `min_height`, `max_height`
20+
* `rev_hash_bytes`: If true, the written block hash list will be
21+
byte-reversed. (In other words, the hash returned by getblockhash will have its
22+
bytes reversed.) False by default. Intended for generation of
23+
standalone hash lists but safe to use with linearize-data.py, which will output
24+
the same data no matter which byte format is chosen.
25+
26+
The `linearize-hashes` script requires a connection, local or remote, to a
27+
JSON-RPC server. Running `dashd` or `dash-qt -server` will be sufficient.
1828

1929
## Step 2: Copy local block data
2030

2131
$ ./linearize-data.py linearize.cfg
2232

2333
Required configuration file settings:
24-
* "input": bitcoind blocks/ directory containing blkNNNNN.dat
25-
* "hashlist": text file containing list of block hashes, linearized-hashes.py
26-
output.
27-
* "output_file" for bootstrap.dat or "output" for output directory for linearized blocks/blkNNNNN.dat output
34+
* `output_file`: The file that will contain the final blockchain.
35+
or
36+
* `output`: Output directory for linearized `blocks/blkNNNNN.dat` output.
2837

2938
Optional config file setting for linearize-data:
30-
* "netmagic": network magic number (default is 'cee2caff', testnet)
31-
* "genesis": genesis block hash (default is '00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c', testnet)
32-
* "max_out_sz": maximum output file size (default 100 \* 1000 \* 1000)
33-
* "split_timestamp": Split files when a new month is first seen, in addition to
34-
reaching a maximum file size.
35-
* "file_timestamp": Set each file's last-modified time to that of the
36-
most recent block in that file.
39+
* `file_timestamp`: Set each file's last-modified time to that of the most
40+
recent block in that file.
41+
* `genesis`: The hash of the genesis block in the blockchain. (default is '00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6', mainnet)
42+
* `input`: dashd blocks/ directory containing blkNNNNN.dat
43+
* `hashlist`: text file containing list of block hashes created by
44+
linearize-hashes.py.
45+
* `max_out_sz`: Maximum size for files created by the `output_file` option.
46+
(Default: `1000*1000*1000 bytes`)
47+
* `netmagic`: Network magic number. (default is 'bf0c6bbd', mainnet)
48+
* `rev_hash_bytes`: If true, the block hash list written by linearize-hashes.py
49+
will be byte-reversed when read by linearize-data.py. See the linearize-hashes
50+
entry for more information.
51+
* `split_timestamp`: Split blockchain files when a new month is first seen, in
52+
addition to reaching a maximum file size (`max_out_sz`).

contrib/linearize/example-linearize.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ netmagic=bf0c6bbd
1313
input=/home/example/.dashcore/blocks
1414
output_file=/home/example/Downloads/bootstrap.dat
1515
hashlist=hashlist.txt
16-
split_year=1
1716
genesis=00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6
1817

1918
# Maxmimum size in bytes of out-of-order blocks cache in memory
2019
out_of_order_cache_sz = 10000000
20+
21+
# Do we want the reverse the hash bytes coming from getblockhash?
22+
rev_hash_bytes = False

contrib/linearize/linearize-data.py

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
#
33
# linearize-data.py: Construct a linear, no-fork version of the chain.
44
#
@@ -8,24 +8,34 @@
88
#
99

1010
from __future__ import print_function, division
11+
try: # Python 3
12+
import http.client as httplib
13+
except ImportError: # Python 2
14+
import httplib
1115
import json
1216
import struct
1317
import re
1418
import os
1519
import os.path
1620
import base64
17-
import httplib
1821
import sys
1922
import hashlib
2023
import dash_hash
2124
import datetime
2225
import time
2326
from collections import namedtuple
27+
from binascii import hexlify, unhexlify
2428

2529
settings = {}
2630

31+
##### Switch endian-ness #####
32+
def hex_switchEndian(s):
33+
""" Switches the endianness of a hex string (in pairs of hex chars) """
34+
pairList = [s[i:i+2].encode() for i in range(0, len(s), 2)]
35+
return b''.join(pairList[::-1]).decode()
36+
2737
def uint32(x):
28-
return x & 0xffffffffL
38+
return x & 0xffffffff
2939

3040
def bytereverse(x):
3141
return uint32(( ((x) << 24) | (((x) << 8) & 0x00ff0000) |
@@ -36,14 +46,14 @@ def bufreverse(in_buf):
3646
for i in range(0, len(in_buf), 4):
3747
word = struct.unpack('@I', in_buf[i:i+4])[0]
3848
out_words.append(struct.pack('@I', bytereverse(word)))
39-
return ''.join(out_words)
49+
return b''.join(out_words)
4050

4151
def wordreverse(in_buf):
4252
out_words = []
4353
for i in range(0, len(in_buf), 4):
4454
out_words.append(in_buf[i:i+4])
4555
out_words.reverse()
46-
return ''.join(out_words)
56+
return b''.join(out_words)
4757

4858
def calc_hdr_hash(blk_hdr):
4959
#hash1 = hashlib.sha256()
@@ -62,7 +72,7 @@ def calc_hash_str(blk_hdr):
6272
hash = calc_hdr_hash(blk_hdr)
6373
hash = bufreverse(hash)
6474
hash = wordreverse(hash)
65-
hash_str = hash.encode('hex')
75+
hash_str = hexlify(hash).decode('utf-8')
6676
return hash_str
6777

6878
def get_blk_dt(blk_hdr):
@@ -72,17 +82,21 @@ def get_blk_dt(blk_hdr):
7282
dt_ym = datetime.datetime(dt.year, dt.month, 1)
7383
return (dt_ym, nTime)
7484

85+
# When getting the list of block hashes, undo any byte reversals.
7586
def get_block_hashes(settings):
7687
blkindex = []
7788
f = open(settings['hashlist'], "r")
7889
for line in f:
7990
line = line.rstrip()
91+
if settings['rev_hash_bytes'] == 'true':
92+
line = hex_switchEndian(line)
8093
blkindex.append(line)
8194

8295
print("Read " + str(len(blkindex)) + " hashes")
8396

8497
return blkindex
8598

99+
# The block map shouldn't give or receive byte-reversed hashes.
86100
def mkblockmap(blkindex):
87101
blkmap = {}
88102
for height,hash in enumerate(blkindex):
@@ -210,7 +224,7 @@ def run(self):
210224

211225
inMagic = inhdr[:4]
212226
if (inMagic != self.settings['netmagic']):
213-
print("Invalid magic: " + inMagic.encode('hex'))
227+
print("Invalid magic: " + hexlify(inMagic).decode('utf-8'))
214228
return
215229
inLenLE = inhdr[4:]
216230
su = struct.unpack("<I", inLenLE)
@@ -268,10 +282,16 @@ def run(self):
268282
settings[m.group(1)] = m.group(2)
269283
f.close()
270284

285+
# Force hash byte format setting to be lowercase to make comparisons easier.
286+
# Also place upfront in case any settings need to know about it.
287+
if 'rev_hash_bytes' not in settings:
288+
settings['rev_hash_bytes'] = 'false'
289+
settings['rev_hash_bytes'] = settings['rev_hash_bytes'].lower()
290+
271291
if 'netmagic' not in settings:
272-
settings['netmagic'] = 'cee2caff'
292+
settings['netmagic'] = 'bf0c6bbd'
273293
if 'genesis' not in settings:
274-
settings['genesis'] = '00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c'
294+
settings['genesis'] = '00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6'
275295
if 'input' not in settings:
276296
settings['input'] = 'input'
277297
if 'hashlist' not in settings:
@@ -281,14 +301,14 @@ def run(self):
281301
if 'split_timestamp' not in settings:
282302
settings['split_timestamp'] = 0
283303
if 'max_out_sz' not in settings:
284-
settings['max_out_sz'] = 1000L * 1000 * 1000
304+
settings['max_out_sz'] = 1000 * 1000 * 1000
285305
if 'out_of_order_cache_sz' not in settings:
286306
settings['out_of_order_cache_sz'] = 100 * 1000 * 1000
287307

288-
settings['max_out_sz'] = long(settings['max_out_sz'])
308+
settings['max_out_sz'] = int(settings['max_out_sz'])
289309
settings['split_timestamp'] = int(settings['split_timestamp'])
290310
settings['file_timestamp'] = int(settings['file_timestamp'])
291-
settings['netmagic'] = settings['netmagic'].decode('hex')
311+
settings['netmagic'] = unhexlify(settings['netmagic'].encode('utf-8'))
292312
settings['out_of_order_cache_sz'] = int(settings['out_of_order_cache_sz'])
293313

294314
if 'output_file' not in settings and 'output' not in settings:
@@ -298,8 +318,8 @@ def run(self):
298318
blkindex = get_block_hashes(settings)
299319
blkmap = mkblockmap(blkindex)
300320

321+
# Block hash map won't be byte-reversed. Neither should the genesis hash.
301322
if not settings['genesis'] in blkmap:
302323
print("Genesis block not found in hashlist")
303324
else:
304325
BlockDataCopier(settings, blkindex, blkmap).run()
305-

0 commit comments

Comments
 (0)