Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Bitcoin 0.17.1 into Unit-e, take 2 #919

Closed
wants to merge 2,187 commits into from
Closed

Conversation

cmihai
Copy link
Member

@cmihai cmihai commented Apr 9, 2019

Fixes #41. Blah blah blah, seeing if this fixes Mergeable.

This PR contains the changes from the latest Bitcoin 0.17.1, adapted for Unit-e. The branch is synced with master, up to revision 7e67c75. It compiles, launches, the unit and functional tests all work.

Here are some of the things that changed in Bitcoin 0.17, as compared to 0.16:

  • The wallet "safe mode" was removed.
  • Address "accounts" were removed from most places, and renamed to "labels" in the rest.
  • Wallets can now have status flags attached to them. Right now, the only one is WALLET_FLAG_DISABLE_PRIVATE_KEYS, but 0.18 adds another one for empty wallets.
  • 0.17 now supports partially-signed transactions.

MarcoFalke and others added 30 commits August 9, 2018 13:25
The largest sensible size for a locator is log in the number of blocks.
 But, as noted by Coinr8d on BCT a maximum size message could encode a
 hundred thousand locators.  If height were used to limit the messages
 that could open new attacks where peers on long low diff forks would
 get disconnected and end up stuck.

Ideally, nodes first first learn to limit the size of locators they
 send before limiting what would be processed, but common implementations
 back off with an exponent of 2 and have an implicit limit of 2^32
 blocks, so they already cannot produce locators over some size.

This sets the limit to an absurdly high amount of 101 in order to
 maximize compatibility with existing software.
When extra entropy is not specified by the caller, CKey::Sign will
now always create a signature that has a low R value and is at most
70 bytes. The resulting signature on the stack will be 71 bytes when
the sighash byte is included.

Using low R signatures means that the resulting DER encoded signature
will never need to have additional padding to account for high R
values.
Changes DUMMY_SIGNATURE_CREATOR to create 71 byte dummy signatures.

Update comments to reflect this change
With watching only inputs, we do not know how large the signatures
for those inputs will be as their signers may not have implemented
71 byte signatures. Thus we estimate their fees using the 72 byte
dummy signature to ensure that we pay enough fees.

This only effects fundrawtransaction when includeWatching is true.
ec749b1 Squashed 'src/leveldb/' changes from 64052c76c5..524b7e36a8 (MarcoFalke)

Pull request description:

  For review:

  ```sh
  git fetch https://github.com/bitcoin-core/leveldb
  ./test/lint/git-subtree-check.sh src/leveldb
  ```

  Closes #13860

Tree-SHA512: 9d13384fe35e7144b4a7fca57efe77b0cc5295952da4a397e4c6d8aa3f8043d5113fccedd3ae1dcaa3d2649e732e5f57a71504847946e055aa4dc8c3780e29fc
e254ff5 Introduce a maximum size for locators. (Gregory Maxwell)

Pull request description:

  The largest sensible size for a locator is log in the number of blocks.
   But, as noted by Coinr8d on BCT a maximum size message could encode a
   hundred thousand locators.  If height were used to limit the messages
   that could open new attacks where peers on long low diff forks would
   get disconnected and end up stuck.

  Ideally, nodes first first learn to limit the size of locators they
   send before limiting what would be processed, but common implementations
   back off with an exponent of 2 and have an implicit limit of 2^32
   blocks, so they already cannot produce locators over some size.

  Locators are cheap to process so allowing a few more is harmless,
   so this sets the maximum to 64-- which is enough for blockchains
   with 2^64 blocks before the get overhead starts increasing.

Tree-SHA512: da28df9c46c988980da861046c62e6e7f93d0eaab3083d32e408d1062f45c00316d5e1754127e808c1feb424fa8e00e5a91aea2cc3b80326b71c148696f7cdb3
1f87c37 Simplify comparison in rpc_blockchain.py. (Daniel Kraft)

Pull request description:

  The test for `gettxoutsetinfo` in `rpc_blockchain.py` verifies that the result is the same as before after invalidating and reconsidering a block.  The comparison has to exclude the `disk_size` field, though, as it is not deterministic.

  Instead of comparing all the other fields for equality, this change explicitly removes the `disk_size` field and then compares the full objects.  This makes the intent more explicit (compare everything except for `disk_size`, not compare just a given list of fields) and also the code simpler.

Tree-SHA512: 3c376a8836b62988fb2f0117c9ca65de64a33bf3cd4980a123de30bf5e7b7a48eda477b25e03d672ff076e205c698e83432469156caa0f0f3ebbb0480f0dd77d
227d27e Use pushKV in some new PSBT RPCs. (Daniel Kraft)

Pull request description:

  Most of the code uses `UniValue::pushKV` where appropriate, but some new RPC code related to PSBTs did not.  This fixes those places - after this change, there are no remaining source files I could find that contain `push_back(Pair(`.

Tree-SHA512: d6567cf144d05d7e42276bd66ff4cd44413328f985772d11bb9d7339d32ab7c3438d4bb0040a37e75f8d193c610b08fa971073935885e0a178546aa045daf9fa
bb5b1c0 [Docs] upgrade rescan time warning from minutes to >1 hour (Mason Simon)

Pull request description:

  When I rescanned just now it took well over an hour. The time warning "may take minutes" didn't prepare me for that.

  ```
  2018-08-08T03:10:17Z [wallet] Still rescanning. At block 174747. Progress=0.008341
  2018-08-08T03:11:17Z [wallet] Still rescanning. At block 204233. Progress=0.024533
  2018-08-08T03:12:17Z [wallet] Still rescanning. At block 221170. Progress=0.038340
  ...
  2018-08-08T04:16:17Z [wallet] Still rescanning. At block 524815. Progress=0.957105
  2018-08-08T04:17:17Z [wallet] Still rescanning. At block 528572. Progress=0.971323
  2018-08-08T04:18:17Z [wallet] Still rescanning. At block 532458. Progress=0.986824
  ```

  This is on a 4-core 4ghz system with a 7200rpm drive.

Tree-SHA512: 722ccf566bfd6a3381fa173e08849cb676fe4c1f1cb2c4b86b07df2a5dc1ca0d54797cbe8fd606cdc2c60fef2be7c98e052460decdac2132ba759cff822132e8
…_args

fa31ca0 qa: Remove redundant checkmempool/checkblockindex extra_args (MarcoFalke)

Pull request description:

  They are already enabled by default for regtest:

  https://github.com/bitcoin/bitcoin/blob/df9f71274645a917e2578c52a1c59745bce8112d/src/init.cpp#L1002-L1007

  Closes  #13912. CC #12138

Tree-SHA512: b11a3e8cc4715569f917ab89132f8c8dcae64aebcd7a34182675f86cf7f6e207e3187b7ea01a56c92c8c3af76122b6b995e84f533e134676863f8953dc1f0574
fa85c98 qa: Add p2p_invalid_locator test (MarcoFalke)

Pull request description:

  Should not be merged *before* #13907

Tree-SHA512: a67ca407854c421ed20a184d0b0dc90085aed3e3431d9652a107fa3022244767e67f67e50449b7e95721f56906836b134615875f28a21e8a012eb22cfe6a66a5
fafe73a qa: Raise feature_help timeout to 5s (MarcoFalke)
faabd7b qa: Use files for stdout/stderr to support Windows (MarcoFalke)
facb56f qa: Run gen_rpcauth with sys.executable (MarcoFalke)
fada896 qa: Close stdout and stderr file when node stops (MarcoFalke)

Pull request description:

  ### qa: Close stdout and stderr file when node stops

  Since these files are potentially deleted by the test framework for cleanup, they should be closed first. Otherwise this will lead to errors on Windows when the tests finish successfully.

  Side note: After the patch, it is no longer possible to reopen the file on Windows (see https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile)

  ### qa: Run gen_rpcauth with sys.executable

  Similar to `test_runner.py`, the `sys.executable` needs to be passed down into subprocesses to pass on native Windows. (Should have no effect on Linux)

  ###   qa: Use files for stdout/stderr to support Windows

  It seems that using PIPE is not supported on Windows. Also, it is easier to just use the files that capture the stdout and stderr within the test node class.

Tree-SHA512: ec675012b10705978606b7fcbdb287c39a8e6e3732aae2fa4041d963a3c6993c6eac6a9a3cbd5479514e7d8017fe74c12235d1ed6fed2e8af8f3c71981e91864
Removes medianfeerate result from getblockstats.
Adds feerate_percentiles which give the feerate of the 10th, 25th, 50th,
75th, and 90th percentile weight unit in the block.
…rse module

5654efb Ported usage of deprecated optparse module to argparse module (Kvaciral)

Pull request description:

  The optparse module is deprecated since Python 2,7/3.2 . Recommend usage of the argparse module which improves upon optparse.

Tree-SHA512: ffd0e3e6f3babef1675226b107eeb7a6bab6e5199de572703da9d94e1f69c70d1c9abc353e9664b40670bb4976c06964bb2606deee52f5dfcc619f336ceb8cf8
Make sure that translations are synchronized with transifex before the
branch-off point to minimize the difference and prevent duplicate work.

Tree-SHA512: 41e71eaf14094606fd90011d035c551a635d5a715f865a49841dbe2b54a76b7fbf59a7918f86e5fd80a717e2934a9613fe463391fd01848d0a01e5c4e7e7fef0
The `help2man` parses a string containing two spaces between words with an issue:
it gives out `.TP` and `.IP` commands instead of a single `.IP` command.
Removing an extra space fixes this issue.
Currently the `-help` output for the `-stdin` option looks without any issue due to eliminating
of two spaces between words by a `FormatParagraph` call for this particular case.
For consistency and preventing from future regressions extra spaces have been removed from the both lines.
The redundant `strprintf` call has been removed aswell.
18f690e wallet: shuffle coins before grouping, where warranted (Karl-Johan Alm)

Pull request description:

  Coins are randomly shuffled in coin selection to avoid unintentional privacy leaks regarding the user's coin set. For the case where a user has a lot of coins with the same destination, these will be grouped into groups of 10 *before* the shuffling.

  It is unclear whether this has any implications at all, but this PR plugs the potential issue, if there ever is one, by shuffling the coins before they are grouped.

  Issue brought up in bitcoin/bitcoin#12257 (comment)

Tree-SHA512: fb50ed4b5fc03ab4853d45b76e1c64476ad5bcd797497179bc37b9262885c974ed6811159fd8e581f1461b6cc6d0a66146f4b70a2777c0f5e818d1322e0edb89
e306be7 Use 72 byte dummy signatures when watching only inputs may be used (Andrew Chow)
48b1473 Use 71 byte signature for DUMMY_SIGNATURE_CREATOR (Andrew Chow)
18dfea0 Always create 70 byte signatures with low R values (Andrew Chow)

Pull request description:

  When creating signatures for transactions, always make one which has a 32 byte or smaller R and 32 byte or smaller S value. This results in signatures that are always less than 71 bytes (32 byte R + 32 byte S + 6 bytes DER + 1 byte sighash) with low R values. In most cases, the signature will be 71 bytes.

  Because R is not mutable in the same way that S is, a low R value can only be found by trying different nonces. RFC 6979 for deterministic nonce generation has the option to specify additional entropy, so we simply use that and add a uin32_t counter which we increment in order to try different nonces. Nonces are sill deterministically generated as the nonce used will the be the first one where the counter results in a nonce that results in a low R value. Because different nonces need to be tried, time to produce a signature does increase. On average, it takes twice as long to make a signature as two signatures need to be created, on average, to find one with a low R.

  Having a fixed size signature makes size calculations easier and also saves half a byte of transaction size, on average.

  DUMMY_SIGNATURE_CREATOR has been modified to produce 71 byte dummy signatures instead of 72 byte signatures.

Tree-SHA512: 3cd791505126ce92da7c631856a97ba0b59e87d9c132feff6e0eef1dc47768e81fbb38bfbe970371bedf9714b7f61a13a5fe9f30f962c81734092a4d19a4ef33
…te parameter syntax

4441ad6 Make format string linter understand basic template parameter syntax (practicalswift)

Pull request description:

  Make format string linter understand basic template parameter syntax.

  Fixes issue described in bitcoin/bitcoin#13705 (comment).

  Thanks to @ken2812221 for reporting!

Tree-SHA512: 8fb995bc6b29d8b9926ef5969e02cf71c494e829434fcdeb4ed5fabad5ab96e86e5b8eea705e8a416927757b4fa4e58abc0fd4f483daa58c94e2c6fdcb8ee822
…n getblockstats

4b7091a Replace median fee rate with feerate percentiles (Marcin Jachymiak)

Pull request description:

  Currently,  the `medianfeerate` statistic is calculated from the feerate of the middle transaction of a list of transactions sorted by feerate.

  This PR instead uses the value of the 50th percentile weight unit in the block, and also calculates the feerate at the 10th, 25th, 75th, and 90th percentiles.  This more accurately corresponds with what is generally meant by median feerate.

Tree-SHA512: 59255e243df90d7afbe69839408c58c9723884b8ab82c66dc24a769e89c6d539db1905374a3f025ff28272fb25a0b90e92d8101103e39a6d9c0d60423a596714
cf9ed30 qa: blocktools enforce named args for amount (MarcoFalke)

Pull request description:

  Since  #13669 changed some signatures, I think it might be worthwhile to enforce named args for primitive types such as amounts.

Tree-SHA512: 2733e7b6a20590b54bd54e81a09e3f5e2fadf4390bed594916b70729bcf485b048266012c1203369e0968032a2c6a2719107ac17ee925d8939af3df916eab1a6
869193f docs: fixed bitcoin-cli -help output for help2man (Hennadii Stepanov)

Pull request description:

  Currently `bitcon-cli -help` output forces help2man to produce `.TP` and `.IP` commands instead of a single `.IP` command for `-stdinrpcpass`  option.
  Removing an extra space fixes this issue.

  This pull request is rebased from #13879

Tree-SHA512: 1c5b25ed2ef7b7de42bc6210165bdbabe63f045699487f2db4790e0d3176f6493dfd3e8e19f4ddc38b551539465d7b41aea570f20dccbc0609f00fdfee1b5180
Pre-0.17 branch hardcoded seeds update.
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Copy link
Member

@cornelius cornelius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I scrolled through the full 86298 lines of diff and commented on what I noticed.

Overall it looks quite good. From a bird's eye view it makes all sense. 🦅

contrib/init/unit-e.init Outdated Show resolved Hide resolved
depends/description.md Outdated Show resolved Hide resolved
doc/REST-interface.md Outdated Show resolved Hide resolved
doc/bips.md Outdated Show resolved Hide resolved
doc/build-freebsd.md Outdated Show resolved Hide resolved
doc/descriptors.md Outdated Show resolved Hide resolved
doc/descriptors.md Outdated Show resolved Hide resolved
doc/descriptors.md Outdated Show resolved Hide resolved
doc/psbt.md Outdated Show resolved Hide resolved
src/miner.cpp Show resolved Hide resolved
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
@cornelius
Copy link
Member

One more thing: We need ceea2d5. That got lost somehow.

Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Copy link
Member

@thothd thothd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking to make sure we test the changes properly on the testnet before merging

cmihai and others added 9 commits April 11, 2019 10:03
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
0.17 builds on bionic, not on trusty anymore.

Signed-off-by: Cornelius Schumacher <cornelius@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Mihai Ciumeica <mihai@thirdhash.com>
Signed-off-by: Andres Correa Casablanca <andres@thirdhash.com>
@thothd thothd added this to the 0.2 milestone Apr 12, 2019
@cmihai cmihai closed this Apr 17, 2019
@cmihai cmihai deleted the merge-bitcoin-0.17-squash branch April 17, 2019 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream sync Related to upstream merges
Projects
None yet
Development

Successfully merging this pull request may close these issues.

merge with bitcoin 0.17