Commit graph

20612 commits

Author SHA1 Message Date
MeshCollider
c3ef63a52f Show loaded wallets as disabled in open menu instead of nothing 2019-05-08 23:54:25 +12:00
practicalswift
62d50ef308 Add LOCKS_EXCLUDED(cs_main) to LimitValidationInterfaceQueue(...) which does AssertLockNotHeld(cs_main)
Add LOCKS_EXCLUDED(cs_main) to functions calling LimitValidationInterfaceQueue(...) which does AssertLockNotHeld(cs_main)

Add LOCKS_EXCLUDED(cs_main) to functions calling CChainState::InvalidateBlock(...) which calls LimitValidationInterfaceQueue(...) which in turn does AssertLockNotHeld(cs_main)

Add LOCKS_EXCLUDED(cs_main) to functions calling CChainState::RewindBlockIndex(...) which calls LimitValidationInterfaceQueue(...) which in turn does AssertLockNotHeld(cs_main)
2019-05-08 10:31:54 +02:00
Carl Dong
a3592c91a2 .gitignore: Don't ignore depends patches 2019-05-07 21:33:54 -04:00
Russell Yanofsky
f6bb11fd37 Add test for ArgsManager::GetChainName
There was some test coverage previously, but it was limited and didn't test
conflicting and negated arguments.
2019-05-07 11:51:30 -04:00
MarcoFalke
b2a6b02161
Merge #15948: refactor: rename chainActive
486c1eea86 refactoring: remove unused chainActive (James O'Beirne)
631940aab2 scripted-diff: replace chainActive -> ::ChainActive() (James O'Beirne)
a3a609079c refactoring: introduce unused ChainActive() (James O'Beirne)
1b6e6fcfd2 rename: CChainState.chainActive -> m_chain (James O'Beirne)

Pull request description:

  This is part of the assumeutxo project:

  Parent PR: #15606
  Issue: #15605
  Specification: https://github.com/jamesob/assumeutxo-docs/tree/2019-04-proposal/proposal

  ---

  This change refactors the `chainActive` reference into a `::ChainActive()` call. It also distinguishes `CChainState`'s `CChain` data member as `m_chain` instead of the current `chainActive`, which makes it easily confused with the global data.

  The active chain must be obtained via function because its reference will be swapped at some point during runtime after loading a UTXO snapshot.

  This change, though lengthy, should be pretty easy to review since most of it is contained within a scripted-diff. Once merged, the parent PR should be easier to review.

ACKs for commit 486c1e:
  Sjors:
    utACK 486c1ee
  promag:
    utACK 486c1ee.
  practicalswift:
    utACK 486c1eea86

Tree-SHA512: 06ed8f9e77f2d25fc9bea0ba86436d80dbbce90a1e8be23e37ec4eeb26060483e60b4a5c4fba679cb1867f61e3921c24abeb9cabdfb4d0a9b1c4ddd77b17456a
2019-05-07 11:51:30 -04:00
Russell Yanofsky
4b331159df Add unit test NextString, ForEachNoDup functions
Remove testcase generating code from util_SettingsMerge so it can be reused in
new tests.

The hash value expected in util_SettingsMerge changes as a result of this, but
only because the testcases are generated in a different order, not because any
cases are added or removed. It is possible to verify this with:

    SETTINGS_MERGE_TEST_OUT=new.txt test/test_bitcoin --run_test=util_tests/util_SettingsMerge
    git checkout HEAD~1
    make test/test_bitcoin
    SETTINGS_MERGE_TEST_OUT=old.txt test/test_bitcoin --run_test=util_tests/util_SettingsMerge
    diff -u <(sort old.txt) <(sort new.txt)

The new output is a little more readable, with simpler testcases sorted first.
2019-05-07 11:51:30 -04:00
Russell Yanofsky
05bfee3451 util_SettingsMerge test cleanup
Followup to #15869. Treat "-wallet" as the network-specific argument in test
instead of "-server", to make test output clearer and be more consistent with
bitcoind. Update embedded hash to match changed output from this.
2019-05-07 11:51:30 -04:00
orient
41ab2a8924
fix static_assert for macro HAVE_THREAD_LOCAL
fix static_assert for macro HAVE_THREAD_LOCAL while define DEBUG_LOCKCONTENTION
2019-05-07 14:11:35 +08:00
grim-trigger
1b05dff080
Fix portability issue with pthreads
This change resolves the following issue:
https://github.com/bitcoin/bitcoin/issues/15951

Only tested on OpenBSD 6.5/amd64
2019-05-07 00:17:33 +00:00
Pieter Wuille
3cb9ce85d0 Document strenghtening 2019-05-06 15:15:04 -07:00
Pieter Wuille
1d207bc46f Add hash strengthening to the RNG
Once every minute, this will feed the RNG state through repeated SHA512
for 10ms. The timings of that operation are used as entropy source as
well.
2019-05-06 15:15:04 -07:00
Pieter Wuille
c01c065b9d Do not construct out-of-bound pointers in SHA512/SHA1/RIPEMD160 code 2019-05-06 15:11:10 -07:00
MarcoFalke
3632143ebb
Merge #14266: refactor: Lift prevector default vals to the member declaration
d2eee87928 Lift prevector default vals to the member declaration (Ben Woosley)

Pull request description:

  I overlooked this possibility in #14028

ACKs for commit d2eee8:
  promag:
    utACK d2eee87, change looks good because members are always initialized.
  251Labs:
    utACK d2eee87 nice one.
  ken2812221:
    utACK d2eee87928
  practicalswift:
    utACK d2eee87928
  scravy:
    utACK d2eee87928

Tree-SHA512: f2726bae1cf892fd680cf8571027bcdc2e42ba567eaa901fb5fb5423b4d11b29e745e0163d82cb513d8c81399cc85933a16ed66d4a30829382d4721ffc41dc97
2019-05-06 15:32:24 -04:00
MarcoFalke
aaaa57c2aa
scripted-diff: Bump copyright headers in wallet
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./src/wallet/
-END VERIFY SCRIPT-
2019-05-06 14:05:52 -04:00
MarcoFalke
faf3729242
wallet: Only fail rescan when blocks have actually been pruned 2019-05-06 14:03:56 -04:00
MarcoFalke
8ec7121a45
Merge #15927: [tests] log thread names by default in functional tests
7b29ec277b [tests] Comment for why logging config is set as command-line args. (John Newbery)
ba534ccd56 [tests] log thread names by default in functional tests (John Newbery)

Pull request description:

  More detailed logs are better

ACKs for commit 7b29ec:
  jamesob:
    utACK 7b29ec277b

Tree-SHA512: 327cfedb7b7bf32f7ce1e2de5f70c7092041a8e868e14285a79176277c6cf47ebea27027f68787332f8ad21c7f64d2640dd21813eda5b2bd0e5208a65364a879
2019-05-06 12:59:19 -04:00
Wladimir J. van der Laan
c5ffe8d515
Merge #15730: rpc: Show scanning details in getwalletinfo
b6c748f849 doc: Add release notes for 15730 (João Barbosa)
d3e8458365 rpc: Show scanning details in getwalletinfo (João Barbosa)
90e27abe37 wallet: Track current scanning progress (João Barbosa)
2ee811e693 wallet: Track scanning duration (João Barbosa)

Pull request description:

  Closes #15724.

ACKs for commit b6c748:
  MarcoFalke:
    re-utACK b6c748f849 (Only change since my last review is rebase, adding release notes, and returning false instead of null)
  laanwj:
    utACK b6c748f849
  jonatack:
    ACK b6c748f849, only changes appear to be rebase for https://github.com/bitcoin/bitcoin/pull/15730#discussion_r280030617 and release notes.

Tree-SHA512: 8ee98f971c15f66ce8138fc92c55e51abc9faf01866a31ac7ce2ad766aa2bb88559eabee3b5815d645c84cdf1c19dc35ec03f31461e39bc5f6040edec0b87116
2019-05-06 13:38:12 +02:00
Wladimir J. van der Laan
a3d2d6b067
Merge #15930: rpc: Add balances RPC
facfb4111d rpc: Deprecate getunconfirmedbalance and getwalletinfo balances (MarcoFalke)
999931cf8f rpc: Add getbalances RPC (MarcoFalke)
fad13e925e rpcwallet: Make helper methods const on CWallet (MarcoFalke)
fad40ec915 wallet: Use IsValidNumArgs in getwalletinfo rpc (MarcoFalke)

Pull request description:

  This exposes the `CWallet::GetBalance()` struct over RPC.

  In the future, incorrectly named rpcs such as `getunconfirmedbalance` or rpcs redundant to this such as `getbalance` could be removed.

ACKs for commit facfb4:
  jnewbery:
    utACK facfb4111d

Tree-SHA512: 1f54fedce55df9a8ea82d2b6265354b39a956072621876ebaee2355aac0e23c7b64340c3279502415598c095858529e18b50789be956250aafda1cd3a8d948a5
2019-05-06 11:36:42 +02:00
Wladimir J. van der Laan
773e16f919
Merge #15947: Install bitcoin-wallet manpage
00d110463a Install bitcoin-wallet manpage. (Daniel Kraft)

Pull request description:

  This change marks the already-existing `bitcoin-wallet.1` manpage file for installation together with the others.  Previously, only `bitcoind.1`, `bitcoin-cli.1`, `bitcoin-tx.1` and `bitcoin-qt.1` would be installed.

ACKs for commit 00d110:
  laanwj:
    utACK 00d110463a
  practicalswift:
    utACK 00d110463a

Tree-SHA512: ca846e414548f1dc774f460edca2e17d7d619c7e6f0d18db0c58c09e04f9d43c6964fcf2bacb5b1eae94de9c5fdda86abf258ef6b78b0f693715d070dfc10f08
2019-05-06 10:07:28 +02:00
Wladimir J. van der Laan
9bbaac73bb
Merge #15928: GUI: Move QRImageWidget to its own file-pair
fc929842c2 GUI: Move QRImageWidget to its own file-pair (Luke Dashjr)
77851ab682 GUI: Refactor actual QR code rendering into new QRImageWidget::setQR (Luke Dashjr)

Pull request description:

  For at least QR-code based pairing of mobile wallets with nodes, it will be desirable to render QR codes even without wallet support.

  Therefore, this prepares by moving the QRImageWidget out of a wallet-specific file into its own `qrencoder` file-pair.

ACKs for commit fc9298:
  laanwj:
    utACK fc929842c2
  jonasschnelli:
    utACK fc929842c2

Tree-SHA512: 95529a38c0573a4b3f1253fb5f11ca07a5b3a9840ec24acc7d87270212f3c9f7c5b186d9274d297517a3b80494f38a57574fb9730b1574db01688539b987bd91
2019-05-06 10:04:33 +02:00
Wladimir J. van der Laan
d7d7d31506
Merge #15141: Rewrite DoS interface between validation and net_processing
0ff1c2a838 Separate reason for premature spends (coinbase/locktime) (Suhas Daftuar)
54470e767b Assert validation reasons are contextually correct (Suhas Daftuar)
2120c31521 [refactor] Update some comments in validation.cpp as we arent doing DoS there (Matt Corallo)
12dbdd7a41 [refactor] Drop unused state.DoS(), state.GetDoS(), state.CorruptionPossible() (Matt Corallo)
aa502b88d1 scripted-diff: Remove DoS calls to CValidationState (Matt Corallo)
7721ad64f4 [refactor] Prep for scripted-diff by removing some \ns which annoy sed. (Matt Corallo)
5e78c5734b Allow use of state.Invalid() for all reasons (Matt Corallo)
6b34bc6b6f Fix handling of invalid headers (Suhas Daftuar)
ef54b486d5 [refactor] Use Reasons directly instead of DoS codes (Matt Corallo)
9ab2a0412e CorruptionPossible -> BLOCK_MUTATED (Matt Corallo)
6e55b292b0 CorruptionPossible -> TX_WITNESS_MUTATED (Matt Corallo)
7df16e70e6 LookupBlockIndex -> CACHED_INVALID (Matt Corallo)
c8b0d22698 [refactor] Drop redundant nDoS, corruptionPossible, SetCorruptionPossible (Matt Corallo)
34477ccd39 [refactor] Add useful-for-dos "reason" field to CValidationState (Matt Corallo)
6a7f8777a0 Ban all peers for all block script failures (Suhas Daftuar)
7b999103e2 Clean up banning levels (Matt Corallo)
b8b4c80146 [refactor] drop IsInvalid(nDoSOut) (Matt Corallo)
8818729013 [refactor] Refactor misbehavior ban decisions to MaybePunishNode() (Matt Corallo)
00e11e61c0 [refactor] rename stateDummy -> orphan_state (Matt Corallo)
f34fa719cf Drop obsolete sigops comment (Matt Corallo)

Pull request description:

  This is a rebase of #11639 with some fixes for the last few comments which were not yet addressed.

  The original PR text, with some strikethroughs of text that is no longer correct:

  > This cleans up an old main-carryover - it made sense that main could decide what DoS scores to assign things because the DoS scores were handled in a different part of main, but now validation is telling net_processing what DoS scores to assign to different things, which is utter nonsense. Instead, we replace CValidationState's nDoS and CorruptionPossible with a general ValidationInvalidReason, which net_processing can handle as it sees fit. I keep the behavior changes here to a minimum, but in the future we can utilize these changes for other smarter behavior, such as disconnecting/preferring to rotate outbound peers based on them providing things which are invalid due to SOFT_FORK because we shouldn't ban for such cases.
  >
  > This is somewhat complementary with, though obviously conflicts heavily with #11523, which added enums in place of DoS scores, as well as a few other cleanups (which are still relevant).
  >
  > Compared with previous bans, the following changes are made:
  >
  > Txn with empty vin/vout or null prevouts move from 10 DoS
  > points to 100.
  > Loose transactions with a dependency loop now result in a ban
  > instead of 10 DoS points.
  > ~~BIP68-violation no longer results in a ban as it is SOFT_FORK.~~
  > ~~Non-SegWit SigOp violation no longer results in a ban as it
  > considers P2SH sigops and is thus SOFT_FORK.~~
  > ~~Any script violation in a block no longer results in a ban as
  > it may be the result of a SOFT_FORK. This should likely be
  > fixed in the future by differentiating between them.~~
  > Proof of work failure moves from 50 DoS points to a ban.
  > Blocks with timestamps under MTP now result in a ban, blocks
  > too far in the future continue to not result in a ban.
  > Inclusion of non-final transactions in a block now results in a
  > ban instead of 10 DoS points.

  Note: The change to ban all peers for consensus violations is actually NOT the change I'd like to make -- I'd prefer to only ban outbound peers in those situations.  The current behavior is a bit of a mess, however, and so in the interests of advancing this PR I tried to keep the changes to a minimum.  I plan to revisit the behavior in a followup PR.

  EDIT: One reviewer suggested I add some additional context for this PR:

  > The goal of this work was to make net_processing aware of the actual reasons for validation failures, rather than just deal with opaque numbers instructing it to do something.
  >
  > In the future, I'd like to make it so that we use more context to decide how to punish a peer. One example is to differentiate inbound and outbound peer misbehaviors. Another potential example is if we'd treat RECENT_CONSENSUS_CHANGE failures differently (ie after the next consensus change is implemented), and perhaps again we'd want to treat some peers differently than others.

ACKs for commit 0ff1c2:
  jnewbery:
    utACK 0ff1c2a838
  ryanofsky:
    utACK 0ff1c2a838. Only change is dropping the first commit (f3883a321bf4ab289edcd9754b12cae3a648b175), and dropping the temporary `assert(level == GetDoS())` that was in 35ee77f2832eaffce30042e00785c310c5540cdc (now c8b0d22698)

Tree-SHA512: e915a411100876398af5463d0a885920e44d473467bb6af991ef2e8f2681db6c1209bb60f848bd154be72d460f039b5653df20a6840352c5f7ea5486d9f777a3
2019-05-04 11:58:57 +02:00
MarcoFalke
f19a3b2ded
Merge #15949: test_runner: Move pruning back to extended
fa08c5cb99 test_runner: Move pruning back to extended (MarcoFalke)

Pull request description:

  This reverts fafb55e2c2, since the test is still too slow to run with asan enabled on a network hdd

ACKs for commit fa08c5:
  jnewbery:
    utACK fa08c5cb99
  jonasschnelli:
    utACK fa08c5cb99

Tree-SHA512: de16786b9d507a72210805c3e9eef360e5fc3d4bc3a81f7175b6cc70d1bc426cde7ac97bc0d1a0d4e0813067e1e251c2dd49256552cc6b52446b475251b7c32b
2019-05-03 17:03:16 -04:00
Jonas Schnelli
2dfe275171
Add ChaCha20 bench 2019-05-03 22:52:11 +02:00
MarcoFalke
fa08c5cb99
test_runner: Move pruning back to extended 2019-05-03 16:16:39 -04:00
James O'Beirne
486c1eea86 refactoring: remove unused chainActive 2019-05-03 15:03:05 -04:00
James O'Beirne
631940aab2 scripted-diff: replace chainActive -> ::ChainActive()
Though at the moment ChainActive() simply references `g_chainstate.m_chain`,
doing this change now clears the way for multiple chainstate usage and allows
us to script the diff.

-BEGIN VERIFY SCRIPT-
git grep -l "chainActive" | grep -E '(h|cpp)$' | xargs sed -i '/chainActive =/b; /extern CChain& chainActive/b; s/\(::\)\{0,1\}chainActive/::ChainActive()/g'
-END VERIFY SCRIPT-
2019-05-03 15:02:54 -04:00
James O'Beirne
a3a609079c refactoring: introduce unused ChainActive()
in preparation for the following scripted-diff commit.
2019-05-03 14:38:38 -04:00
James O'Beirne
1b6e6fcfd2 rename: CChainState.chainActive -> m_chain
This can't be a scripted-diff due to the confusion of the global
chainActive and the CChainState member of the same name.

This specific rename makes the following chainActive -> ::ChainActive() diff
scriptable.
2019-05-03 14:38:30 -04:00
Jonas Schnelli
2bc2b8b49a
Add ChaCha20 encryption option (XOR) 2019-05-03 20:31:18 +02:00
MarcoFalke
facfb4111d
rpc: Deprecate getunconfirmedbalance and getwalletinfo balances 2019-05-03 13:59:44 -04:00
MarcoFalke
faf666f814
Remove Windows 32 bit build 2019-05-03 13:41:27 -04:00
John Newbery
7b29ec277b [tests] Comment for why logging config is set as command-line args. 2019-05-03 12:47:27 -04:00
Daniel Kraft
00d110463a Install bitcoin-wallet manpage.
This change marks the already-existing bitcoin-wallet.1 manpage file for
installation together with the others.  Previously, only bitcoind.1,
bitcoin-cli.1, bitcoin-tx.1 and bitcoin-qt.1 would be installed.
2019-05-03 15:10:39 +02:00
Sjors Provoost
2620e24b83
[depends] boost: update to 1.70 2019-05-03 13:22:17 +01:00
MarcoFalke
94daebf327
Merge #15932: rpc: Serialize in getblock without cs_main
faea56400d rpc: Add lock annotations to block{,header}ToJSON (MarcoFalke)
fab00a5cb9 rpc: Serialize in getblock without cs_main (MarcoFalke)
fa1c3591ad rpc: Use IsValidNumArgs in getblock (MarcoFalke)

Pull request description:

  No need to hold cs_main when serializing a struct to json

  Fixes: #15925

ACKs for commit faea56:
  jnewbery:
    utACK faea56400d
  jonasschnelli:
    utACK faea56400d

Tree-SHA512: 005d378cda1e6024e9f5142f99a8adbefe202cd7bfeaafee55eb909e8990a3790aa27fcf5dd16119cc9afe9dc8bd30f660de40233316781669be166bac3018e7
2019-05-03 08:09:22 -04:00
Suhas Daftuar
0ff1c2a838 Separate reason for premature spends (coinbase/locktime) 2019-05-02 15:30:58 -04:00
Suhas Daftuar
54470e767b Assert validation reasons are contextually correct 2019-05-02 15:29:09 -04:00
Matt Corallo
2120c31521 [refactor] Update some comments in validation.cpp as we arent doing DoS there 2019-05-02 15:27:32 -04:00
Matt Corallo
12dbdd7a41 [refactor] Drop unused state.DoS(), state.GetDoS(), state.CorruptionPossible()
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2019-05-02 15:25:43 -04:00
Matt Corallo
aa502b88d1 scripted-diff: Remove DoS calls to CValidationState
-BEGIN VERIFY SCRIPT-
sed -i 's/\.DoS(\(.*\), REJECT_\(.*\), \(true\|false\)/.DoS(\1, REJECT_\2/' src/validation.cpp src/consensus/tx_verify.cpp src/consensus/tx_check.cpp
sed -i 's/state.GetRejectCode(), state.GetRejectReason(), [^,]\+, state.GetDebugMessage())/state.GetRejectCode(), state.GetRejectReason(), state.GetDebugMessage())/' src/validation.cpp
sed -i 's/\.DoS([^,]*, /.Invalid\(/' src/validation.cpp src/consensus/tx_verify.cpp src/consensus/tx_check.cpp
-END VERIFY SCRIPT-

Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2019-05-02 15:24:07 -04:00
Matt Corallo
7721ad64f4 [refactor] Prep for scripted-diff by removing some \ns which annoy sed. 2019-05-02 15:22:29 -04:00
Matt Corallo
5e78c5734b Allow use of state.Invalid() for all reasons
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2019-05-02 15:21:24 -04:00
Suhas Daftuar
6b34bc6b6f Fix handling of invalid headers
We only disconnect outbound peers (excluding HB compact block peers and manual
connections) when receiving a CACHED_INVALID header.
2019-05-02 15:17:24 -04:00
Matt Corallo
ef54b486d5 [refactor] Use Reasons directly instead of DoS codes 2019-05-02 15:15:50 -04:00
Matt Corallo
9ab2a0412e CorruptionPossible -> BLOCK_MUTATED
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2019-05-02 15:14:12 -04:00
Matt Corallo
6e55b292b0 CorruptionPossible -> TX_WITNESS_MUTATED
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2019-05-02 15:12:38 -04:00
Matt Corallo
7df16e70e6 LookupBlockIndex -> CACHED_INVALID
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2019-05-02 15:11:03 -04:00
Matt Corallo
c8b0d22698 [refactor] Drop redundant nDoS, corruptionPossible, SetCorruptionPossible
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2019-05-02 15:10:32 -04:00
Matt Corallo
34477ccd39 [refactor] Add useful-for-dos "reason" field to CValidationState
This is a first step towards cleaning up our DoS interface - make
validation return *why* something is invalid, and let net_processing
figure out what that implies in terms of banning/disconnection/etc.

Behavior change: peers will now be banned for providing blocks
with premature coinbase spends.

Co-authored-by: Anthony Towns <aj@erisian.com.au>
                Suhas Daftuar <sdaftuar@gmail.com>
2019-05-02 14:55:13 -04:00
MarcoFalke
faea56400d
rpc: Add lock annotations to block{,header}ToJSON 2019-05-02 14:33:26 -04:00