Commit Graph

20573 Commits

Author SHA1 Message Date
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
Suhas Daftuar
6a7f8777a0 Ban all peers for all block script failures
This eliminates a discrepancy between block validation with multiple
script check threads, versus a single script check thread.
2019-05-02 11:00:19 -04:00
Matt Corallo
7b999103e2 Clean up banning levels
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.
 * Many pre-segwit soft-fork errors now result in a ban.
   Note: Transactions that violate soft-fork script flags since P2SH do not generally
   result in a ban. Also, banning behavior for invalid blocks is dependent on
   whether the node is validating with multiple script check threads, due to a long-
   standing bug. That inconsistency is still present after this commit.
 * 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.

Co-authored-by: Anthony Towns <aj@erisian.com.au>
2019-05-02 11:00:19 -04:00
Matt Corallo
b8b4c80146 [refactor] drop IsInvalid(nDoSOut)
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2019-05-02 11:00:19 -04:00
Matt Corallo
8818729013 [refactor] Refactor misbehavior ban decisions to MaybePunishNode()
Isolate the decision of whether to ban a peer to one place in the
code, rather than having it sprinkled throughout net_processing.

Co-authored-by: Anthony Towns <aj@erisian.com.au>
                Suhas Daftuar <sdaftuar@gmail.com>
                John Newbery <john@johnnewbery.com>
2019-05-02 11:00:19 -04:00
Matt Corallo
00e11e61c0 [refactor] rename stateDummy -> orphan_state
Co-authored-by: Anthony Towns <aj@erisian.com.au>
                Suhas Daftuar <sdaftuar@gmail.com>
2019-05-02 11:00:19 -04:00
Matt Corallo
f34fa719cf Drop obsolete sigops comment
This comment was confusing and incorrect when first added ("invalid rather than
merely non-standard" has the opposite meaning of what is actually the case),
and was also not updated after segwit with the correct variable names.

Delete it since the code reads just fine on its own.

Co-authored by: Anthony Towns <aj@erisian.com.au>
                Suhas Daftuar <sdaftuar@gmail.com>
2019-05-02 11:00:19 -04:00
Wladimir J. van der Laan
24dfcf3a56
Merge #15941: doc: Add historical release notes for 0.18.0
da9f1ace5d doc: Add historical release notes for 0.18.0 (Wladimir J. van der Laan)

Pull request description:

ACKs for commit da9f1a:
  jonasschnelli:
    Cross read verification ACK da9f1ace5d

Tree-SHA512: f41e87d1c6bf29440ebfe15ea2f92bf96d4c4c041fe598f8e5417113a62684cffb2e54277d9412c0d230f78c7481bcb56374858ffb7d1149c68226b9cb7a5c3e
2019-05-02 16:24:15 +02:00
MarcoFalke
999931cf8f
rpc: Add getbalances RPC 2019-05-02 10:10:23 -04:00
Wladimir J. van der Laan
da9f1ace5d
doc: Add historical release notes for 0.18.0
Tree-SHA512: f41e87d1c6bf29440ebfe15ea2f92bf96d4c4c041fe598f8e5417113a62684cffb2e54277d9412c0d230f78c7481bcb56374858ffb7d1149c68226b9cb7a5c3e
2019-05-02 16:10:19 +02:00
MarcoFalke
fad13e925e
rpcwallet: Make helper methods const on CWallet 2019-05-02 10:09:48 -04:00
MarcoFalke
c1ba1182eb
Merge #15938: refactor: Silence "control reaches end of non-void function" (-Wreturn-type) in psbt.cpp
beb42d71a0 Silence GCC 7 warning "control reaches end of non-void function" (-Wreturn-type) in psbt.cpp (practicalswift)

Pull request description:

  Silence GCC 7 warning "control reaches end of non-void function" (`-Wreturn-type`) in `psbt.cpp`.

  Context: ef22fe8c1f (r33370109)

  Before this patch:

  ```
  $ ./configure CC=gcc-7 CXX=g++-7
  $ make 2>&1 | grep -A2 "warning: "
  leveldb/util/logging.cc:58:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             (v == kMaxUint64/10 && delta > kMaxUint64%10)) {
                                    ~~~~~~^~~~~~~~~~~~~~~
  --
  leveldb/port/port_posix.cc:60:15: warning: ‘ecx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     return (ecx & (1 << 20)) != 0;
            ~~~~~^~~~~~~~~~~~
  --
  psbt.cpp:341:1: warning: control reaches end of non-void function [-Wreturn-type]
   }
   ^
  $
  ```

  After this patch:

  ```
  $ ./configure CC=gcc-7 CXX=g++-7
  $ make 2>&1 | grep -A2 "warning: "
  leveldb/util/logging.cc:58:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             (v == kMaxUint64/10 && delta > kMaxUint64%10)) {
                                    ~~~~~~^~~~~~~~~~~~~~~
  --
  leveldb/port/port_posix.cc:60:15: warning: ‘ecx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     return (ecx & (1 << 20)) != 0;
            ~~~~~^~~~~~~~~~~~
  $
  ```

ACKs for commit beb42d:

Tree-SHA512: b068b9aef565cae0bd1fa1f79c8d422ed2c3e7645edfa14a780a36dd66095a3c627f4111a6b16e706ce6c8abafe51725af8b3bf60778821de0aa8f6193bfadf8
2019-05-02 09:13:52 -04:00
practicalswift
beb42d71a0 Silence GCC 7 warning "control reaches end of non-void function" (-Wreturn-type) in psbt.cpp 2019-05-02 15:08:22 +02:00
MarcoFalke
c4560a7dfe
Merge #15650: Handle the result of posix_fallocate system call
5d35ae3326 Handle the result of posix_fallocate system call (Luca Venturini)

Pull request description:

  The system call `posix_fallocate` is not supported on some filesystems.

  - catches the result of posix_allocate and fall back to the default behaviour if the return value is different from 0 (success)

  Fixes #15624

ACKs for commit 5d35ae:
  MarcoFalke:
    utACK 5d35ae3326
  sipa:
    utACK 5d35ae3326, though the Yoda condition is an uncommon style in this project.
  hebasto:
    utACK 5d35ae3326
  practicalswift:
    utACK 5d35ae3326

Tree-SHA512: 7ab3b35fb633926f28a58b2b07ffde8e31bb997c80a716b1b45ee716fe9ff4ddcef0a05810bd4423530e220cfc62f8925517d27a8b92b05a524272063e43f746
2019-05-02 08:43:57 -04:00
Luke Dashjr
fc929842c2 GUI: Move QRImageWidget to its own file-pair 2019-05-02 12:18:18 +00:00
João Barbosa
b6c748f849 doc: Add release notes for 15730 2019-05-02 11:39:07 +01:00
João Barbosa
d3e8458365 rpc: Show scanning details in getwalletinfo 2019-05-02 11:39:07 +01:00
João Barbosa
90e27abe37 wallet: Track current scanning progress 2019-05-02 11:39:05 +01:00
MarcoFalke
faede747b3
doc: Explain how to pass in non-fundamental types into functions 2019-05-01 16:03:20 -04:00
MarcoFalke
0936f35f65
Merge #15842: refactor: replace isPotentialtip/waitForNotifications by higher method
422677963a refactor: replace isPotentialtip/waitForNotifications by higher method (Antoine Riard)
edfe9438ca Add WITH_LOCK macro: run code while locking a mutex (Antoine Riard)

Pull request description:

  In Chain interface, instead of a isPotentialTip and a WaitForNotifications method, both used only once in CWallet::BlockUntilSyncedToCurrentChain, combine them in a higher WaitForNotificationsUpToTip method. Semantic should be unchanged, wallet wait for pending notifications to be processed unless block hash points to the current chain tip or a descendant.

ACKs for commit 422677:
  jnewbery:
    ACK 422677963a
  ryanofsky:
    utACK 422677963a. Only change is adding the cs_wallet lock annotation.

Tree-SHA512: 2834ff0218795ef607543fae822e5cce25d759c1a9cfcb1f896a4af03071faed5276fbe0966e0c6ed65dc0e88af161899c5b2ca358a2d24fe70969a550000bf2
2019-05-01 15:02:31 -04:00
John Newbery
f1a77b0c51 [docs] Add doxygen comment for CReserveKey 2019-05-01 14:53:36 -04:00
John Newbery
37796b2dd4 [docs] Add doxygen comment for CKeyPool 2019-05-01 14:53:32 -04:00
MarcoFalke
fab00a5cb9
rpc: Serialize in getblock without cs_main 2019-05-01 12:32:11 -04:00
MarcoFalke
fa1c3591ad
rpc: Use IsValidNumArgs in getblock 2019-05-01 11:16:21 -04:00
MarcoFalke
fad40ec915
wallet: Use IsValidNumArgs in getwalletinfo rpc 2019-05-01 10:21:21 -04:00
MarcoFalke
12aa2ac988
Merge #15323: rpc: Expose g_is_mempool_loaded via getmempoolinfo
effe81f750 Move g_is_mempool_loaded into CTxMemPool::m_is_loaded (Ben Woosley)
bb8ae2c419 rpc: Expose g_is_mempool_loaded via getmempoolinfo and /rest/mempool/info.json (Ben Woosley)

Pull request description:

  And use it to fix a race condition in mempool_persist.py:
  https://travis-ci.org/Empact/bitcoin/jobs/487577243

  Since e.g. getrawmempool returns errors based on this status, this
  enables users to test it for readiness.

  Fixes #12863

ACKs for commit effe81:
  MarcoFalke:
    utACK effe81f750
  jnewbery:
    utACK effe81f750

Tree-SHA512: 74328b0c17a97efb8a000d4ee49b9a673c2b6dde7ea30c43a6a2eff961a233351c9471f9a42344412135786c02bdf2ee1b2526651bb8fed68bd94d2120c4ef86
2019-05-01 10:06:15 -04:00
MarcoFalke
86edb79e97
Merge #15841: [test] combine_logs: append node stderr and stdout if it exists
fa90a89eee [test] combine_logs: append node stderr and stdout if it exists (MarcoFalke)

Pull request description:

  See issue:

  * tests: bitcoind stdout and error should be passed to the logger #13519

ACKs for commit fa90a8:
  laanwj:
    utACK fa90a89eee

Tree-SHA512: 39c4596e2e133c9011ab01bc4dc24e884d0a8cce7a67d3765f17c288d3ffbd438e1ff6016d0f817a981b27fce17fa77a1ff56787ddb1ea55123ce9ecffb44c08
2019-05-01 08:39:51 -04:00
MarcoFalke
2eb8c5d7a2
Merge #15758: qa: Add further tests to wallet_balance
fa79a783d6 test: Add reorg test to wallet_balance (MarcoFalke)
fad03cd046 test: Check that wallet txs not in the mempool are untrusted (MarcoFalke)
fa195315e6 test: Add getunconfirmedbalance test with conflicts (MarcoFalke)
fa464e8211 test: Add wallet_balance test for watchonly (MarcoFalke)

Pull request description:

  Second commit can be reviewed with `--ignore-all-space`

ACKs for commit fa79a7:
  jnewbery:
    utACK fa79a783d6

Tree-SHA512: ec4919a3c93b6dcb35d58e7c65bdffe7f4c8cb87b9287f3679631c1823ef5bd72789f233def94e60c1ab332711601751645566f5997ce250af55b328ed60e917
2019-05-01 08:35:05 -04:00
Luke Dashjr
77851ab682 GUI: Refactor actual QR code rendering into new QRImageWidget::setQR 2019-05-01 05:25:17 +00:00
John Newbery
ba534ccd56 [tests] log thread names by default in functional tests 2019-04-30 15:06:26 -05:00
MarcoFalke
2c35fe6238
Merge #15849: Thread names in logs and deadlock debug tools
8722e54e56 threads: add thread names to deadlock debugging message (James O'Beirne)
383b186c28 threads: prefix log messages with thread names (James O'Beirne)
ddd95ccb80 tests: add threadutil tests (James O'Beirne)
ae5f2b6a6c threads: introduce util/threadnames, refactor thread naming (James O'Beirne)
188ca75e5f disable HAVE_THREAD_LOCAL on unreliable platforms (James O'Beirne)

Pull request description:

  I'm resurrecting this one (from #13168) because I need it to make progress on #15735.

  It's now off by default and can be turned on with `-logthreadnames=1`.

  Ran some benchmarks (IBD from local peer from 500_000 -> 504_000) and it's within spitting distance either on or off:

  ### threadnames off (default)

  #### 2018-05-threadnames.3 vs. master (absolute)
  |                      name                      | iterations |   2018-05-threadnames.3    |           master           |
  |------------------------------------------------|-----------:|----------------------------|----------------------------|
  | ibd.local.500000.504000.dbcache=2048           |          3 | 376.1584 (± 9.2944)        | 392.3414 (± 13.4238)       |
  | ibd.local.500000.504000.dbcache=2048.mem-usage |          3 | 2236117.3333 (± 1845.9623) | 2238690.6667 (± 2669.3487) |

  #### 2018-05-threadnames.3 vs. master (relative)
  |                      name                      | iterations | 2018-05-threadnames.3 | master |
  |------------------------------------------------|-----------:|----------------------:|-------:|
  | ibd.local.500000.504000.dbcache=2048           |          3 |                     1 |  1.043 |
  | ibd.local.500000.504000.dbcache=2048.mem-usage |          3 |                     1 |  1.001 |

  ### threadnames on

  #### 2018-05-threadnames-take-2 vs. master (absolute)
  |                      name                      | iterations | 2018-05-threadnames-take-2 |           master           |
  |------------------------------------------------|-----------:|----------------------------|----------------------------|
  | ibd.local.500000.504000.dbcache=2048           |          3 | 367.6861 (± 0.3941)        | 364.1667 (± 0.9776)        |
  | ibd.local.500000.504000.dbcache=2048.mem-usage |          3 | 2238461.3333 (± 3697.8730) | 2237014.6667 (± 3307.6966) |

  #### 2018-05-threadnames-take-2 vs. master (relative)
  |                      name                      | iterations | 2018-05-threadnames-take-2 | master |
  |------------------------------------------------|-----------:|---------------------------:|-------:|
  | ibd.local.500000.504000.dbcache=2048           |          3 |                      1.010 |   1.00 |
  | ibd.local.500000.504000.dbcache=2048.mem-usage |          3 |                      1.001 |   1.00 |
  ```

ACKs for commit 8722e5:
  Empact:
    utACK 8722e54e56
  jnewbery:
    utACK 8722e54e56
  MarcoFalke:
    re-utACK 8722e54e56 (Only change since my previous review is DEFAULT_LOGTHREADNAMES=false and stylistic updates

Tree-SHA512: 50af992708295b8d680cf10025262dd964e599a356bdfc1dfc84fb18c00afabcb34d3d12d551b0677ff81f8fccad0e17c1d5b24dfecb953a913bc77fdd1a4577
2019-04-30 15:26:01 -04:00
MarcoFalke
fa79a783d6
test: Add reorg test to wallet_balance 2019-04-30 15:14:41 -04:00
MarcoFalke
fad03cd046
test: Check that wallet txs not in the mempool are untrusted 2019-04-30 15:11:52 -04:00
MarcoFalke
fa195315e6
test: Add getunconfirmedbalance test with conflicts 2019-04-30 15:11:51 -04:00
MarcoFalke
fa464e8211
test: Add wallet_balance test for watchonly 2019-04-30 15:11:50 -04:00
MarcoFalke
10ed4dff24
Merge #15869: Add settings merge test to prevent regresssions
151f3e9cf1 Add settings merge test to prevent regresssions (Russell Yanofsky)

Pull request description:

  Test-only change. Motivation: I'm trying to clean up settings code and add support for read/write settings without changing existing behavior, but current tests are very scattershot and don't actually cover a lot of current behavior.

ACKs for commit 151f3e:
  jonasschnelli:
    utACK 151f3e9cf1.
  MarcoFalke:
    utACK 151f3e9cf1

Tree-SHA512: f9062f078da02855cdbdcae37d0cea5684e82adbe5c701a8eb042ee4a57d899f0ffb6a9db3bcf58b639dff22b2b2d8a75f9a7917402df58904036753d65a1e3e
2019-04-30 12:13:22 -04:00
MarcoFalke
45d8b71778
Merge #15696: [qa] test_runner: Move feature_pruning to base tests
fafb55e2c2 [qa] test_runner: Move feature_pruning to base tests (MarcoFalke)
8728a66782 [tests] fix block time in feature_pruning.py (John Newbery)

Pull request description:

ACKs for commit fafb55:

Tree-SHA512: 88abef94379fbad6629da11dccb080d5f0644490d6f2cc2756a33fac34bcf72e84245cef596dfae5a40f7a99b3f4da0dd85d306d4c1b452d310d3f36eef75a8b
2019-04-30 10:09:54 -04:00
MarcoFalke
fafb55e2c2
[qa] test_runner: Move feature_pruning to base tests 2019-04-30 08:55:28 -04:00
Hennadii Stepanov
a0a222eec0
Replace deprecated Boost Filesystem function
Boost Filesystem basename() function is deprecated since v1.36.0.
Also, defining BOOST_FILESYSTEM_NO_DEPRECATED before including
filesystem headers is strongly recommended. This prevents inadvertent
use of old features, particularly legacy function names, that have been
replaced and are going to go away in the future.
2019-04-30 10:05:54 +03:00
John Newbery
8728a66782 [tests] fix block time in feature_pruning.py 2019-04-29 18:48:22 -04:00