Commit graph

2083 commits

Author SHA1 Message Date
John Newbery 9a8505299b [tests] Use -whitelist in rpc_fundrawtransaction.py
Makes tx relay faster
2019-11-06 14:56:29 -05:00
Hennadii Stepanov 577682d9e8
script: Enable SC2006 rule for Gitian scripts 2019-11-06 15:11:54 +02:00
Hennadii Stepanov 14aded46df
script: Lint Gitian descriptors with ShellCheck 2019-11-06 15:10:11 +02:00
MarcoFalke 22a58811d4
Merge #17353: doc: Add ShellCheck to lint tests dependencies
80c9e66ab8 build: Remove install command samples (Hennadii Stepanov)
2ad74b78c6 doc: Add ShellCheck to lint tests dependencies (Hennadii Stepanov)

Pull request description:

  In master (9641366950) the lint tests dependencies list lacks ShellCheck. This PR fixes it.

  Also `lint-python.sh` is slightly improved.

ACKs for top commit:
  laanwj:
    ACK 80c9e66ab8
  promag:
    ACK 80c9e66ab8, verified internal and external links. Nice looking table.

Tree-SHA512: b63718a6c41be93137db70586465d84ca0b1ff33c0f2674147c928cb1bdf903ec7587861c09ad832841264285f99c7b171d5319eef3c989822a7cd01449222ae
2019-11-06 07:41:31 -05:00
Hennadii Stepanov 80c9e66ab8
build: Remove install command samples
test/README.md contains comprehensive install instructions.
2019-11-06 13:22:06 +02:00
Andrew Chow b84e776fd1 wallet_importmulti: use addresses of the same type as being imported
When constructing an import from the solving data of an address,
make sure that the original address is the same type as the one that
will be imported.
2019-11-05 18:31:10 -05:00
Wladimir J. van der Laan b05b28183c
Merge #16899: UTXO snapshot creation (dumptxoutset)
92b2f5306b test: add dumptxoutset RPC test (James O'Beirne)
c1ccbc3dde devtools: add utxo_snapshot.sh (James O'Beirne)
57cf74c991 rpc: add dumptxoutset (James O'Beirne)
92fafb3a7d coinstats: add coins_count (James O'Beirne)
707fde7b9b add unused SnapshotMetadata class (James O'Beirne)

Pull request description:

  This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11):

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

  ---

  This changeset defines the serialization format for UTXO snapshots and adds an RPC command for creating them, `dumptxoutset`. It also adds a convenience script for generating and verifying snapshots at a certain height, since that requires doing a hacky rewind of the chain via `invalidateblock`.

  All of this is unused at the moment.

ACKs for top commit:
  laanwj:
    ACK 92b2f5306b

Tree-SHA512: 200dff87767f157d627e99506ec543465d9329860a6cd49363081619c437163a640a46d008faa92b1f44fd403bfc7a7c9e851c658b5a4849efa9a34ca976bf31
2019-11-05 19:40:18 +01:00
James O'Beirne 92b2f5306b test: add dumptxoutset RPC test 2019-11-05 13:36:04 -05:00
James Chiang 2493770e36 TestShell: Return self from setup()
This allows user to chain setup() to the initializer. test-shell.md code
examples have been updated to reflect this.
2019-11-05 12:55:52 +01:00
James Chiang a8dea45524 TestShell: Simplify default setting of num_nodes 2019-11-05 12:55:52 +01:00
James Chiang 9c7806e4bf Doc: Remove backticks in test-shell.md code block 2019-11-05 12:55:52 +01:00
James Chiang d3ed06e2cd TestShell: Fix typo in TestShell warning printout 2019-11-05 12:55:52 +01:00
Samuel Dobson bdda137878
Merge #16766: wallet: Make IsTrusted scan parents recursively
4671fc3d9e Expand on wallet_balance.py comment from https://github.com/bitcoin/bitcoin/pull/16766\#issuecomment-527563982 (Jeremy Rubin)
91f3073f08 Update release notes to mention changes to IsTrusted and impact on wallet (Jeremy Rubin)
8f174ef112 Systematize style of IsTrusted single line if (Jeremy Rubin)
b49dcbedf7 update variable naming conventions for IsTrusted (Jeremy Rubin)
5ffe0d1449 Update comment in test/functional/wallet_balance.py (Jeremy Rubin)
a550c58267 Update wallet_balance.py test to reflect new behavior (Jeremy Rubin)
5dd7da4ccd Reuse trustedParents in looped calls to IsTrusted (Jeremy Rubin)
595f09d6de Cache tx Trust per-call to avoid DoS (Jeremy Rubin)
dce032ce29 Make IsTrusted scan parents recursively (Jeremy Rubin)

Pull request description:

  This slightly modifies the behavior of IsTrusted to recursively check the parents of a transaction. Otherwise, it's possible that a parent is not IsTrusted but a child is. If a parent is not trusted, then a child should not be either.

  This recursive scan can be a little expensive, so ~it might be beneficial to have a way of caching IsTrusted state, but this is a little complex because various conditions can change between calls to IsTrusted (e.g., re-org).~ I added a cache which works per call/across calls, but does not store the results semi-permanently. Which reduces DoS risk of this change. There is no risk of untrusted parents causing a resource exploitation, as we immediately return once that is detected.

  This is a change that came up as a bug-fix esque change while working on OP_SECURETHEBAG. You can see the branch where this change is important here: https://github.com/bitcoin/bitcoin/compare/master...JeremyRubin:stb-with-rpc?expand=1. Essentially, without this change, we can be tricked into accepting an OP_SECURETHEBAG output because we don't properly check the parents. As this was a change which, on its own, was not dependent on OP_SECURETHEBAG, I broke it out as I felt the change stands on its own by fixing a long standing wallet bug.

  The test wallet_balance.py has been corrected to meet the new behavior. The below comment, reproduced, explains what the issue is and the edge cases that can arise before this change.

          # Before `test_balance()`, we have had two nodes with a balance of 50
          # each and then we:
          #
          # 1) Sent 40 from node A to node B with fee 0.01
          # 2) Sent 60 from node B to node A with fee 0.01
          #
          # Then we check the balances:
          #
          # 1) As is
          # 2) With transaction 2 from above with 2x the fee
          #
          # Prior to #16766, in this situation, the node would immediately report
          # a balance of 30 on node B as unconfirmed and trusted.
          #
          # After #16766, we show that balance as unconfirmed.
          #
          # The balance is indeed "trusted" and "confirmed" insofar as removing
          # the mempool transactions would return at least that much money. But
          # the algorithm after #16766 marks it as unconfirmed because the 'taint'
          # tracking of transaction trust for summing balances doesn't consider
          # which inputs belong to a user. In this case, the change output in
          # question could be "destroyed" by replace the 1st transaction above.
          #
          # The post #16766 behavior is correct; we shouldn't be treating those
          # funds as confirmed. If you want to rely on that specific UTXO existing
          # which has given you that balance, you cannot, as a third party
          # spending the other input would destroy that unconfirmed.
          #
          # For example, if the test transactions were:
          #
          # 1) Sent 40 from node A to node B with fee 0.01
          # 2) Sent 10 from node B to node A with fee 0.01
          #
          # Then our node would report a confirmed balance of 40 + 50 - 10 = 80
          # BTC, which is more than would be available if transaction 1 were
          # replaced.

  The release notes have been updated to note the new behavior.

ACKs for top commit:
  ariard:
    Code Review ACK 4671fc3, maybe extend DoS protection in a follow-up PR.
  fjahr:
    Code review ACK 4671fc3d9e
  ryanofsky:
    Code review ACK 4671fc3d9e. Changes since last review: 2 new commits adding suggested release note and python test comment, also a clean rebase with no changes to the earlier commits. The PR description is more comprehensive now, too. Looks good!
  promag:
    Code review ACK 4671fc3d9e.

Tree-SHA512: 6b183ff425304fef49724290053514cb2770f4a2350dcb83660ef24af5c54f7c4c2c345b0f62bba60eb2d2f70625ee61a7fab76a7f491bb5a84be5c4cc86b92f
2019-11-05 21:59:27 +13:00
Samuel Dobson bfc4c896d6
Merge #17258: Fix issue with conflicted mempool tx in listsinceblock
436ad43643 Fix issue with conflicted mempool tx in listsinceblock (Adam Jonas)

Pull request description:

  Closes #8752 by bringing back abandoned #10470.

  This now checks that returned transactions are not conflicting with any transactions that are filtered out by the given blockhash and add a functional test to prevent this in the future.

  For more context, #8757 was closed in favor of #10470.

ACKs for top commit:
  instagibbs:
    utACK 436ad43643
  kallewoof:
    utACK 436ad43643
  jonatack:
    I'm not qualifed to give an ACK here but 436ad43643 appears reasonable. Built/ran tests/verified that this test fails without the change in rpcwallet.cpp:

Tree-SHA512: 63d75cd3d3f19fc84dc38899b200c96179b82b24db263cd0116ee5b715265be647157855c2e35912d2fbc49c7b37db9375d6aab0ac672f0f09bece8431de5ea9
2019-11-05 21:56:34 +13:00
MarcoFalke bc38bb9a60
Merge #17288: Added TestShell class for interactive Python environments.
19139ee034 Add documentation for test_shell submodule (JamesC)
f5112369cf Add TestShell class (James Chiang)
5155602a63 Move argparse() to init() (JamesC)
2ab01462f4 Move assert num_nodes is set into main() (JamesC)
614c645643 Clear TestNode objects after shutdown (JamesC)
6f40820757 Add closing and flushing of logging handlers (JamesC)
6b71241291 Refactor TestFramework main() into setup/shutdown (JamesC)
ede8b7608e Remove network_event_loop instance in close() (JamesC)

Pull request description:

  This PR refactors BitcoinTestFramework to encapsulate setup and shutdown logic into dedicated methods, and adds a  ~~TestWrapper~~ TestShell child class. This wrapper allows the underlying BitcoinTestFramework to run _between user inputs_ in a REPL environment, such as a Jupyter notebook or any interactive Python3 interpreter.

  The ~~TestWrapper~~ TestShell is motivated by the opportunity to expose the test-framework as a prototyping and educational toolkit. Examples of code prototypes enabled by  ~~TestWrapper~~ TestShell can be found in the Optech [Taproot/Schnorr](https://github.com/bitcoinops/taproot-workshop) workshop repository.

  Usage example:
  ```
  >>> import sys
  >>> sys.path.insert(0, "/path/to/bitcoin/test/functional")
  ```
  ```
  >>> from test_framework.test_wrapper import TestShell
  >>> test = TestShell()
  >>> test.setup(num_nodes=2)
  20XX-XX-XXTXX:XX:XX.XXXXXXX TestFramework (INFO): Initializing test directory /path/to/bitcoin_func_test_XXXXXXX
  ```
  ```
  >>> test.nodes[0].generate(101)
  >>> test.nodes[0].getblockchaininfo()["blocks"]
  101
  ```
  ```
  >>> test.shutdown()
  20XX-XX-XXTXX:XX:XX.XXXXXXX TestFramework (INFO): Stopping nodes
  20XX-XX-XXTXX:XX:XX.XXXXXXX TestFramework (INFO): Cleaning up /path/to/bitcoin_func_test_XXXXXXX on exit
  20XX-XX-XXTXX:XX:XX.XXXXXXX TestFramework (INFO): Tests successful
  ```

  **Overview of changes to BitcoinTestFramework:**

  - Code moved to `setup()/shutdown()` methods.
  - Argument parsing logic encapsulated by `parse_args` method.
  - Success state moved to `BitcoinTestFramework.success`.

  _During Shutdown_

  - `BitcoinTestFramework` logging handlers are flushed and removed.
  - `BitcoinTestFrameowork.nodes` list is cleared.
  - `NetworkThread.network_event_loop` is reset. (NetworkThread class).

  **Behavioural changes:**
  - Test parameters can now also be set when overriding BitcoinTestFramework.setup() in addition to overriding `set_test_params` method.
  - Potential exceptions raised in BitcoinTestFramework.setup() will be handled in main().

  **Added files:**
  - ~~test_wrapper.py~~ `test_shell.py`
  - ~~test-wrapper.md~~ `test-shell.md`

ACKs for top commit:
  jamesob:
    ACK 19139ee034
  jonatack:
    ACK 19139ee034
  jnewbery:
    Rather than invalidate the three ACKs for a minor nit, can you force push back to 19139ee034 please? I think this PR was ready to merge before your last force push.
  jachiang:
    > Rather than invalidate the three ACKs for a minor nit, can you force push back to [19139ee](19139ee034) please? I think this PR was ready to merge before your last force push.
  jnewbery:
    ACK 19139ee034

Tree-SHA512: 0c24f405f295a8580a9c8f1b9e0182b5d753eb08cc331424616dd50a062fb773d3719db4d08943365b1f42ccb965cc363b4bcc5beae27ac90b3460b349ed46b2
2019-11-04 14:54:14 -05:00
John Newbery 646b593bbd [tests] Speed up rpc_fundrawtransaction.py
Most of the time in rpc_fundrawtransaction.py is spent waiting for
unconfirmed transactions to propagate. Net processing adds a poisson
random delay to the time it will INV transactions with a mean interval
of 5 seconds. Calls like the following:

```
self.nodes[2].sendrawtransaction(signedTx['hex'])
self.sync_all()
self.nodes[1].generate(1)
````

will therefore introduce a delay waiting for the mempools to sync.
Instead just generate the block on the node that sent the transaction:

```
self.nodes[2].sendrawtransaction(signedTx['hex'])
self.nodes[2].generate(1)
```

rpc_fundrawtransaction.py is not intended to be a test for transaction
relay, so it's ok to do this.
2019-11-04 13:20:23 -05:00
MarcoFalke 94a26b192f
Merge #17318: replace asserts in RPC code with CHECK_NONFATAL and add linter
c98bd13e67 replace asserts in RPC code with CHECK_NONFATAL and add linter (Adam Jonas)

Pull request description:

  - Replace instances of assert in /rpc files and rpcwallet with CHECK_NONFATAL(condition)
  - Add a linter to prevent future usage of assert being used in RPC code

  ref https://github.com/bitcoin/bitcoin/pull/17192

ACKs for top commit:
  practicalswift:
    ACK c98bd13e67 -- diff looks correct

Tree-SHA512: a16036b6bbcca73a5334665f66e17e1756377d582317568291da1d727fc9cf8c84bac9d9bd099534e1be315345336e5f7b66b93793135155f320dc5862a2d875
2019-11-04 11:33:41 -05:00
MarcoFalke 6cb10c14c6
Merge #17199: test: use default address type (bech32) for wallet_bumpfee tests
8d8e5a79d0 test: use default address type (bech32) for wallet_bumpfee tests (Sebastian Falbesoner)

Pull request description:

  The use of native segwit addresses (pure p2wpkh instead of p2sh-p2wpkh) leads to smaller transaction sizes, needing adaption of some constants in the following test cases:
  - `test_dust_to_fee()`: adaption of dust calculation (p2wpkh spend estimate of 67 is taken from `src/policy/policy.cpp:GetDustThreshold()`)
  - `test_maxtxfee_fails()`: lowering `-maxtxfee` setting to trigger fail

Top commit has no ACKs.

Tree-SHA512: b4163700d56c11955f811bc5fe6edaf7aec69931d7db741c03b055fb518bb9825c031fb931c513b37a1968085cb8c2f263adf664b357aff8ee42795fd0f88d2d
2019-11-04 11:27:48 -05:00
JamesC 19139ee034 Add documentation for test_shell submodule 2019-11-04 16:02:28 +01:00
randymcmillan ac831339cb
doc: Fix some misspellings 2019-11-04 04:22:53 -05:00
James Chiang f5112369cf Add TestShell class
A BitcoinTestFramework child class which can be imported by an external user or
project. TestShell.setup() initiates an underlying BitcoinTestFramework object
with bitcoind subprocesses, rpc interfaces and test logging.
TestShell.shutdown() safely tears down the BitcoinTestFramework object.
2019-11-04 08:56:56 +01:00
JamesC 5155602a63 Move argparse() to init()
This ensures TestFramework default parameters are set before setup is called. A
 child class will therefore have access to defaults when overriding setup.
2019-11-03 20:34:49 +01:00
JamesC 2ab01462f4 Move assert num_nodes is set into main()
This allows a BitcoinTestFramework child class to set test parameters in an
overridden setup() rather than in an overridden set_test_params().
2019-11-03 20:34:41 +01:00
JamesC 614c645643 Clear TestNode objects after shutdown
TestNode objects need to be removed during shutdown, as setup_nodes does not
remove previous TestNode objects from previous test runs during setup.
2019-11-03 20:34:27 +01:00
JamesC 6f40820757 Add closing and flushing of logging handlers
In order for BitcoinTestFramework to correctly restart after shutdown, the
previous logging handlers need to be removed, or else logging will continue in
the previous temp directory. "Flush" ensures buffers are emptied, and "close"
ensures file handler close logging file.
2019-11-03 20:34:18 +01:00
JamesC 6b71241291 Refactor TestFramework main() into setup/shutdown
Setup and shutdown code now moved into dedicated methods. Test "success" is
added as a BitcoinTestFramework member, which can be accessed outside of main.
Argument parsing also moved into separate method and called from main.
2019-11-03 20:34:07 +01:00
JamesC ede8b7608e Remove network_event_loop instance in close()
The asyncio.new_event_loop() instance is now removed from the NetworkThread
class during shutdown. This enables a NetworkThread instance to be restarted
after being closed. The current NetworkThread class guards against an existing
new_event_loop during initialization.
2019-11-03 20:33:49 +01:00
Hennadii Stepanov 2ad74b78c6
doc: Add ShellCheck to lint tests dependencies 2019-11-02 17:43:07 +02:00
MarcoFalke 6a7c40bee4
Merge #15888: QA: Add wallet_implicitsegwit to test the ability to transform keys between address types
a6f6f77a86 QA: Add wallet_implicitsegwit to test the ability to transform keys between address types (Luke Dashjr)

Pull request description:

  This makes sure the wallet recognises payments to keys via address types they weren't created with.

  While we don't *want* this behaviour, it might make sense to explicitly test that it works until we remove it.

ACKs for top commit:
  adamjonas:
    utACK a6f6f77a86

Tree-SHA512: b208405729277e9ce06eb772b45e8d1683c4dc5703754448b8f19a590b37522abd7bb46d4dbd41513b3d46d7f9e8769ce4f15fa4114be600f31a1ebbc1157840
2019-11-01 13:24:50 -04:00
MarcoFalke bc3fcf3c0d
Merge #17327: test: add rpc_fundrawtransaction logging
ff22751417 test: rm ascii art in rpc_fundrawtransaction (Jon Atack)
94fcc08541 test: add rpc_fundrawtransaction logging (Jon Atack)

Pull request description:

  `test/functional/rpc_fundrawtransaction.py` is fairly slow to run and has no logging, so it can appear to be stalled.

  This commit adds info logging at each test to provide feedback on the test run.

ACKs for top commit:
  instagibbs:
    utACK ff22751417
  jnewbery:
    tACK ff22751417

Tree-SHA512: f4fabad8ef51c29981351bb4e66fb0c0e0517418a4a15892ef804df11d16b2d2ae1a1abc958d2b121819850278de90a2003b0edb8d7098d00360b89fa76e9062
2019-11-01 11:06:20 -04:00
Jon Atack ff22751417
test: rm ascii art in rpc_fundrawtransaction
Doc changes only to test/functional/rpc_fundrawtransaction.py:

- remove ascii art or convert to a docstring when sufficiently different from
the logging

- touch up other comments while here
2019-11-01 11:56:53 +01:00
Jon Atack 94fcc08541
test: add rpc_fundrawtransaction logging
test/functional/rpc_fundrawtransaction.py is fairly long to run and has no
logging, so it can appear to be stalled.

This commit adds info logging at each test to provide feedback on the test run.
2019-11-01 11:27:11 +01:00
MarcoFalke 222b7d0ca7
Merge #17330: test: Add shrinkdebugfile=0 to regtest bitcoin.conf
c5377ffbbb [qa] Add shrinkdebugfile=0 to regtest bitcoin.conf (Suhas Daftuar)

Pull request description:

  This helps avoid accidentally truncating the debug.log while manually
  debugging.

ACKs for top commit:
  MarcoFalke:
    ACK c5377ffbbb
  dongcarl:
    ACK c5377ffbbb

Tree-SHA512: a05d6a7c494ee2c300fa1a9dbaa48b7fed63a44b1fa823198cbf401cff1c4aa8e44eb431fa635b27a1987d0eb1a5f8e2712514dcea7c5dd05240a445c8bd505d
2019-10-31 14:57:44 -04:00
Suhas Daftuar c5377ffbbb [qa] Add shrinkdebugfile=0 to regtest bitcoin.conf
This helps avoid accidentally truncating the debug.log while manually
debugging.
2019-10-31 13:54:07 -04:00
John Newbery 60582d6060 [linter] Strip trailing / in path for git-subtree-check
git-subtree-check fails if the directory is given with a trailing slash,
eg:

```
> test/lint/git-subtree-check.sh src/univalue/
ERROR: src/univalue/ is not a subtree
```

Shell autocompletes will add the trailing slash when autofilling the
path name, which will therefore cause the script to fail.

Just ignore any trailing slash.
2019-10-31 11:53:46 -04:00
Luke Dashjr a6f6f77a86 QA: Add wallet_implicitsegwit to test the ability to transform keys between address types 2019-10-30 18:56:25 +00:00
Adam Jonas c98bd13e67 replace asserts in RPC code with CHECK_NONFATAL and add linter 2019-10-30 12:03:07 -04:00
Wladimir J. van der Laan 3c40bc6726
Merge #15921: validation: Tidy up ValidationState interface
3004d5a12d [validation] Remove fMissingInputs from AcceptToMemoryPool() (John Newbery)
c428622a5b [validation] Remove unused first_invalid parameter from ProcessNewBlockHeaders() (John Newbery)
7204c6434b [validation] Remove useless ret parameter from Invalid() (John Newbery)
1a37de4b31 [validation] Remove error() calls from Invalid() calls (John Newbery)
067981e492 [validation] Tidy Up ValidationResult class (John Newbery)
a27a2957ed [validation] Add CValidationState subclasses (John Newbery)

Pull request description:

  Carries out some remaining tidy-ups remaining after PR 15141:

  - split ValidationState into TxValidationState and BlockValidationState (commit from ajtowns)
  - various minor code style tidy-ups to the ValidationState class
  - remove the useless `ret` parameter from `ValidationState::Invalid()`
  - remove the now unused `first_invalid` parameter from `ProcessNewBlockHeaders()`
  - remove the `fMissingInputs` parameter from `AcceptToMemoryPool()`, and deal with missing inputs the same way as other errors by using the `TxValidationState` object.

  Tip for reviewers (thanks ryanofsky!): The first commit ("[validation] Add CValidationState subclasses" ) is huge and can be easier to start reviewing if you revert the rote, mechanical changes:

  Substitute the commit hash of commit "[validation] Add CValidationState subclasses" for <CommitHash> in the commands below.

  ```sh
  git checkout <CommitHash>
  git grep -l ValidationState | xargs sed -i 's/BlockValidationState\|TxValidationState/CValidationState/g'
  git grep -l ValidationResult | xargs sed -i 's/BlockValidationResult\|TxValidationResult/ValidationInvalidReason/g'
  git grep -l MaybePunish | xargs sed -i 's/MaybePunishNode\(ForBlock\|ForTx\)/MaybePunishNode/g'
  git diff HEAD^
  ```

  After that it's possible to easily see the mechanical changes with:

  ```sh
  git log -p -n1 -U0 --word-diff-regex=. <CommitHash>
  ```

ACKs for top commit:
  laanwj:
    ACK 3004d5a12d
  amitiuttarwar:
    code review ACK 3004d5a12d. Also built & ran tests locally.
  fjahr:
    Code review ACK 3004d5a12d . Only nit style change and pure virtual destructor added since my last review.
  ryanofsky:
    Code review ACK 3004d5a12d. Just whitespace change and pure virtual destructor added since last review.

Tree-SHA512: 511de1fb380a18bec1944ea82b513b6192df632ee08bb16344a2df3c40811a88f3872f04df24bc93a41643c96c48f376a04551840fd804a961490d6c702c3d36
2019-10-30 15:37:34 +01:00
MarcoFalke fa144e6fde
rpc: Add generatetodescriptor 2019-10-30 10:01:32 -04:00
John Newbery 3004d5a12d [validation] Remove fMissingInputs from AcceptToMemoryPool()
Handle this failure in the same way as all other failures: call Invalid()
with the reasons for the failure.
2019-10-29 15:46:45 -04:00
MarcoFalke 6a97e8a060
Merge #17260: Split some CWallet functions into new LegacyScriptPubKeyMan
f201ba59ff Refactor: Split up CWallet and LegacyScriptPubKeyMan and classes (Andrew Chow)
6702048f91 MOVEONLY: Move key handling code out of wallet to keyman file (Andrew Chow)
ab053ec6d1 Move wallet enums to walletutil.h (Andrew Chow)

Pull request description:

  Moves key management functions into a new class LegacyScriptPubKeyMan. First two commits are move-only commits which move stuff out of wallet.{h/cpp} and into newly created scriptpubkeyman.{h/cpp}. Third commit changes several things in CWallet to use LegacyScriptPubKeyMan.

  First step in the wallet boxes refactor. Note that LegacyScriptPubKeyMan and ScriptPubKeyMan cannot be used standalone yet and are still very much tied into CWallet with both accessing functions within each other. This PR is to help reduce review burden.

ACKs for top commit:
  Sjors:
    Code review ACK f201ba5.
  promag:
    Code review ACK f201ba59ff.
  ryanofsky:
    Code review ACK f201ba59ff
  MarcoFalke:
    ACK f201ba59ff

Tree-SHA512: bdc0d8595a06233fe003afcf968a38e0e8cc584a6a89c5bcd05309ac29dca852391802d46763ef81a108d146d0f40c79ea5438e87234ed12b4b8360c9aec94c0
2019-10-29 08:19:23 -04:00
Adam Jonas 436ad43643 Fix issue with conflicted mempool tx in listsinceblock
listsinceblock now checks that returned transactions are not
conflicting with any transactions that are filtered out by
the given blockhash

Co-Authored-By: Michael Chrostowski <michael.chrostowski@gmail.com>
2019-10-28 10:26:46 -04:00
fanquake badca85e2c
Merge #16202: p2p: Refactor network message deserialization
ed2dc5e48a Add override/final modifiers to V1TransportDeserializer (Pieter Wuille)
f342a5e61a Make resetting implicit in TransportDeserializer::Read() (Pieter Wuille)
6a91499496 Remove oversized message detection from log and interface (Pieter Wuille)
b0e10ff4df Force CNetMessage::m_recv to use std::move (Jonas Schnelli)
efecb74677 Use adapter pattern for the network deserializer (Jonas Schnelli)
1a5c656c31 Remove transport protocol knowhow from CNetMessage / net processing (Jonas Schnelli)
6294ecdb8b Refactor: split network transport deserializing from message container (Jonas Schnelli)

Pull request description:

  **This refactors the network message deserialization.**

  * It transforms the `CNetMessage` into a transport protocol agnostic message container.
  * A new class `TransportDeserializer` (unique pointer of `CNode`)  is introduced, handling the network buffer reading and the decomposing to a `CNetMessage`
  * **No behavioral changes** (in terms of disconnecting, punishing)
  * Moves the checksum finalizing into the `SocketHandler` thread (finalizing was in `ProcessMessages` before)

  The **optional last commit** makes the `TransportDeserializer` following an adapter pattern (polymorphic interface) to make it easier to later add a V2 transport protocol deserializer.

  Intentionally not touching the sending part.

  Pre-Requirement for BIP324 (v2 message transport protocol).
  Replacement for #14046 and inspired by a [comment](https://github.com/bitcoin/bitcoin/pull/14046#issuecomment-431528330) from sipa

ACKs for top commit:
  promag:
    Code review ACK ed2dc5e48a.
  marcinja:
    Code review ACK ed2dc5e48a
  ryanofsky:
    Code review ACK ed2dc5e48a. 4 cleanup commits added since last review. Unaddressed comments:
  ariard:
    Code review and tested ACK ed2dc5e.

Tree-SHA512: bab8d87464e2e8742529e488ddcdc8650f0c2025c9130913df00a0b17ecdb9a525061cbbbd0de0251b76bf75a8edb72e3ad0dbf5b79e26f2ad05d61b4e4ded6d
2019-10-28 09:15:59 -04:00
Wladimir J. van der Laan 9ae468a6d5
Merge #17192: util: Add CHECK_NONFATAL and use it in src/rpc
faeb666536 util: Add CHECK_NONFATAL and use it in src/rpc (MarcoFalke)

Pull request description:

  Fixes #17181

  Currently, we use `assert` in RPC code to document logic and code assumptions. However, it seems a bit extreme to abort all of Bitcoin Core on an assert failure in one of the RPC threads. I suggest to replace all `assert`s with a macro `CHECK_NONFATAL(condition)` that throws a runtime error when the condition evaluates to `false`. That runtime error will then be returned to the rpc caller and will include instructions to report the error to our issue tracker.

ACKs for top commit:
  practicalswift:
    ACK faeb666536
  laanwj:
    ACK faeb666536
  ryanofsky:
    Code review ACK faeb666536

Tree-SHA512: 9b748715a5e0767ac11f1324a95a3a6ec672a0e0658013492219223bda83ce4b1b447fd8183bbb235f7df5ef7dddda7666ad569544b4d61cc65f232ca7a800ec
2019-10-28 12:00:36 +01:00
Andrew Chow f201ba59ff Refactor: Split up CWallet and LegacyScriptPubKeyMan and classes
This moves CWallet members and methods dealing with keys to a new
LegacyScriptPubKeyMan class, and updates calling code to reference the new
class instead of CWallet.

Most of the changes are simple text replacements and variable substitutions
easily verified with:

    git log -p -n1 -U0 --word-diff-regex=.

The only nontrivial chunk of code added is the new LegacyScriptPubKeyMan class
declaration, but this code isn't new and is just selectively copied and moved
from the previous CWallet class declaration. This can be verified with:

    git log -p -n1 --color-moved=dimmed_zebra src/wallet/scriptpubkeyman.h src/wallet/wallet.h

or

    git diff HEAD~1:src/wallet/wallet.h HEAD:src/wallet/scriptpubkeyman.h

This commit does not change behavior.
2019-10-25 19:20:24 -04:00
Wladimir J. van der Laan b688b859db
Merge #17004: validation: Remove REJECT code from CValidationState
9075d13153 [docs] Add release notes for removal of REJECT reasons (John Newbery)
04a2f326ec [validation] Fix REJECT message comments (John Newbery)
e9d5a59e34 [validation] Remove REJECT code from CValidationState (John Newbery)
0053e16714 [logging] Don't log REJECT code when transaction is rejected (John Newbery)
a1a07cfe99 [validation] Fix peer punishment for bad blocks (John Newbery)

Pull request description:

  We no longer send BIP 61 REJECT messages, so there's no need to set
  a REJECT code in the CValidationState object.

  Note that there is a minor bug fix in p2p behaviour here. Because the
  call to `MaybePunishNode()` in `PeerLogicValidation::BlockChecked()` only
  previously happened if the REJECT code was > 0 and < `REJECT_INTERNAL`,
  then there are cases were `MaybePunishNode()` can get called where it
  wasn't previously:

  - when `AcceptBlockHeader()` fails with `CACHED_INVALID`.
  - when `AcceptBlockHeader()` fails with `BLOCK_MISSING_PREV`.

  Note that `BlockChecked()` cannot fail with an 'internal' reject code. The
  only internal reject code was `REJECT_HIGHFEE`, which was only set in
  ATMP.

  This reverts a minor bug introduced in 5d08c9c579.

ACKs for top commit:
  ariard:
    ACK 9075d13, changes since last reviewed are splitting them in separate commits to ease understanding and fix nits
  fjahr:
    ACK 9075d13153, confirmed diff to last review was fixing nits in docs/comments.
  ryanofsky:
    Code review ACK 9075d13153. Only changes since last review are splitting the main commit and updating comments

Tree-SHA512: 58e8a1a4d4e6f156da5d29fb6ad6a62fc9c594bbfc6432b3252e962d0e9e10149bf3035185dc5320c46c09f3e49662bc2973ec759679c0f3412232087cb8a3a7
2019-10-24 10:49:45 +02:00
Wladimir J. van der Laan 4258fd7377
Merge #17091: tests: Add test for loadblock option and linearize scripts
89339d1460 tests: Add test for loadblock option (Fabian Jahr)

Pull request description:

  Fixes #17019

  Was initially part of #17044 but as the test got larger it made sense to split it into its own commit as suggested in #17019 .

  This is testing the `-loadblock` option by using the scripts in `contrib/linearize` to generate a `bootstrap.dat` file and starting a disconnected node with it. So it is also testing the linearize scripts which were untested before and needed to be made available for the CI environment, hence they are added to `DIST_CONTRIB` in `Makefile.am`.

ACKs for top commit:
  laanwj:
    ACK 89339d1460

Tree-SHA512: aede0cd6e8b21194973f3633bc07fa2672d66a6f85dfe6a57cee2bb269a65d19ea49d5f9ed7914a173b3847c76e70257aa865f44bde170c1999d9655b4862d1c
2019-10-23 11:21:46 +02:00
Pieter Wuille 6a91499496
Remove oversized message detection from log and interface 2019-10-23 09:27:25 +02:00
Sebastian Falbesoner 8d8e5a79d0 test: use default address type (bech32) for wallet_bumpfee tests
The use of native segwit addresses (pure p2wpkh instead of p2sh-p2wpkh) leads
to smaller transaction sizes, needing adaption of some constants in the
following test cases:
    - test_dust_to_fee(): adaption of dust calculation
          (p2wpkh spend estimate of 67 is taken from src/policy/policy.cpp:GetDustThreshold())
    - test_maxtxfee_fails(): lowering -maxtxfee setting to trigger fail
2019-10-22 16:38:48 +02:00
Jeremy Rubin 4671fc3d9e Expand on wallet_balance.py comment from https://github.com/bitcoin/bitcoin/pull/16766\#issuecomment-527563982 2019-10-21 13:43:44 -07:00
Jeremy Rubin 5ffe0d1449 Update comment in test/functional/wallet_balance.py
Co-Authored-By: MarcoFalke <falke.marco@gmail.com>
2019-10-21 13:16:22 -07:00
Jeremy Rubin a550c58267 Update wallet_balance.py test to reflect new behavior 2019-10-21 13:16:22 -07:00
practicalswift 0616138a07 tests: Remove no longer needed UBSan suppressions (issues fixed). Add documentation. 2019-10-21 18:24:27 +00:00
Wladimir J. van der Laan a22b62481a
Merge #17070: wallet: Avoid showing GUI popups on RPC errors
facec1c643 wallet: Avoid showing GUI popups on RPC errors (MarcoFalke)

Pull request description:

  RPC errors and warnings are shown as popups in the GUI instead of being returned to the RPC caller. For example,

  ```
  $ ./src/bitcoin-cli loadwallet $(pwd)/./test/functional/data/wallets/high_minversion/
  error code: -4
  error message:
  Wallet loading failed.
  ```

  gives me a GUI popup and no reason why loading the wallet failed.

  After this pull request:

  ```
  $ ./src/bitcoin-cli loadwallet $(pwd)/./test/functional/data/wallets/high_minversion/
  error code: -4
  error message:
  Wallet loading failed: Error loading /home/marco/workspace/btc_bitcoin_core/./test/functional/data/wallets/high_minversion/wallet.dat: Wallet requires newer version of Bitcoin Core

ACKs for top commit:
  laanwj:
    Code review ACK facec1c643

Tree-SHA512: c8274bbb02cfcf71676eeec1e773e51fb3538cf93f82e7cb8536f4716d44ed819cdc162dfc039ac7386a4db381a734cdb27fd32567043a1180c02519fbcba194
2019-10-21 13:48:27 +02:00
Wladimir J. van der Laan fc1040acc0
Merge #17176: ci: Cleanup macOS runs
fa677d1801 ci: Remove redundant check for TRAVIS_OS_NAME (MarcoFalke)
fadccb263b doc: Document that GNU tools are required for linters (MarcoFalke)
4444704ca9 ci: Cleanup macOS runs (MarcoFalke)

Pull request description:

  * Remove a commented out cleanup task in `before_cache`
  * Remove the linter run on macOS, and document that GNU tools are required to run the linters

ACKs for top commit:
  Sjors:
    Code review ACK fa677d1801
  laanwj:
    ACK fa677d1801
  ryanofsky:
    Code review ACK fa677d1801 for new third commit replacing TRAVIS_OS_NAME check with NO_DEPENDS setting

Tree-SHA512: 9122a63bbe7887d9e379123152ea4ba44324cb18033b9e6b45bfdb1af665c10ea598564b9fcd57330d208a08e4696e41b4d6175f05f0843a3a76530da114f8c6
2019-10-21 12:20:47 +02:00
MarcoFalke faeb666536
util: Add CHECK_NONFATAL and use it in src/rpc 2019-10-18 17:19:36 -04:00
Jonas Schnelli 6294ecdb8b
Refactor: split network transport deserializing from message container 2019-10-18 08:56:06 +02:00
MarcoFalke 88eff969c2
Merge #17177: doc: Describe log files + consistent paths in test READMEs
9576614d2d doc: Describe log files + consistent paths in test READMEs (Martin Erlandsson)

Pull request description:

  picks up #15830

  I saw this was almost ready to merge but the test logging part was not 100% correct. I reworked that part, the rest is the same.

ACKs for top commit:
  GChuf:
    ACK 9576614d2d

Tree-SHA512: 3de7f1b0a1b0419df6e7b55964d00e715b6cb7874b1849ad6f120597610d7df4182c4b61b9c9691ce04f4e392ed3caead4c623374be2066ac31319e702d45d09
2019-10-17 14:35:21 -04:00
Martin Erlandsson 9576614d2d doc: Describe log files + consistent paths in test READMEs 2019-10-17 17:53:45 +02:00
MarcoFalke fadccb263b
doc: Document that GNU tools are required for linters 2019-10-17 10:52:11 -04:00
John Newbery eebcdfa86a [test] rename SegwitVersion1SignatureHash()
The function implementing segwit v0 signature hash was originally named
SegwitVersion1SignatureHash() (presumably before segwit v0 was named
segwit v0). Rename it to SegwitV0SignatureHash().

Also rename SignatureHash() to LegacySignatureHash() for disambiguation.
2019-10-14 17:13:05 -04:00
MarcoFalke b33c03b0cb
Merge #17124: test: speed up wallet_address_types by whitelisting peers (immediate tx relay)
fba4baa4fa test: speed up wallet_address_types by whitelisting peers (immediate tx relay) (Sebastian Falbesoner)

Pull request description:

  approaches another part of #16613 ("Functional test suite bottlenecks")

  As for `wallet_backup.py` (Commit 581c9be0d8), the
  bottleneck is in relaying transactions. By whitelisting the peers, the
  inventory is transmissioned immediately rather than on average every 5 seconds,
  speeding up the test significantly:

  before:
  ```
  $ time ./wallet_address_types.py
  real    1m30.072s
  user    0m6.478s
  sys     0m2.298s
  ```

  with this PR:
  ```
  $ time ./wallet_address_types.py
  real    0m26.785s
  user    0m5.525s
  sys     0m1.888s
  ```

ACKs for top commit:
  fanquake:
    ACK - fba4baa4fa

Tree-SHA512: 6728ae44bd8839426fa943d06af884e40c2d88de5d7807269a1e78ff987077160aa7e8d395f4468e6ca1d6f2110c7a03cd346a3339b256702f4cdabd285f7f86
2019-10-14 10:23:20 -04:00
MarcoFalke 6c7da0736d
Merge #17108: test: fix "tx-size-small" errors after default address change
32d665c265 test: fix "tx-size-small" errors after default address change (Sebastian Falbesoner)

Pull request description:

  Addresses #17043, affects RBF and BIP68 functional tests.

  The "tx-size-small" policy rule rejects transactions with a non-witness size of
  smaller than 82 bytes (see `src/validation.cpp:MemPoolAccept::PreChecks(...)`),
  which corresponds to a transaction with 1 segwit input and 1 P2WPKH output.

  Through the default address change, the created test transactions have segwit
  inputs now and sending to short scriptPubKeys might violate this rule. By
  bumping the dummy scriptPubKey size to 22 bytes (= the size of a P2WPKH
  scriptPubKey), on all occurences the problem is solved.

  The dummy scriptPubKey has the format:
      ```21 <21-byte-long string of 'a' or 1s>```

ACKs for top commit:
  instagibbs:
    reACK 32d665c265 just s/Bytes/bytes/
  MarcoFalke:
    ACK 32d665c265

Tree-SHA512: 80e0386ff3c3f462901ba5c1e5ef2cbf095d9c0a40c8c3cfeacd4a3ab676afe744aa95b9eed77b4b3eec88bed930b33aa718117ed0977f6374e858a2f3bd5c57
2019-10-14 10:14:46 -04:00
MarcoFalke 556820ee57
Merge #17009: tests: Add EvalScript(...) fuzzing harness
7e50abcc29 tests: Add EvalScript(...) fuzzing harness (practicalswift)
bebb637472 tests: Add FuzzedDataProvider fuzzing helper from the Chromium project (practicalswift)

Pull request description:

  Add `EvalScript(...)` fuzzing harness.

  To test this PR:

  We can run `contrib/devtools/test_fuzzing_harnesses.sh` (#17000) during five seconds to quickly verify that the newly added  fuzz harness seem to hit relevant code regions, that the fuzzing throughput seems reasonable, etc.

  `test_fuzzing_harnesses.sh eval 5` runs all fuzzers matching the regexp `eval` giving them five seconds of runtime each.

  ```
  $ CC=clang CXX=clang++ ./configure --enable-fuzz --with-sanitizers=address,fuzzer,undefined
  $ make
  $ contrib/devtools/test_fuzzing_harnesses.sh eval 5
  Testing fuzzer eval_script during 5 second(s)
  A subset of reached functions:
          NEW_FUNC[1/24]: 0x557b808742e0 in prevector<28u, unsigned char, unsigned int, int>::indirect_ptr(int) src/./prevector.h:161
          NEW_FUNC[2/24]: 0x557b80875460 in prevector<28u, unsigned char, unsigned int, int>::indirect_ptr(int) const src/./prevector.h:162
          NEW_FUNC[6/9]: 0x557b81acdaa0 in popstack(std::vector<std::vector<unsigned char, std::allocator<unsigned char> >, std::allocator<std::vector<unsigned char, std::allocator<unsigned char> > > >&) src/script/interpreter.cpp:57
          NEW_FUNC[5/16]: 0x557b809f1bf0 in CScriptNum::serialize(long const&) src/./script/script.h:326
          NEW_FUNC[4/6]: 0x557b817c93d0 in CScriptNum::CScriptNum(std::vector<unsigned char, std::allocator<unsigned char> > const&, bool, unsigned long) src/./script/script.h:225
          NEW_FUNC[5/6]: 0x557b817cbb80 in CScriptNum::set_vch(std::vector<unsigned char, std::allocator<unsigned char> > const&) src/./script/script.h:360
          NEW_FUNC[0/11]: 0x557b80a88170 in CHash256::Write(unsigned char const*, unsigned long) src/./hash.h:34
          NEW_FUNC[1/11]: 0x557b80a88270 in CHash256::Finalize(unsigned char*) src/./hash.h:28
          NEW_FUNC[5/11]: 0x557b81affdb0 in CSHA256::CSHA256() src/crypto/sha256.cpp:644
          NEW_FUNC[6/11]: 0x557b81affe80 in (anonymous namespace)::sha256::Initialize(unsigned int*) src/crypto/sha256.cpp:66
          NEW_FUNC[7/11]: 0x557b81b00460 in CSHA256::Write(unsigned char const*, unsigned long) src/crypto/sha256.cpp:649
          NEW_FUNC[8/11]: 0x557b81b009a0 in CSHA256::Finalize(unsigned char*) src/crypto/sha256.cpp:675
          NEW_FUNC[9/11]: 0x557b81b015e0 in CSHA256::Reset() src/crypto/sha256.cpp:692
          NEW_FUNC[10/11]: 0x557b81b01d90 in (anonymous namespace)::sha256::Transform(unsigned int*, unsigned char const*, unsigned long) src/crypto/sha256.cpp:79
          NEW_FUNC[0/1]: 0x557b808cc180 in BaseSignatureChecker::CheckLockTime(CScriptNum const&) const src/./script/interpreter.h:153
          NEW_FUNC[0/2]: 0x557b81ab5640 in CastToBool(std::vector<unsigned char, std::allocator<unsigned char> > const&) src/script/interpreter.cpp:36
          NEW_FUNC[0/1]: 0x557b817c9c30 in CScriptNum::getint() const src/./script/script.h:312
          NEW_FUNC[0/1]: 0x557b81ae1df0 in CScriptNum::operator-=(long const&) src/./script/script.h:298
          NEW_FUNC[0/5]: 0x557b81af5670 in CRIPEMD160::CRIPEMD160() src/crypto/ripemd160.cpp:243
          NEW_FUNC[1/5]: 0x557b81af5740 in (anonymous namespace)::ripemd160::Initialize(unsigned int*) src/crypto/ripemd160.cpp:25
          NEW_FUNC[2/5]: 0x557b81af5b00 in CRIPEMD160::Write(unsigned char const*, unsigned long) src/crypto/ripemd160.cpp:248
          NEW_FUNC[3/5]: 0x557b81af5fa0 in (anonymous namespace)::ripemd160::Transform(unsigned int*, unsigned char const*) src/crypto/ripemd160.cpp:55
          NEW_FUNC[4/5]: 0x557b81af8d60 in CRIPEMD160::Finalize(unsigned char*) src/crypto/ripemd160.cpp:274
          NEW_FUNC[0/16]: 0x557b80857a30 in CScript::operator<<(std::vector<unsigned char, std::allocator<unsigned char> > const&) src/./script/script.h:462
          NEW_FUNC[1/16]: 0x557b80872670 in prevector<28u, unsigned char, unsigned int, int>::insert(prevector<28u, unsigned char, unsigned int, int>::iterator, unsigned char const&) src/./prevector.h:342
          NEW_FUNC[2/16]: 0x557b80872e00 in void prevector<28u, unsigned char, unsigned int, int>::insert<__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char> > > >(prevector<28u, unsigned char, unsigned int, int>::iterator, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char> > >, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char> > >) src/./prevector.h:368
          NEW_FUNC[3/16]: 0x557b80873630 in prevector<28u, unsigned char, unsigned int, int>::capacity() const src/./prevector.h:295
          NEW_FUNC[4/16]: 0x557b80874ed0 in void prevector<28u, unsigned char, unsigned int, int>::fill<prevector<28u, unsigned char, unsigned int, int>::const_iterator>(unsigned char*, prevector<28u, unsigned char, unsigned int, int>::const_iterator, prevector<28u, unsigned char, unsigned int, int>::const_iterator) src/./prevector.h:204
          NEW_FUNC[5/16]: 0x557b808cc0f0 in BaseSignatureChecker::CheckSig(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, CScript const&, SigVersion) const src/./script/interpreter.h:148
          NEW_FUNC[6/16]: 0x557b809edb10 in CScript::operator=(CScript&&) src/./script/script.h:390
          NEW_FUNC[7/16]: 0x557b809f8ec0 in void prevector<28u, unsigned char, unsigned int, int>::insert<prevector<28u, unsigned char, unsigned int, int>::const_iterator>(prevector<28u, unsigned char, unsigned int, int>::iterator, prevector<28u, unsigned char, unsigned int, int>::const_iterator, prevector<28u, unsigned char, unsigned int, int>::const_iterator) src/./prevector.h:368
          NEW_FUNC[8/16]: 0x557b809f9260 in prevector<28u, unsigned char, unsigned int, int>::swap(prevector<28u, unsigned char, unsigned int, int>&) src/./prevector.h:451
          NEW_FUNC[9/16]: 0x557b81ab58c0 in CheckSignatureEncoding(std::vector<unsigned char, std::allocator<unsigned char> > const&, unsigned int, ScriptError_t*) src/script/interpreter.cpp:200
          NEW_FUNC[10/16]: 0x557b81ab6f30 in FindAndDelete(CScript&, CScript const&) src/script/interpreter.cpp:254
          NEW_FUNC[11/16]: 0x557b81acdc20 in CheckPubKeyEncoding(std::vector<unsigned char, std::allocator<unsigned char> > const&, unsigned int, SigVersion const&, ScriptError_t*) src/script/interpreter.cpp:217
          NEW_FUNC[12/16]: 0x557b81ad3890 in IsCompressedOrUncompressedPubKey(std::vector<unsigned char, std::allocator<unsigned char> > const&) src/script/interpreter.cpp:63
          NEW_FUNC[13/16]: 0x557b81ad8830 in CScript::GetOp(prevector<28u, unsigned char, unsigned int, int>::const_iterator&, opcodetype&) const src/./script/script.h:505
          NEW_FUNC[14/16]: 0x557b81ae21a0 in prevector<28u, unsigned char, unsigned int, int>::prevector<prevector<28u, unsigned char, unsigned int, int>::const_iterator>(prevector<28u, unsigned char, unsigned int, int>::const_iterator, prevector<28u, unsigned char, unsigned int, int>::const_iterator) src/./prevector.h:246
          NEW_FUNC[0/1]: 0x557b81ae1a40 in CScriptNum::operator+=(long const&) src/./script/script.h:290
          NEW_FUNC[0/5]: 0x557b81af9760 in CSHA1::CSHA1() src/crypto/sha1.cpp:150
          NEW_FUNC[1/5]: 0x557b81af9830 in (anonymous namespace)::sha1::Initialize(unsigned int*) src/crypto/sha1.cpp:32
          NEW_FUNC[2/5]: 0x557b81af9bf0 in CSHA1::Write(unsigned char const*, unsigned long) src/crypto/sha1.cpp:155
          NEW_FUNC[3/5]: 0x557b81afa090 in (anonymous namespace)::sha1::Transform(unsigned int*, unsigned char const*) src/crypto/sha1.cpp:47
          NEW_FUNC[4/5]: 0x557b81afc5e0 in CSHA1::Finalize(unsigned char*) src/crypto/sha1.cpp:181
          NEW_FUNC[0/1]: 0x557b81ada4f0 in CScriptNum::operator-() const src/./script/script.h:278
          NEW_FUNC[0/1]: 0x557b808cc210 in BaseSignatureChecker::CheckSequence(CScriptNum const&) const src/./script/interpreter.h:158
          NEW_FUNC[0/1]: 0x557b81ab5c00 in IsValidSignatureEncoding(std::vector<unsigned char, std::allocator<unsigned char> > const&) src/script/interpreter.cpp:107
  stat::number_of_executed_units: 9728
  stat::average_exec_per_sec:     1621
  stat::new_units_added:          844
  stat::slowest_unit_time_sec:    0
  stat::peak_rss_mb:              326
  Number of unique code paths taken during fuzzing round: 583

  Tested fuzz harnesses seem to work as expected.
  ```

ACKs for top commit:
  MarcoFalke:
    ACK 7e50abcc29

Tree-SHA512: 4874ab28efb4219c24a4cfc9be901a3297d1973f43acadec415c2e1d6843e4e661f90e8f9695849373775a4556884cdcc8862a092246ae0383b844c37c1627d5
2019-10-14 09:28:03 -04:00
Sebastian Falbesoner 32d665c265 test: fix "tx-size-small" errors after default address change
Addresses #17043, affects RBF and BIP68 functional tests.

The "tx-size-small" policy rule rejects transactions with a non-witness size of
smaller than 82 bytes (see src/validation.cpp:MemPoolAccept::PreChecks(...)),
which corresponds to a transaction with 1 segwit input and 1 P2WPKH output.

Through the default address change, the created test transactions have segwit
inputs now and sending to short scriptPubKeys might violate this rule. By
bumping the dummy scriptPubKey size to 22 bytes (= the size of a P2WPKH
scriptPubKey), on all occurences the problem is solved.

The dummy scriptPubKey has the format:
    21 <21-byte-long string of 'a' or 1s>

former commit messages, now squashed:
test: rbf, bip68: use constant DUMMY_P2WPKH_SCRIPT for bumped scriptPubKey
test: rbf, bip68: use constant DUMMY_P2WPKH_SCRIPT for dummy scriptPubKeys (b'a' * 35)
test: rbf, bip68: comment DUMMY_P2WPKH_SCRIPT constant, put into common (new) module
2019-10-14 15:03:11 +02:00
Sebastian Falbesoner fba4baa4fa test: speed up wallet_address_types by whitelisting peers (immediate tx relay)
approaches another part of #16613 ("Functional test suite bottlenecks")

As for wallet_backup.py (Commit 581c9be0d8), the
bottleneck is in relaying transactions. By whitelisting the peers, the
inventory is transmissioned immediately rather than on average every 5 seconds,
speeding up the test significantly:

before:
$ time ./wallet_address_types.py
real    1m30.072s
user    0m6.478s
sys     0m2.298s

with this PR:
$ time ./wallet_address_types.py
real    0m26.785s
user    0m5.525s
sys     0m1.888s
2019-10-13 21:11:37 +02:00
Fabian Jahr 89339d1460 tests: Add test for loadblock option 2019-10-13 13:09:35 +02:00
Sebastian Falbesoner 581c9be0d8 test: speedup wallet_backup by whitelisting peers (immediate tx relay)
approaches part of #16613 ("Functional test suite bottlenecks")

The majority of the test time is spent in sync_mempools() after sending to
addresses, i.e. the bottleneck is in relaying transactions. By whitelisting the
peers via -whitelist, the inventory is transmissioned immediately rather than
on average every 5 seconds, speeding up the test by at least a factor of two:

before:
$ time ./wallet_backup.py
real    2m2.523s
user    0m6.093s
sys 0m2.454s

with this PR:
$ time ./wallet_backup_with_whitelist.py
real    0m36.570s
user    0m5.365s
sys 0m1.696s

Note that the test is not deterministic (the sendtoaddress RPC in function
one_send() is executed with a probability of 50%), hence the times could vary
between individual runs.
2019-10-13 02:50:08 +02:00
practicalswift bebb637472 tests: Add FuzzedDataProvider fuzzing helper from the Chromium project
Source: https://cs.chromium.org/chromium/src/third_party/libFuzzer/src/utils/FuzzedDataProvider.h?rcl=b9f51dc8c98065df0c8da13c051046f5bab833db
2019-10-10 21:13:33 +00:00
MarcoFalke d5a770b70d
Merge #16973: test: Fix combine_logs.py for AppVeyor build
d478a472eb test: Fix combine_logs.py for AppVeyor build (Martin Zumsande)

Pull request description:

  Fixes #16894

  This fixes the problem of AppVeyor builds not showing `debug.log` if a functional test fails, because the windows separator `\` doesn't work together with the regex in `combine_logs.py`.

  A fix was already attempted in  #16896, however, that PR became inactive and was marked "up for grabs", plus it's a really small change.

  As suggested by jamesob, this PR uses `pathlib`: For the glob and to convert the path to a posix-style string, it leaves the regex as is (in contrast to #16896 which adjusted the regex).

  I tested this locally on Windows and Ubuntu.

Top commit has no ACKs.

Tree-SHA512: 603b4359b6009b6da874c30f69759acda03730ee5747898a0fe957a5fc37ee9ba07858c6aa2169bf4c40521f37e47138e8314d698652ea2760fa0a3f76b890bd
2019-10-10 13:19:10 -04:00
John Newbery 0053e16714 [logging] Don't log REJECT code when transaction is rejected
Remove the BIP61 REJECT code from error messages and logs when a
transaction is rejected.

BIP61 support was removed from Bitcoin Core in
fa25f43ac5. The REJECT codes will be
removed from the codebase entirely in the following commit.
2019-10-10 11:19:42 -04:00
fanquake b1de33d29a
Merge #16821: Fix bug where duplicate PSBT keys are accepted
9743432034 Fix bug where duplicate PSBT keys are accepted (John L. Jegutanis)

Pull request description:

  As per the BIP 174 spec a PSBT key cannot be duplicated,
  however the current code accepts key duplication.
  The PSBT key/value entries can be duplicated when the value
  is `empty()` or `IsNull()` for `CScript` or `CTxOut` respectively
  and if those key/value entries are serialized before the non-empty ones.

  For example, the following PSBT, included in the test vectors,
  contains a duplicate field:

  ```
  // magic
  70736274ff

  // global tx
  //// key
  0100
  //// value
  2a02000000000140420f000000000017a9146e91b72d5593e7d4391e2ff44e91e985c31641f08700000000
  //// separator
  00

  // no inputs

  // outputs
  //// key PSBT_OUT_WITNESSSCRIPT
  0101
  //// value (empty script)
  00
  //// key PSBT_OUT_WITNESSSCRIPT (same as the above)
  0101
  //// value (an OP_RETURN script)
  016a
  //// separator
  00
  ```

ACKs for top commit:
  achow101:
    ACK 9743432034
  instagibbs:
    code review ACK 9743432034

Tree-SHA512: 34f4b34c8e6561c6a6ab745cdd319f6687eac6f7cecc735c94035eeca8c5157e17a27f2ae853dbaa6634fcd5a8f4e1c6cc13d1ebd7e563459665d72bb147cc1e
2019-10-09 09:18:27 -04:00
Wladimir J. van der Laan c08bf2b574
Merge #15437: p2p: Remove BIP61 reject messages
fa25f43ac5 p2p: Remove BIP61 reject messages (MarcoFalke)

Pull request description:

  Reject messages (BIP 61) appear in the following settings:

  * Parsing of reject messages (in case `-debug=net` is set, off by default). This has only been used for a single `LogPrint` call for several releases now. Such logging is completely meaningless to us and should thus be removed.

  * The sending of reject messages (in case `-enablebip61` is set, off by default). This can be used to debug a node that is under our control. Instead of hacking this debugging into the p2p protocol, it could be more easily achieved by parsing the debug log. (Use `-printtoconsole` to have it as stream, or read from the `debug.log` file like our python function `assert_debug_log` in the test framework does)

  Having to maintain all of this logic and code to accommodate debugging, which can be achieved by other means a lot easier, is a burden. It makes review on net processing changes a lot harder, since the reject message logic has to be carried around without introducing any errors or DOS vectors.

ACKs for top commit:
  jnewbery:
    utACK fa25f43ac5
  laanwj:
    I'm still not 100% convinced that I like getting rid of BIP61 conceptually, but apparently everyone wants it, code review ACK fa25f43ac5.
  ryanofsky:
    Code review ACK fa25f43ac5

Tree-SHA512: daf55254202925e56be3d6cfb3c1c804e7a82cecb1dd1e5bd7b472bae989fd68ac4f21ec53fc46751353056fd645f7f877bebcb0b40920257991423a3d99e0be
2019-10-09 11:51:58 +02:00
fanquake 520d140e6e
Merge #17056: descriptors: Introduce sortedmulti descriptor
4bb660be90 Add release note (Andrew Chow)
ed96b295d7 Update descriptors.md to include sortedmulti (Andrew Chow)
80be78ea75 Test sortedmulti descriptor using BIP 67 tests (Andrew Chow)
6f588fd227 Add sortedmulti descriptor and unit tests (Andrew Chow)

Pull request description:

  Adds a `sortedmulti()` descriptor as mentioned in https://github.com/bitcoin/bitcoin/pull/17023#issuecomment-537596416.

  `sortedmulti()` works in the same way as `multi` does but sorts the pubkeys in the resulting scripts in lexicographic order as described in [BIP67](https://github.com/bitcoin/bips/blob/master/bip-0067.mediawiki). Note that this does not add support for BIP67 nor is BIP67 fully supported by this descriptor (which is why it is not named `multi67()`) as it does not require compressed pubkeys.

  Tests from BIP67 were added and documentation was updated.

ACKs for top commit:
  instagibbs:
    re-ACK 4bb660be90
  Sjors:
    re-ACK 4bb660be90

Tree-SHA512: 93b21112a74ebe0bf316d8f3e0291f69fd975cf0a29332f9728e7b880cad312b8b14007e86adcd7899f117b9303cbcf4cb35f3bb2f2f648d1a446f83f75a70a5
2019-10-08 14:26:26 -04:00
Andrew Chow 80be78ea75 Test sortedmulti descriptor using BIP 67 tests 2019-10-08 13:56:56 -04:00
MarcoFalke facec1c643
wallet: Avoid showing GUI popups on RPC errors 2019-10-08 13:02:14 -04:00
Wladimir J. van der Laan 866fd2888f
Merge #17030: test: Fix Python Docstring to include all Args.
8acd58927a Fix Python Docstring to include all Args. (John Bampton)

Pull request description:

  Found a Python function that had incorrect and missing arguments in its Docstring.

ACKs for top commit:
  laanwj:
    ACK 8acd58927a

Tree-SHA512: 936f275f29a700d630bb479b5283e47b66f2df76d8b8c053f594e6aedf783cc98a29c924c3a46613f112dfc884acb50f21a0b18f96d939e887b12b921ef2e10f
2019-10-08 10:29:28 +02:00
John L. Jegutanis 9743432034 Fix bug where duplicate PSBT keys are accepted
As per the BIP 174 spec a PSBT key cannot be duplicated,
however the current code accepts key duplication.
The PSBT key/value entries can be duplicated when the value
is `empty()` or `IsNull()` for `CScript` or `CTxOut` respectively
and if those key/value entries are serialized before the non-empty ones.

For example, the following PSBT, included in the test vectors,
contains a duplicate field:

```
// magic
70736274ff

// global tx
//// key
0100
//// value
2a02000000000140420f000000000017a9146e91b72d5593e7d4391e2ff44e91e985c31641f08700000000
//// separator
00

// no inputs

// outputs
//// key PSBT_OUT_WITNESSSCRIPT
0101
//// value (empty script)
00
//// key PSBT_OUT_WITNESSSCRIPT (same as the above)
0101
//// value (an OP_RETURN script)
016a
//// separator
00
```
2019-10-08 01:45:36 +03:00
John Bampton 8acd58927a Fix Python Docstring to include all Args. 2019-10-06 10:37:50 +10:00
Gregory Sanders eb7b781659 modify p2p_feefilter test to catch rounding error 2019-10-03 14:03:27 -04:00
MarcoFalke a689c11907
Merge #16524: Wallet: Disable -fallbackfee by default
ea4cc3a7b3 Truly decouple wallet from chainparams for -fallbackfee (Jorge Timón)

Pull request description:

  Before it was 0 by default for main and 20000 for test and regtest.
  Now it is 0 by default for all chains, thus there's no need to call Params().

  Also now the default for main is properly documented.

  Suggestion for release notes:

  -fallbackfee was 0 (disabled) by default for the main chain, but 20000 by default for the test chains. Now it is 0 by default for all chains. Testnet and regtest users will have to add fallbackfee=20000 to their configuration if they weren't setting it and they want it to keep working like before.

  Should I propose them to the wiki for the release notes or only after merge?

  For more context, see https://github.com/bitcoin/bitcoin/pull/16402#issuecomment-515701042

ACKs for top commit:
  MarcoFalke:
    ACK ea4cc3a7b3

Tree-SHA512: fdfaba5d813da4221e405e0988bef44f3856d10f897a94f9614386d14b7716f4326ab8a6646e26d41ef3f4fa61b936191e216b1b605e9ab0520b0657fc162e6c
2019-10-02 13:42:57 -04:00
Jorge Timón ea4cc3a7b3
Truly decouple wallet from chainparams for -fallbackfee
Before it was 0 by default for main and 20000 for test and regtest.
Now it is 0 by default for all chains, thus there's no need to call Params().

Also now the default for main is properly documented
2019-10-02 18:10:07 +02:00
Wladimir J. van der Laan fecc1be231
Merge #16884: wallet: Change default address type to bech32
71d4eddf42 Add release note for bech32 by default in wallet (Gregory Sanders)
b34f0180e3 Revert "gui: Generate bech32 addresses by default (take 2, fixup)" (Gregory Sanders)
f50785ab56 Change default address type to bech32 (Gregory Sanders)

Pull request description:

ACKs for top commit:
  MarcoFalke:
    re-ACK 71d4eddf42 (only change is restore mimick behavior)
  laanwj:
    ACK 71d4eddf42

Tree-SHA512: 3c49a1b51c49f3a762ad08985167ca1b89b0177ae20ab6d5883f1f74dde7a155921c1b855a842199bbf32f563c56b33f8b603bc842637bdcb121001023d454b6
2019-10-02 17:46:01 +02:00
Wladimir J. van der Laan ccaef6c28b
Merge #16908: txmempool: Make entry time type-safe (std::chrono)
faec689bed txmempool: Make entry time type-safe (std::chrono) (MarcoFalke)
faaa1f01da util: Add count_seconds time helper (MarcoFalke)
1111170f2f test: mempool entry time is persisted (MarcoFalke)

Pull request description:

  This changes the type of the entry time of txs into the mempool from `int64_t` to `std::chrono::seconds`.

  The benefits:
  * Documents the type for developers
  * Type violations result in compile errors
  * After compilation, the two are equivalent (at no run time cost)

ACKs for top commit:
  ajtowns:
    utACK faec689bed
  laanwj:
    ACK faec689bed

Tree-SHA512: d958e058755d1a1d54cef536a8b30a11cc502b7df0d6ecf84a0ab1d38bc8105a67668a99cd5087a444f6de2421238111c5fca133cdf8e2e2273cb12cb6957845
2019-10-02 16:55:36 +02:00
MarcoFalke fa25f43ac5
p2p: Remove BIP61 reject messages 2019-10-02 10:39:14 -04:00
Wladimir J. van der Laan 8afa602f30
Merge #16727: wallet: Explicit feerate for bumpfee
c812aba394 test bumpfee fee_rate argument (ezegom)
9f25de3d9e rpc bumpfee check fee_rate argument (ezegom)
88e5f997df rpc bumpfee: add fee_rate argument (ezegom)
1a4c791cf4 rpc bumpfee: move feerate estimation logic into separate method (ezegom)

Pull request description:

  Taking over for https://github.com/bitcoin/bitcoin/pull/16492 which seems to have gone inactive.

  Only minor commit cleanups, rebase, and some help text fixes on top of previous PR. Renamed `feeRate` to `fee_rate` to reflect updated guidelines.

ACKs for top commit:
  Sjors:
    Code review ACK c812aba
  laanwj:
    ACK c812aba394

Tree-SHA512: 5f7f51bd780a573ccef1ccd72b0faf3e5d143f6551060a667560c5163f7d9480e17e73775d1d7bcac0463f3b6b4328f0cff7b27e39483bddc42a530f4583ce30
2019-10-02 15:55:19 +02:00
MarcoFalke 696b5eb179
Merge #16987: test: Correct docstring param name.
e28d8f8936 Correct docstring param name. (John Bampton)

Pull request description:

  Small fix to correct the Python docstring.

ACKs for top commit:
  laanwj:
    ACK e28d8f8936
  MarcoFalke:
     ACK e28d8f8

Tree-SHA512: 7bec1c6b166c768dd69fc6b94eb80ceeaa0258985b9a11956e336940d403785e7d09d0084d9b870b637ec784db044cf4c0f8ac3f0fcdf431090f003016ef13a9
2019-09-30 12:12:59 -04:00
Wladimir J. van der Laan c3a8e097b1
Merge #16991: qa: Fix service flag comparison check in rpc_net test (luke-jr)
9c23ebd6b1 qa: Fix service flag comparison check in rpc_net test (Luke Dashjr)

Pull request description:

  Rebase of #16936

ACKs for top commit:
  darosior:
    ACK 9c23ebd6b1

Tree-SHA512: 74f287740403da1040ab1e235ef6eba4e304f3ee5d57a3b25d1e2e1f2f982d256528d398a4d6cb24ba393798e680a8f46cd7dae54ed84ab2c747e96288f1f884
2019-09-30 15:32:18 +02:00
ezegom c812aba394 test bumpfee fee_rate argument 2019-09-30 09:31:53 -04:00
Luke Dashjr 9c23ebd6b1 qa: Fix service flag comparison check in rpc_net test 2019-09-30 11:45:47 +02:00
Wladimir J. van der Laan e2ce392aec test: Avoid whitespace linting in qt translations 2019-09-30 09:55:54 +02:00
Wladimir J. van der Laan 9edb2b6550
Merge #16953: doc: Improve test READMEs
43e7d576f5 doc: Improve test READMEs (Fabian Jahr)

Pull request description:

  General improvements on READMEs for unit tests and functional tests:
  - Give unit test readme a headline
  - Move general information on `src/test` folder to the top
  - Add information on logging and debugging unit tests
  - Improve debugging and logging information in functional testing
  - Include all available log levels in functional tests

ACKs for top commit:
  laanwj:
    ACK 43e7d576f5

Tree-SHA512: 22b27644992ba5d99a885cd51b7a474806714396fcea1fd2d6285e41bdf3b28835ad8c81449099e3ee15a63d57b3ab9acb89c425d9855ed1d9b4af21db35ab03
2019-09-30 09:27:35 +02:00
John Bampton e28d8f8936 Correct docstring param name. 2019-09-30 12:15:18 +10:00
Wladimir J. van der Laan a6c8aed1f1
Merge #16817: rpc: Fix casing in getblockchaininfo to be inline with other fields
1a02edb3f2 [RPC] Fix casing in getblockchaininfo to be inline with the rest of the response (Dan Gershony)

Pull request description:

  The response in the RPC result `startTime` is camel cased while the rest of the response seems to be lower cased.

  If this was intentional please ignore and close this PR.

  Note: RPC field case changes might break existing callers

ACKs for top commit:
  laanwj:
    ACK 1a02edb3f2

Tree-SHA512: 6f0eaf2b4aaf73c9a9bf1fbd4af59af5f95fc012fa88f94e050e6ae273b3ad647f5729df53bfce91e1a925fe4fd7b14818908bb6131a81413a555137d1007d7c
2019-09-27 15:11:00 +02:00
Martin Zumsande d478a472eb test: Fix combine_logs.py for AppVeyor build 2019-09-27 12:40:20 +02:00
Gregory Sanders f50785ab56 Change default address type to bech32 2019-09-26 16:23:32 -04:00
Fabian Jahr 43e7d576f5 doc: Improve test READMEs 2019-09-26 19:04:58 +02:00
Dan Gershony 1a02edb3f2 [RPC] Fix casing in getblockchaininfo to be inline with the rest of the response
The response in the RPC result `starttime` is camel cased while the rest of the response seems to be lower cased.

If this was intentional please ignore this PR.

Note: case might break existing callers

Reflect the change in the test data

Change to snake case
2019-09-26 15:20:55 +01:00
MarcoFalke 4c4ff4911a
Merge #16961: test: Remove python dead code linter
f4beb4996d test: Remove python dead code linter (Wladimir J. van der Laan)

Pull request description:

  Primarily I'd like to remove this because it is very imprecise, due to Python's dynamic nature, giving it a large list of false positives that need to be listed as exceptions. See for example #16906.

  It's also a frequent source of complaints. I'm doubtful of the usefulness of checking for dead code in a linter in the first place.
  Having some dead code in the test framework for a while is not a
  disaster.

ACKs for top commit:
  sdaftuar:
    utACK f4beb4996d
  practicalswift:
    ACK f4beb4996d -- diff looks correct
  jamesob:
    ACK f4beb4996d

Tree-SHA512: 329b1555210311d5d15799fd2cb794b3208b0ac4d8a2ffaf4dece1bcc3e0e8b1fe952d5e7a394f94a98919cab579fb579eae7db2a796cc9a1a42ef495dd17507
2019-09-25 13:14:22 -04:00
Wladimir J. van der Laan 742cd77f6f
Merge #16929: test: follow-up to rpc: default maxfeerate value as BTC/kB
6659810e2f test: use named args for sendrawtransaction calls (Jon Atack)
5c1cd78b7e doc: improve rawtransaction code/test docs (Jon Atack)
acc14c5093 test: fix incorrect value in rpc_rawtransaction.py (Jon Atack)

Pull request description:

  Follow-up to PR #16521.

  - Fix incorrect value in rpc_rawtransaction test as per https://github.com/bitcoin/bitcoin/pull/16521/files#r325842308
  - Improve the code docs
  - Use named arguments as per https://github.com/bitcoin/bitcoin/pull/16521/files#r310715127

  Happy to squash or keep only the first commit if the others are too fixup-y.

ACKs for top commit:
  laanwj:
    ACK 6659810e2f

Tree-SHA512: bf5258f23802ab3ba3defb8791097e08e63f3e2af21023f832cd270dc88d1fa04349e921d69f9f5fedac5dce5cd3c1cc46b48febbede4bc18dccb8be994565b2
2019-09-25 11:51:31 +02:00