Commit Graph

4216 Commits

Author SHA1 Message Date
Pavel Safronov
467fe5779c test: Correct MyPy typing for subtest decorator 2021-11-11 08:06:38 +00:00
MarcoFalke
4a8707741d
Merge bitcoin/bitcoin#22872: log: improve checkaddrman logging with duration in milliseconds
22b44fc696 p2p: improve checkaddrman logging with duration in milliseconds (Jon Atack)
ec65bed00e log, timer: add LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE macro (Jon Atack)
325da75a53 log, timer: allow not repeating log message on completion (Jon Atack)

Pull request description:

  This patch:
  - updates the `logging/timer.h::Timer` class to allow not repeating the log message on completion
  - adds a `LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE` macro that prints the descriptive message when logging the start but not when logging the completion
  - updates the checkaddrman logging to log the duration, and renames the function like the `-checkaddrman` configuration option in order to prefix every log message with `CheckAddrman` instead of the longer, less pleasant, and different-from-checkaddrman `ForceCheckAddrman` (the Doxygen documentation on the function already makes clear that it is unaffected by `m_consistency_check_ratio`).

  before
  ```
  2021-09-21T18:42:50Z [opencon] Addrman checks started: new 64864, tried 1690, total 66554
  2021-09-21T18:42:50Z [opencon] Addrman checks completed successfully
  ```

  after
  ```
  2021-09-21T18:42:50Z [opencon] CheckAddrman: new 64864, tried 1690, total 66554 started
  2021-09-21T18:42:50Z [opencon] CheckAddrman: completed (76.21ms)
  ```

  To test, build and run bitcoind with `-debug=addrman -checkaddrman=<n>` for a value of `n` in the range of, say, 10 to 40.

ACKs for top commit:
  laanwj:
    Code review ACK 22b44fc696

Tree-SHA512: 658c0dfaaa9d07092e2418f2d05007c58cc35be6593f22b3c592ce793334a885dd92dacc46bdeddc9d37939cf11174660a094c07c0fa117fbb282953aa45a94d
2021-11-10 17:38:45 +01:00
W. J. van der Laan
ed479497bd
Merge bitcoin/bitcoin#23398: rpc: add return message to savemempool RPC
aa1a4c9204 Add file validation to savemempool RPC test (lsilva01)
871e64d22f Add filename to savemempool RPC result (lsilva01)

Pull request description:

  Currently, if the user calls the `savemempool` RPC method, there is no way to know
  where the file was created (unless the user knows internal implementation details).

  This PR adds a return message stating the file name and path where the mempool was saved and changes `mempool_persist.py` to validate this new return message.

ACKs for top commit:
  laanwj:
    Code review ACK aa1a4c9204

Tree-SHA512: e8b1dd0a8976e5eb15f7476c9651e492d2c621a67e0b726721fa7a2ae0ddd272ee28b87a2d0c650bd635e07fa96bdefe77bece4deb6486ef3ee9a4f83423a840
2021-11-10 14:20:28 +01:00
W. J. van der Laan
8f86820ff8
Merge bitcoin/bitcoin#23370: test: Add ios_base::width tsan suppression
96c7db9373 test: Add ios_base::width tsan suppression (Hennadii Stepanov)

Pull request description:

  This PR:
  - adds tsan suppression for intermittent failures in CI
  ```
  SUMMARY: ThreadSanitizer: data race /usr/lib/llvm-12/bin/../include/c++/v1/ios:523:12 in std::__1::ios_base::width() const
  ```

  - fixes #23366

ACKs for top commit:
  laanwj:
    Concept and code review ACK 96c7db9373

Tree-SHA512: fcad296e8da4a6d94dcbb011c3d9b3d07f6983818be16cfff8341a035fa6abe2777ae72409c9bc83083097660408a850c1e9cd6f0ad3ea7976e4a4768f1e1858
2021-11-10 13:19:11 +01:00
MarcoFalke
fac23c2114
scripted-diff: Bump copyright headers
The previous diff touched most files in ./test/, so bump the headers to
avoid having to touch them again for a bump later.

-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./test/
-END VERIFY SCRIPT-
2021-11-10 11:10:24 +01:00
MarcoFalke
fa974f1f14
scripted-diff: Remove redundant sync_all and sync_blocks
The sync calls are redundant after a call to generate, because generate
already syncs itself.

-BEGIN VERIFY SCRIPT-
perl -0777 -pi -e 's/(generate[^\n]*\)[^\n]*)(\n|\s)+self.sync_(all|blocks)\([^\)]*\)\n/\1\n/g' $(git grep -l generate ./test)
-END VERIFY SCRIPT-
2021-11-10 11:10:15 +01:00
MarcoFalke
fad13991ae
test: Properly set sync_fun in NodeNetworkLimitedTest 2021-11-10 11:09:55 +01:00
MarcoFalke
faeff57709
test: Use 4 spaces for indentation 2021-11-10 10:11:47 +01:00
lsilva01
aa1a4c9204 Add file validation to savemempool RPC test 2021-11-09 12:47:32 -03:00
Sebastian Falbesoner
041abfebe4 test: MiniWallet: add P2TR support and use it per default 2021-11-09 12:25:48 +01:00
Sebastian Falbesoner
4a2edf2bf7 test: generate blocks to MiniWallet address in rpc_blockchain.py 2021-11-09 12:24:48 +01:00
MarcoFalke
fadc4c7272
test: Add txindex migration test 2021-11-09 12:05:45 +01:00
MarcoFalke
94db963de5
Merge bitcoin/bitcoin#23300: test: Implicitly sync after generate*, unless opted out
facc352648 test: Implicitly sync after generate*, unless opted out (MarcoFalke)

Pull request description:

  The most frequent failure in functional tests are intermittent races. Fixing such bugs is cumbersome because it involves:
  * Noticing the failure
  * Fetching and reading the log to determine the test case that failed
  * Adding a `self.sync_all()` where it was forgotten
  * Spamming out a pr and waiting for review, which is already sparse

  Also, writing a linter to catch those is not possible, nor is review effective in finding these bugs prior to merge.

  Fix all future intermittent races caused by a missing sync_block call by calling `sync_all` implicitly after each `generate*`, unless opted out. This ensures that the code is race-free (with regards to blocks) when the tests pass once, instead of our current approach where the code can never be guaranteed to be race-free.

  There are some scripted-diff cleanups (see https://github.com/bitcoin/bitcoin/pull/22567), but they will be submitted in a follow-up to reduce the conflicts in this pull.

ACKs for top commit:
  lsilva01:
    tACK facc352 on Ubuntu 20.04
  brunoerg:
    tACK facc352648 on MacOS 11.6

Tree-SHA512: 046a40a066b4a3bd28a3077bd654fa8887442dd1f0ec6fd11671865809ef02376f126eb667a1320ebd67b6e372c78c00dbf8bd25d86ed86f1d9a25363103ed97
2021-11-09 09:58:51 +01:00
W. J. van der Laan
8346004ac8
Merge bitcoin/bitcoin#23077: Full CJDNS support
420695c193 contrib: recognize CJDNS seeds as such (Vasil Dimov)
f9c28330a0 net: take the first 4 random bits from CJDNS addresses in GetGroup() (Vasil Dimov)
29ff79c0a2 net: relay CJDNS addresses even if we are not connected to CJDNS (Vasil Dimov)
d96f8d304c net: don't skip CJDNS from GetNetworkNames() (Vasil Dimov)
c2d751abba net: take CJDNS into account in CNetAddr::GetReachabilityFrom() (Vasil Dimov)
9b43b3b257 test: extend feature_proxy.py to test CJDNS (Vasil Dimov)
508eb258fd test: remove default argument of feature_proxy.py:node_test() (Vasil Dimov)
6387f397b3 net: recognize CJDNS addresses as such (Vasil Dimov)
e6890fcb44 net: don't skip CJDNS from GetNetworksInfo() (Vasil Dimov)
e9d90d3c11 net: introduce a new config option to enable CJDNS (Vasil Dimov)
78f456c576 net: recognize CJDNS from ParseNetwork() (Vasil Dimov)
de01e312b3 net: use -proxy for connecting to the CJDNS network (Vasil Dimov)
aedd02ef27 net: make it possible to connect to CJDNS addresses (Vasil Dimov)

Pull request description:

  CJDNS overview
  =====

  CJDNS is like a distributed, shared VPN with multiple entry points where every participant can reach any other participant. All participants use addresses from the `fc00::/8` network (reserved IPv6 range). Installation and configuration is done outside of applications, similarly to VPN (either in the host/OS or on the network router).

  Motivation
  =====

  Even without this PR it is possible to connect two Bitcoin Core nodes through CJDNS manually by using e.g. `-addnode` in environments where CJDNS is set up. However, this PR is necessary for address relay to work properly and automatic connections to be made to CJDNS peers. I.e. to make CJDNS a first class citizen network like IPv4, IPv6, Tor and I2P.

  Considerations
  =====

  An address from the `fc00::/8` network, could mean two things:
  1. Part of a local network, as defined in RFC 4193. Like `10.0.0.0/8`. Bitcoin Core could be running on a machine with such address and have peers with those (e.g. in a local network), but those addresses are not relayed to other peers because they are not globally routable on the internet.
  2. Part of the CJDNS network. This is like Tor or I2P - if we have connectivity to that network then we could reach such peers and we do relay them to other peers.

  So, Bitcoin Core needs to be able to tell which one is it when it encounters a bare `fc00::/8` address, e.g. from `-externalip=` or by looking up the machine's own addresses. Thus a new config option is introduced `-cjdnsreacable`:
  * `-cjdnsreacable=0`: it is assumed a `fc00::/8` address is a private IPv6 (1.)
  * `-cjdnsreacable=1`: it is assumed a `fc00::/8` address is a CJDNS one (2.)

  After setting up CJDNS outside of Bitcoin Core, a node operator only needs to enable this option.
  Addresses from P2P relay/gossip don't need that because they are properly tagged as IPv6 or as CJDNS.

  For testing
  =====
  ```
  [fc32:17ea:e415:c3bf:9808:149d:b5a2:c9aa]:8333
  [fc68:7026:cb27:b014:5910:e609:dcdb:22a2]:8333
  [fcb3:dc50:e1ae:7998:7dc0:7fa6:4582:8e46]:8333
  [fcc7:be49:ccd1:dc91:3125:f0da:457d:8ce]:8333
  [fcf2:d9e:3a25:4eef:8f84:251b:1b4d:c596]:8333
  ```

ACKs for top commit:
  dunxen:
    ACK 420695c
  jonatack:
    re-ACK 420695c193 per `git range-diff 23ae793 4fbff39 420695c`
  laanwj:
    Code review ACK 420695c193

Tree-SHA512: 21559886271aa84671d52b120fa3fa5a50fdcf0fcb26e5b32049c56fab0d606438d19dd366a9c8ce612d3894237ae6d552ead3338b326487e3534399b88a317a
2021-11-08 14:44:37 +01:00
Samuel Dobson
24abd8312e
Merge bitcoin/bitcoin#22949: fee: Round up fee calculation to avoid a lower than expected feerate
80dc829be7 tests: Calculate fees more similarly to CFeeRate::GetFee (Andrew Chow)
ce2cc44afd tests: Test for assertion when feerate is rounded down (Andrew Chow)
0fbaef9676 fees: Always round up fee calculated from a feerate (Andrew Chow)

Pull request description:

  When calculating the fee for a feerate, it is possible that the final calculation will have fractional satoshis. Currently those are ignored via truncation which results in the absolute fee being rounded down. Rounding down is problematic because it results in a feerate that is slightly lower than the feerate represented by the `CFeeRate` object. A slightly lower feerate particularly causes issues for coin selection as it can trigger an assertion error. To avoid potentially underpaying the feerate (and the assertion), always round up the calculated fee.

  A test is added for the assertion, along with a comment explaining what happens.

  It is unlikely that a user can trigger this as it requires a very specific set of rounding errors to occur as well as the transaction not needing any change and being right on the lower bound of the exact match window. However I was able to trigger the assertion while running coin selection simulations, albeit after thousands of transactions and with some weird feerates.

ACKs for top commit:
  ryanofsky:
    Code review ACK 80dc829be7
  promag:
    Tested ACK 80dc829be7.
  lsilva01:
    tACK 80dc829
  meshcollider:
    utACK 80dc829be7

Tree-SHA512: fe26684c60f236cab48ea6a4600c141ce766dbe59504ec77595dcbd7fd0b34559acc617007f4f499c9155d8fda0a336954413410ba862b19c765c0cfac79d642
2021-11-05 00:08:00 +13:00
Vasil Dimov
d96f8d304c
net: don't skip CJDNS from GetNetworkNames() 2021-11-03 14:58:53 +01:00
Vasil Dimov
9b43b3b257
test: extend feature_proxy.py to test CJDNS 2021-11-03 14:58:51 +01:00
Vasil Dimov
508eb258fd
test: remove default argument of feature_proxy.py:node_test()
The default bool argument makes it harder to read because the last but
one argument is also bool. Pass all of them as named arguments to
increase readability.

Another bool argument will be added to indicate whether to test CJDNS.

Co-authored-by: Jon Atack <jon@atack.com>
2021-11-03 14:58:50 +01:00
Vasil Dimov
e6890fcb44
net: don't skip CJDNS from GetNetworksInfo() 2021-11-03 14:58:49 +01:00
Vasil Dimov
78f456c576
net: recognize CJDNS from ParseNetwork()
This allows to use "cjdns" as an argument to the `getnodeaddresses` RPC
and to the `-onlynet=` parameter.
2021-11-03 14:41:14 +01:00
josibake
2ee406ce3e
test: add functional test for deprecatedrpc=fees
Test for old fields when `-deprecatedrpc=fees`
flag is passed and verify values in the deprecated
fields match values in the fees sub-object.
2021-11-02 10:05:38 +01:00
josibake
35d928c632
rpc: deprecate fee fields from mempool entries
Unless `-deprecatedrpc=fees` is passed, top level
fee fields are no longer returned for mempool entries.

Add instructions to field help on how to access
deprecated fields, update help text for readability,
and include units. This is important to help
avoid any confusion as users move from deprecated
fields to the fee fields object (credit: jonatack).

This affects `getmempoolentry`, `getrawmempool`,
`getmempoolancestors`, and `getmempooldescendants`

Modify `test/functional/mempool_packages.py` and
`test/functional/rpc_fundrawtransaction.py` tests
to no longer use deprecated fields.

Co-authored-by: jonatack <jon@atack.com>
2021-11-02 10:05:37 +01:00
fanquake
994aaaa88d
Merge bitcoin/bitcoin#23380: addrman: Fix AddrMan::Add() return semantics and logging
61ec0539b2 [MOVEONLY] reorder functions in addrman_impl.h and addrman.cpp (John Newbery)
2095df7b7b [addrman] Add Add_() inner function, fix Add() return semantics (John Newbery)
2658eb6d68 [addrman] Rename Add_() to AddSingle() (John Newbery)
e58598e833 [addrman] Add doxygen comment to AddrMan::Add() (John Newbery)

Pull request description:

  Previously, Add() would return true if the function created a new
  AddressInfo object, even if that object could not be successfully
  entered into the new table and was deleted. That would happen if the new
  table position was already taken and the existing entry could not be
  removed.

  Instead, return true if the new AddressInfo object is successfully
  entered into the new table. This fixes a bug in the "Added %i addresses"
  log, which would not always accurately log how many addresses had been
  added.

ACKs for top commit:
  naumenkogs:
    ACK 61ec0539b2
  mzumsande:
    ACK 61ec0539b2
  shaavan:
    ACK 61ec0539b2

Tree-SHA512: 276f1e8297d4b6d411d05d06ffc7c176f6290a784da039926ab6c471a8ed8e9159ab4f56c893b1285737ae292954930f0d28012d89dfb3f2f825d7df41016feb
2021-11-01 10:58:27 +08:00
MarcoFalke
facc352648
test: Implicitly sync after generate*, unless opted out 2021-10-29 13:34:52 +02:00
MarcoFalke
5574881ce3
Merge bitcoin/bitcoin#23354: Introduce new V4 format addrman
d891ae7681 Introduce new V4 format addrman (Pieter Wuille)

Pull request description:

  #23306 effectively changed the on-disk format in an incompatible way: old deserializers cannot deal with multiple entries for the same IP.

  Introduce a `V4_MULTIPORT` format, and increment the compatibility base, so that old versions correctly recognize it as an incompatible future version, rather than corruption.

ACKs for top commit:
  naumenkogs:
    ACK d891ae7681
  ajtowns:
    utACK d891ae7681
  vasild:
    ACK d891ae7681

Tree-SHA512: de2153beb59152504ee0656dd0cc0b879b09136eb07e3ce0426d2fea778adfabacebbce5cf1a9a65dc99ad4e99cda42ab26743fe672fb82a9fbfec49c4cccb4d
2021-10-29 13:13:03 +02:00
MarcoFalke
8bac3b1096
Merge bitcoin/bitcoin#23375: test: MiniWallet: more deterministic coin selection for coinbase UTXOs (oldest first)
d2c4904ef7 test: MiniWallet: more deterministic coin selection for coinbase UTXOs (oldest first) (Sebastian Falbesoner)

Pull request description:

  The coin selection strategy for MiniWallet is quite straight-forward: simply pick a single UTXO with the largest value:

  ab25ef8c7f/test/functional/test_framework/wallet.py (L173-L174)

  If there are several candidates with the same value, however, it is not clear which one is taken.  This can be particularly problematic for coinbase outputs with fixed block subsidy, since spending could lead to a `bad-txns-premature-spend-of-coinbase` reject if an UTXO from a too-recent block is picked.  Introduce block height as second criteria (saved in `self._utxos` in the methods `generate(...)` and `rescan_utxos(...)`), in order to avoid potential issues with coinbases that are not matured yet. If there is a tie between coinbase UTXOs and non-coinbase UTXOs (the latter are added via `scan_tx(...)`), prefer the non-coinbase UTXOs, since those don't need to mature.

  The issue came up while refactoring the test rpc_blockchain.py, see https://github.com/bitcoin/bitcoin/pull/23371#discussion_r737401936 (PR #23371).

ACKs for top commit:
  MarcoFalke:
    review ACK d2c4904ef7
  shaavan:
    ACK d2c4904ef7

Tree-SHA512: 15d67b42fb8b77fd53022ea2ab8a6ed2b615567f3ce73bab16c06bfcb687c1a04dcb0360d0c2287c526b604cd3ac5eef7b14ce46fc31e23047ce1a3290027306
2021-10-29 12:55:51 +02:00
MarcoFalke
c426e0dc6f
Merge bitcoin/bitcoin#22972: test: fix misleading fee unit in mempool_limit.py
2600db6c36 test: fix misleading fee unit in mempool_limit.py (Sebastian Falbesoner)

Pull request description:

  The PR is a follow-up to #22543. The helper `send_large_txs` in its current interface has a fee_rate parameter, implying that it would create a transaction with exactly that rate. Unfortunately, this fee rate is only passed to MiniWallet's `create_self_transfer` method, which can't know that we append several tx outputs after, increasing the tx's vsize and decreasing it's fee rate accordingly.

  In our case, the fee rate is off by several orders of magnitude, as the tx's vsize changes changes from 96 to 67552 vbytes (>700x), i.e. the value passed to this function is neither really a fee rate nor an absolute fee, but something in-between, which is very confusing. It was suggested to simply in-line this helper as it's currently only used in this single test (https://github.com/bitcoin/bitcoin/pull/22543#discussion_r701685136, https://github.com/bitcoin/bitcoin/pull/22543#issuecomment-918986896), but I could imagine that this helper may also become useful for other tests and may be moved to a library (e.g. wallet.py) in the future.

  Clarify the interface by passing an absolute fee that is deducted in the end (and also verified, via testmempoolaccept) and also describe how we come up with the value passed. On master, the comment says that the fee rate needs to increased "massively"; this word is also removed because the fee rate only needs to be higher for the test to succeed.

ACKs for top commit:
  stratospher:
    ACK 2600db6.

Tree-SHA512: 0bfacc3fa87603970d86c1d0186e51511f6c20c64b0559e19e7e12a68647f79dcb4f436000dee718fd832ce6a68e3bbacacb29145e0287811f1cb03d2f316843
2021-10-29 12:33:04 +02:00
glozow
6aed8b7e9b [test] tx processing before and after ibd
Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
2021-10-28 16:32:41 +01:00
John Newbery
2095df7b7b [addrman] Add Add_() inner function, fix Add() return semantics
Previously, Add() would return true if the function created a new
AddressInfo object, even if that object could not be successfully
entered into the new table and was deleted. That would happen if the new
table position was already taken and the existing entry could not be
removed.

Instead, return true if the new AddressInfo object is successfully
entered into the new table. This fixes a bug in the "Added %i addresses"
log, which would not always accurately log how many addresses had been
added.

p2p_addrv2_relay.py and p2p_addr_relay.py need to be updated since they
were incorrectly asserting on the buggy log (assuming that addresses are
added to addrman, when there could in fact be new table position
collisions that prevent some of those address records from being added).
2021-10-28 14:00:21 +01:00
Sebastian Falbesoner
d2c4904ef7 test: MiniWallet: more deterministic coin selection for coinbase UTXOs (oldest first)
The coin selection strategy for MiniWallet is quite straight-forward: simply
pick a single UTXO with the largest value:

self._utxos = sorted(self._utxos, key=lambda k: k['value'])
utxo_to_spend = utxo_to_spend or self._utxos.pop()

If there are several candidates with the same value, however, it is not clear
which one is taken.  This can be particularly problematic for coinbase outputs
with fixed block subsidy, since spending could lead to a
'bad-txns-premature-spend-of-coinbase' reject if an UTXO from a too-recent
block is picked.  Introduce block height as second criteria (saved in
self._utxos in the methods generate(...) and rescan_utxos(...)), in order to
avoid potential issues with coinbases that are not matured yet.
2021-10-27 17:49:53 +02:00
Hennadii Stepanov
96c7db9373
test: Add ios_base::width tsan suppression 2021-10-27 11:41:03 +03:00
James O'Beirne
d9803f7a0a
test: add stress tests for initialization 2021-10-26 12:46:36 -04:00
Sebastian Falbesoner
4718897ce3 test: add script_util helper for creating bare multisig scripts 2021-10-26 14:51:18 +02:00
Pieter Wuille
d891ae7681 Introduce new V4 format addrman
92617b7a75 effectively changed the
on-disk format in an incompatible way: old deserializers cannot
deal with multiple entries for the same IP.

Introduce a V4_MULTIPORT format, and increment the compatibility base,
so that old versions correctly recognize it as an incompatible future
version.
2021-10-25 13:48:21 -04:00
MarcoFalke
d565d9b56d
Merge bitcoin/bitcoin#23312: tests: reduce feature_segwit.py usage of the legacy wallet
e9ade032f3 tests: Add feature_segwit.py --descriptors to test_runner.py (Andrew Chow)
ae6cbcc909 tests: restrict feature_segwit legacy wallet import tests (Andrew Chow)
1d13c44a4c tests: Use descriptors for feature_segwit multisig setup (Andrew Chow)

Pull request description:

  `feature_segwit.py` has tests for some legacy wallet behavior, but otherwise does not really need the legacy wallet. Those parts now require `--legacy-wallet` to be provided (as with other legacy wallet tests). Other parts of the test are changed to work with descriptor wallets as well.

ACKs for top commit:
  lsilva01:
    tACK e9ade03

Tree-SHA512: 4ae76a4d2a8d318e7f8ad4c984748e3cdd67ed00359fcd798a08492ed9399b1d01be88c9ebea3d6c996fbe190cf41708a15c98f088f0cb5c47d6d00fff258944
2021-10-25 15:32:27 +02:00
MarcoFalke
beb45b8b14
Merge bitcoin/bitcoin#23311: wallet: Use PACKAGE_NAME to mention our software
da791c7f66 wallet: Use PACKAGE_NAME to mention our software (Hennadii Stepanov)

Pull request description:

  This PR replaces "bitcoin" and "bitcoind" with `PACKAGE_NAME` in wallet log and error messages.

ACKs for top commit:
  jonatack:
    ACK da791c7f66
  lsilva01:
    Tested ACK da791c7 on Ubuntu 20.04.
  brunoerg:
    tACK da791c7f66
  stratospher:
    Tested ACK da791c7
  shaavan:
    ACK da791c7f66

Tree-SHA512: c613446d9c8c3f85e6f5fec77382c9bc17746a853c89e72e1a3a79bf355d7bd9e455bbde8f9e02a894d225a67029c732cdc68ec8c58ac8237dde27d39dae8be7
2021-10-25 15:24:00 +02:00
MarcoFalke
49e40f5704
Merge bitcoin/bitcoin#22711: test: check for specific block reject reasons in p2p_segwit.py
45827fd718 test: check for block reject reasons in p2p_segwit.py [2/2] (Sebastian Falbesoner)
4eb532ff8b test: check for block reject reasons in p2p_segwit.py [1/2] (Sebastian Falbesoner)
b1488c4dce test: fix reference to block processing test in p2p_segwit.py (Sebastian Falbesoner)

Pull request description:

  In the test `p2p_segwit.py`, there are many instances where we send a segwit block to a node with the expectation that it is rejected. For this purpose, the helper function `test_witness_block` exists which allows also to check for a specific reject `reason` that is asserted in the debug log:
  502d22ceed/test/functional/p2p_segwit.py (L119-L120)

  This PR aims to increase the precision of the tests by adding the expected reject reasons to all `test_witness_block` call instances (found via `grep`ing after `test_witness_block(.*accepted=False`). For some blocks that are rejected due to failed script verification, the exact reason is only shown in the debug log if parallel script verification is disabled. For this reason, the addition of the reasons is split up in two commits:
  * first, all instances are tackled that are not subject to script verification, i.e. it doesn't matter whether parallel script verification is enabled or not (e.g. `bad-blk-weight`, `bad-witness-merkle-match`...)
  * then, we explicitely set `-par=1` to only use one script thread, and add the remaining reasons (`non-mandatory-script-verify-flag` with the more specific reason in parantheses)

ACKs for top commit:
  stratospher:
    tested ACK 45827fd.

Tree-SHA512: 00f31867f11d48b38a42b1e79a1303bda1c797ccf3d8c73e6107d70b062604d51ee2a3f2251e7f068dfafdaf09469d27dfee438d9bc9ebaef7febc4b6ef90a95
2021-10-25 14:53:40 +02:00
W. J. van der Laan
a1d55ced09
Merge bitcoin/bitcoin#23139: rpc: fix "trusted" field in TransactionDescriptionString(), add coverage
66f6efc70a rpc: improve TransactionDescriptionString() "generated" help (Jon Atack)
296cfa312f test: add listtransactions/listsinceblock "trusted" coverage (Jon Atack)
d95913fc43 rpc: fix "trusted" description in TransactionDescriptionString (Jon Atack)

Pull request description:

  The RPC gettransaction, listtransactions, and listsinceblock helps returned by `TransactionDescriptionString()` inform the user that the `trusted` boolean field is only present if the transaction is trusted and safe to spend from.

  The field is in fact returned by `WalletTxToJSON()` when the transaction has 0 confirmations (or negative confirmations, if conflicted), and it can be true or false.

  This patch fixes the help, adds test coverage, and touches up the help for the neighboring `generate` field.

ACKs for top commit:
  rajarshimaitra:
    tACK 66f6efc70a
  theStack:
    Tested ACK 66f6efc70a

Tree-SHA512: 4c2127765b82780e07bbdbf519d27163d414d9f15598e01e02210f210e6009be344c84951d7274e747b1386991d4c3b082cd25aebe885fb8cf0b92d57178f68e
2021-10-22 16:26:48 +02:00
MarcoFalke
02feae54a5
Merge bitcoin/bitcoin#23002: Make descriptor wallets by default
9c1052a521 wallet: Default new wallets to descriptor wallets (Andrew Chow)
f19ad40463 rpc, wallet: Descriptor wallets are no longer experimental (Andrew Chow)

Pull request description:

  Changes the default wallet type from legacy to descriptors. Descriptor wallets will now by the default type. Additionally, descriptor wallets will no longer be marked as experimental.

  This follows the timeline proposed in #20160

ACKs for top commit:
  lsilva01:
    Tested ACK 9c1052a521 on Ubuntu 20.04
  prayank23:
    tACK 9c1052a521
  meshcollider:
    Code review ACK 9c1052a521

Tree-SHA512: 834e6fec88e0c18673af7ebe135bd5333694d1be502164eb93a90e3e76c27974165aa4e59426945100c88e4eca07356e16886ef5b05cf789683ecb23fc71a12a
2021-10-22 13:31:10 +02:00
MarcoFalke
12ff8993bc
Merge bitcoin/bitcoin#23331: test: Replace log with assert_equal in wallet_abandonconflict
fa6c62f34b test: Replace log with assert_equal in wallet_abandonconflict (MarcoFalke)

Pull request description:

  This will make the test fail as soon as the bug is fixed, forcing it to
  be updated. Otherwise, the bug might be fixed (or made worse)
  accidentally, leaving the test in an inconsistent state.

ACKs for top commit:
  theStack:
    Concept and code-review ACK fa6c62f34b
  brunoerg:
    tACK fa6c62f34b

Tree-SHA512: 416f72380164bf3f93332a5cfa81a8e61d8ada3714ef6815889ed3cf2d16c09411760dee4acf19629227e565b765b3dea491a0b23efd38eb370254cfadf7c441
2021-10-21 22:00:49 +02:00
W. J. van der Laan
8a083bc5b5
Merge bitcoin/bitcoin#23218: p2p: Use mocktime for ping timeout
fadf1186c8 p2p: Use mocktime for ping timeout (MarcoFalke)

Pull request description:

  It is slightly confusing to use mocktime for some times, but not others.

  Start fixing that by making the ping timeout use mocktime.

  The only downside would be that tests that use mocktime disconnect peers after this patch. However, I don't think this is an issue, as the inactivity check is already disabled for all functional tests after commit 6d76b57ca0. Only one unit test needed the inactivity check disabled as part of this patch.

  A nice side effect of this patch is that the `p2p_ping` functional test now runs 4 seconds faster.

ACKs for top commit:
  laanwj:
    Code review ACK fadf1186c8

Tree-SHA512: e9e7b21040a89d9d574b3038f85a67e6336de6cd6e41aa286769cd03cada6e75a94ec01700e052e56d822ef85d7813cc06bf7e67b81543eff8917a16cdccf942
2021-10-21 19:44:38 +02:00
MarcoFalke
fa6c62f34b
test: Replace log with assert_equal in wallet_abandonconflict
This will make the test fail as soon as the bug is fixed, forcing it to
be updated. Otherwise, the bug might be fixed (or made worse)
accidentally, leaving the test in an inconsistent state.
2021-10-21 11:15:15 +02:00
MarcoFalke
88fc7950f8
Merge bitcoin/bitcoin#23267: test: bip125-replaceable in listsinceblock
b7884dd1b6 test: bip125-replaceable in listsinceblock (brunoerg)

Pull request description:

  This PR adds test coverage for bip125-replaceable in listsinceblock. I added this test into wallet_listtransactions.py instead of putting it into wallet_listsinceblock.py to utilize the scenario already created in wallet_listtransactions.py and avoid repetition.

ACKs for top commit:
  theStack:
    ACK b7884dd1b6
  promag:
    ACK b7884dd1b6.
  stratospher:
    tested ACK b7884dd. Verified the bip125-replaceable status of some transactions with listsinceblock.
  lsilva01:
    tACK b7884dd  on Ubuntu 20.04

Tree-SHA512: 510dfe5a6f9d68e5a656514d356dc8fe99324296ed8caa78f0eb4b6c6906cf70b1fb50bde80aa6f61d726b2fa1d4ce1fe48c635ce24285588e56ceff92291617
2021-10-21 10:21:30 +02:00
MarcoFalke
548ad5ef7f
Merge bitcoin/bitcoin#23281: test: check that bumpfee RPC fails for txs with descendants in mempool
4ac8c89ad9 test: check that bumpfee RPC fails for txs with descendants in mempool (Sebastian Falbesoner)

Pull request description:

  This PR adds missing test coverage for the bumpfee RPC error _"Transaction has descendants in the mempool"_,

  6419bdfeb1/src/wallet/feebumper.cpp (L29-L32)

  which is thrown if the bumped tx has descendants in the mempool and is _not_ connected to the bitcoin wallet (for those, the error "Transaction has descendants in the Wallet" is thrown a few lines above). To achieve that, the test framework's MiniWallet is used.

ACKs for top commit:
  brunoerg:
    tACK 4ac8c89ad9
  promag:
    Code review ACK 4ac8c89ad9. Nice stuff!
  lsilva01:
    Tested ACK 4ac8c89 cad756b10c9dee2d9e1405 on Ubuntu 20.04.
  stratospher:
    tested ACK 4ac8c89.

Tree-SHA512: 83e99f9dd2b140c0c0597c0c36c9c948fa334871be40e58a5e004440698d9685661c69bb83ab937d30f692545a3799705f991b31904f2ef31a2fbc3ae1179fa8
2021-10-21 10:14:47 +02:00
MarcoFalke
9aa4ddb410
Merge bitcoin/bitcoin#23287: test: get and decode tx with a single gettransaction RPC call
130ee48108 test: get and decode tx with a single `gettransaction` RPC call (Sebastian Falbesoner)

Pull request description:

  Rather than subsequently calling `gettransaction` and `decoderawtransaction` to get the decoded information  for a specific tx-id, we can simply use the verbose version of `gettransaction`, which returns this in a 'decoded' key. I.e.

  ```
  node.decoderawtransaction(node.gettransaction(txid)['hex'])
  ```

  can simply be replaced by:

  ```
  node.gettransaction(txid=txid, verbose=True)['decoded']
  ```

  Rationale: shorter code, shorter test logs, less RPC calls.

ACKs for top commit:
  stratospher:
    tested ACK 130ee48
  amadeuszpawlik:
    tACK 130ee48108
  lsilva01:
    Tested ACK 130ee48 on Ubuntu 20.04.
  shaavan:
    ACK 130ee48108

Tree-SHA512: cf0bd26e1e21b8022fb8062857906e0706f0ee32d3277f985c461e2519405afe445ab005f5f763fb268c7b4d6e48b2d47eda7af8621b3bce67cece8dfc9bc153
2021-10-21 10:07:06 +02:00
fanquake
c53e95f22c
Merge bitcoin/bitcoin#23137: Move-only: bloom to src/common
fa2d611bed style: Sort (MarcoFalke)
fa1e5de2db scripted-diff: Move bloom to src/common (MarcoFalke)
fac303c504 refactor: Remove unused MakeUCharSpan (MarcoFalke)

Pull request description:

  To avoid having all files at the top level `./src` directory, start moving them to their respective sub directory according to https://github.com/bitcoin/bitcoin/issues/15732.

  `bloom` currently depends on libconsensus (`CTransaction`, `CScript`, ...) and it is currently located in the libcommon. Thus, move it to `src/common/`. (libutil in `src/util/` is for stuff that doesn't depend on libconsensus).

ACKs for top commit:
  theStack:
    Code-review ACK fa2d611bed
  ryanofsky:
    Code review ACK fa2d611bed
  fanquake:
    ACK fa2d611bed - source shuffle starts now.

Tree-SHA512: d2fbc31b81741e9f0be539e1149542c9ca39958c240e12e8e757d882beccd0f0debdc10dcce146a05f03ef9f5c6247900a461a7a4799b515e8716dfb9af1fde2
2021-10-21 10:30:04 +08:00
Cory Fields
29173d6c6c
ubsan: add minisketch exceptions 2021-10-21 09:39:26 +08:00
Gleb Naumenko
0659f12b13
Add minisketch dependency 2021-10-21 09:38:55 +08:00
fanquake
69986de383
Merge bitcoin/bitcoin#22839: log: improve addrman logging
b65a25a846 log: improve addrman logging (Martin Zumsande)

Pull request description:

  The addrman helper functions `GetNewBucket()` and `GetTriedBucket()`
  1) log into the wrong category (`BCLog::NET` instead of `BCLog::ADDRMAN`)
  2)  log too unspecifically - especially `GetTriedBucket()` gets called from many  different places (e.g. `Check_()`, `Serialize()`), it seems sufficient to me logging these when moving an address from new to tried. Running a node with `-checkaddrman=1`and net logging currently results in a lot of repetitive log entries.

  This PR moves these log entries to `Add_()` and `Good_()` and also adds logging for `Select_()` (allowing statistics about New/Tried success probabilities), `GetAddr_()`, `ClearNew()` and `MakeTried()`.

ACKs for top commit:
  jnewbery:
    ACK b65a25a846
  vasild:
    ACK b65a25a846

Tree-SHA512: 90ab0f64eb44b7388a198efccb613577b74989fea73194bda7de8bfbd50bdb19127cb12f5ec645c7859afdb89290614a79e255f3af0a63a58d4f21aa8fe7b696
2021-10-21 08:35:30 +08:00
Hennadii Stepanov
da791c7f66
wallet: Use PACKAGE_NAME to mention our software 2021-10-20 21:09:14 +03:00
James O'Beirne
23f85616a8
test: add node.chain_path and node.debug_log_path
To allow easier access to the node's datadir and debug logs.
2021-10-20 11:24:56 -04:00
lsilva01
7b3c9e4ee8 Make explicit the node param in init_wallet() 2021-10-20 00:30:28 -03:00
Andrew Chow
e9ade032f3 tests: Add feature_segwit.py --descriptors to test_runner.py 2021-10-19 18:43:18 -04:00
Andrew Chow
ae6cbcc909 tests: restrict feature_segwit legacy wallet import tests
A portion of feature_segwit deals with the legacy wallet IsMine and
import behavior. This is now hidden behind --legacy-wallet
2021-10-19 18:41:46 -04:00
Andrew Chow
1d13c44a4c tests: Use descriptors for feature_segwit multisig setup
When setting up the multisig addresses in feature_segwit.py, use
descriptors rather than addmultisigaddress.
2021-10-19 18:41:05 -04:00
W. J. van der Laan
986003aff9
Merge bitcoin/bitcoin#22918: rpc: Add level 3 verbosity to getblock RPC call (#21245 modified)
5c34507ecb core_write: Rename calculate_fee to have_undo for clarity (fyquah)
8edf6204a8 release-notes: Add release note about getblock verbosity level 3. (fyquah)
459104b2aa rest: Add test for prevout fields in getblock (fyquah)
4330af6f72 rpc: Add test for level 3 verbosity getblock rpc call. (fyquah)
51dbc167e9 rpc: Add level 3 verbosity to getblock RPC call. (fyquah)
3cc95345ca rpc: Replace boolean argument for tx details with enum class. (fyquah)

Pull request description:

  Author of #21245 expressed [time issues](https://github.com/bitcoin/bitcoin/pull/21245#issuecomment-902332088) in the original PR. Given that #21245 has received a lot of review*, I have decided to open this new pull request with [modifications required to get ACK from luke-jr ](https://github.com/bitcoin/bitcoin/pull/21245#issuecomment-905150806) and a few nits of mine.

  ### Original PR description

  > Display the prevout in transaction inputs when calling getblock level 3 verbosity. This PR affects the existing `/rest/block` API by adding a `prevout` fields to tx inputs. This is mentioned in the change to the release notes.
  >
  > I added some functional tests that
  >
  >     * checks that the RPC call still works when TxUndo can't be found
  >
  >     * Doesn't display the "value" or "scriptPubKey" of the previous output when at a lower verbosity level
  >
  >
  > This "completes" the issue #18771

  ### Possible improvements

  * b0bf4f255f - I can include even this commit to this PR if deemed useful or I can leave it for a follow-up PR. See https://github.com/bitcoin/bitcoin/pull/21245#issuecomment-894853784 for more context.

  ### Examples

  Examples of the `getblock` output with various verbose levels. Note that `000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5` contains only 2 transactions.

  #### Verbose level 0

  ```bash
  ./bitcoin-cli -testnet getblock 000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5 0
  ```

  ##### Verbose level 1

  ```bash
  ./bitcoin-cli -testnet getblock 000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5 1
  ```

  ##### Verbose level 2

  ```bash
  ./bitcoin-cli -testnet getblock 000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5 2
  ```

  ##### Verbose level 3

  ```bash
  ./bitcoin-cli -testnet getblock 000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5 3
  ```

  #### REST

  ```bash
  curl -H "content-type:text/plain;" http://127.0.0.1:18332/rest/block/000000000000001f682b188971cc1a121546be4e9d5baf22934fdc7f538288d5.json
  ```

  <sub>* ... and my everyday obsessive checking of my email inbox whether the PR moves forward.</sub>

  Edit laanwj: Removed at symbol from message, and large example output to prevent it from all ending up in the commit message.

ACKs for top commit:
  0xB10C:
    ACK 5c34507ecb
  meshcollider:
    utACK 5c34507ecb
  theStack:
    ACK 5c34507ecb 👘
  promag:
    Concept ACK 5c34507ecb

Tree-SHA512: bbff120d8fd76e617b723b102b0c606e0d8eb27f21c631d5f4cdab0892137c4bc7c65b1df144993405f942c91be47a26e80480102af55bff22621c19f518aea3
2021-10-19 15:47:53 +02:00
MarcoFalke
fa44b071fd
test: Remove unused node from mining_prioritisetransaction 2021-10-19 11:02:10 +02:00
Martin Zumsande
b65a25a846 log: improve addrman logging 2021-10-19 00:20:28 +02:00
Hennadii Stepanov
ffdd94d753
test: Fix wallet_multisig_descriptor_psbt.py 2021-10-18 23:14:56 +03:00
W. J. van der Laan
ff65b696f3
Merge bitcoin/bitcoin#22067: Test and document a basic M-of-N multisig using descriptor wallets and PSBTs
9de0d94508 doc: add disclaimer highlighting shortcomings of the basic multisig example (Michael Dietz)
f9479e4626 test, doc: basic M-of-N multisig minor cleanup and clarifications (Michael Dietz)
e05cd0546a doc: add another signing flow for multisig with descriptor wallets and PSBTs (Michael Dietz)
17dd657300 doc: M-of-N multisig using descriptor wallets and PSBTs, as well as a signing flow (Michael Dietz)
1f20501efc test: add functional test for multisig flow with descriptor wallets and PSBTs (Michael Dietz)

Pull request description:

  Aims to resolve issue https://github.com/bitcoin/bitcoin/issues/21278. I try to follow the steps laanwj outlined there exactly, with the exception of using `combinepsbt` instead of `joinpsbts`. I wrote a functional test to make sure it works as expected before doing the docs, and figured it would also be a good source of documentation. So I kept the test as simple as possible and didn't go crazy with edge-cases and various checks. I do have a lot more test-cases I've written that I will follow up with (either in a separate PR or another commit - lmk if you have a preference), but I want to do it in a way that doesn't bloat this test so it remains useful as a quickstart (unless that's a bad idea)?

ACKs for top commit:
  S3RK:
    Code review ACK 9de0d94. Rspigler's argument convinced me that we should leave the workflow with two wallets. I assume using multisig with external signers is a popular use-case and it's important to keep compatibility.
  laanwj:
    Code and documentation review ACK 9de0d94508

Tree-SHA512: 6c76e787c21f09d8be5eaa11f3ca3eaa4868497824050562bdfb2095c73b90f5e8987a8775119891d6bfde586e3f31ad1b13e4b67b0802e1d23ef050227a1211
2021-10-18 16:17:45 +02:00
MarcoFalke
2e82af46e2
Merge bitcoin/bitcoin#23207: test: Delete generate* calls from TestNode
fac62e6ff5 test: Delete generate* calls from TestNode (MarcoFalke)
fac7f6102f test: Use generate* node RPC, not wallet RPC (MarcoFalke)
faac1cda6e test: Use generate* from TestFramework, not TestNode (MarcoFalke)

Pull request description:

  Deleting the methods is needed for #22567 to pave the way to make it easier to implicitly call the `sync_all` member function.

  Without the methods being deleted, nothing prevents developers from adding calls to it. As history showed, developers *will* add calls to it. For example, see commit eb02dbba3c from today or the first commit in this pull request.

ACKs for top commit:
  stratospher:
    Tested ACK fac62e6.
  brunoerg:
    tACK fac62e6ff5
  promag:
    Code review ACK fac62e6ff5.

Tree-SHA512: 6d4dea8f95ead954acfef2e6a5d98897ce0c2d02265c5b137bb149d0265543bd51d7e8403e1945b9af75df5524ca50064fe1d2a432b25c8abc71bbb28ed6ed53
2021-10-18 13:06:03 +02:00
fanquake
ef596923a8
Merge bitcoin/bitcoin#23080: test: check abandoned tx in listsinceblock
bda620aecd test: check abandoned tx in listsinceblock (brunoerg)

Pull request description:

  This PR tests if the abandoned transaction is correct in listsinceblock return (wallet_abandonconflict.py).

ACKs for top commit:
  jonatack:
    ACK bda620aecd
  theStack:
    ACK bda620aecd
  stratospher:
    Tested ACK bda620a. This PR verifies whether the transaction txAB1 has been abandoned in listsinceblock and is a nice addition to the test!

Tree-SHA512: e4dce344cf621de7a8b5bd8660d252419772a293080fc881f6f448b6df85c6b1c8f0df619e855a40b6393f53c836f0d7fadbd3916c20cccd3a95830b8b502991
2021-10-18 12:02:55 +08:00
Sebastian Falbesoner
130ee48108 test: get and decode tx with a single gettransaction RPC call
Rather than subsequently calling `gettransaction` and
`decoderawtransaction` to get the decoded information  for a specific
tx-id, we can simply use the verbose version of `gettransaction`, which
returns this in a 'decoded' key. I.e.

node.decoderawtransaction(node.gettransaction(txid)['hex'])

can be replaced by:

node.gettransaction(txid=txid, verbose=True)['decoded']
2021-10-17 18:10:36 +02:00
josibake
a46f71bb70
lint: enable mypy checking for missing imports
Achieve this by adding some ignore, and making data/ importable.

Co-authored-by: JoĂŁo Barbosa <joao.paulo.barbosa@gmail.com>
2021-10-16 09:14:37 +08:00
josibake
6ae9c2ef23
lint: install pyzmq (22.3.0) into linter environment
mypy stubs were introduced in 21.0.1
2021-10-16 09:14:36 +08:00
fanquake
b93e2299da
doc: remove pointlessly duplicated linter version / install info 2021-10-16 09:14:36 +08:00
Sebastian Falbesoner
4ac8c89ad9 test: check that bumpfee RPC fails for txs with descendants in mempool
This commit adds missing test coverage for the bumpfee RPC
error "Transaction has descendants in the mempool", which is
thrown if the bumped tx has descendants in the mempool and is
_not_ connected to the bitcoin wallet. To achieve that, the
test framework's MiniWallet is used.
2021-10-15 02:38:18 +02:00
W. J. van der Laan
6419bdfeb1
Merge bitcoin/bitcoin#23093: Add ability to flush keypool and always flush when upgrading non-HD to HD
6531599f42 test: Add check that newkeypool flushes change addresses too (Samuel Dobson)
84fa19c77a Add release notes for keypool flush changes (Samuel Dobson)
f9603ee4e0 Add test for flushing keypool with newkeypool (Samuel Dobson)
6f6f7bb36c Make legacy wallet upgrades from non-HD to HD always flush the keypool (Samuel Dobson)
2434b10781 Fix outdated keypool size default (Samuel Dobson)
22cc797ca5 Add newkeypool RPC to flush the keypool (Samuel Dobson)

Pull request description:

  This PR makes two main changes:
  1) Adds a new RPC `newkeypool` which will entirely flush and refill the keypool.
  2) When upgradewallet is called on old, non-HD wallets upgrading them to HD, we now always flush the keypool and generate a new one, to immediately start using the HD generated keys.

  This PR is motivated by a number of users with old, pre-compressed-key wallets upgrading them and being confused about why they still can't generate p2sh-segwit or bech32 addresses -- this is due to uncompressed keys remaining in the keypool post-upgrade and being illegal in these newer address formats. There is currently no easy way to flush the keypool other than to call `getnewaddress` a hundred/thousand times or an ugly hack of using a `sethdseed` call.

ACKs for top commit:
  laanwj:
    re-ACK 6531599f42
  meshcollider:
    Added new commit 6531599f42 to avoid invalidating previous ACKs.
  instagibbs:
    ACK 6531599f42

Tree-SHA512: 50c79c5d42dd27ab0ecdbfdc4071fdaa1b2dbb2f9195ed325b007106ff19226419ce57fe5b1539c0c24101b12f5e034bbcfb7bbb0451b766cb1071295383d774
2021-10-14 18:05:58 +02:00
Samuel Dobson
ec4e43c21c
Merge #23235: Reduce unnecessary default logging
b5950dd59c validation: put coins cache write log into bench debug log (Anthony Towns)
31b2b802b5 blockstorage: use debug log category (Anthony Towns)
da94ebc2fa validation: move header validation error logging to VALIDATION debug category (Anthony Towns)
1d7d835ec3 validation: include block hash when reporting prev block not found errors (Anthony Towns)

Pull request description:

  Moves the following log messages into debug log categories:

   * "AcceptBlockHeader: ..." to validation
   * "Prune: deleted blk/rev" to new blockstorage log category
   * "Leaving block file" moves from validation to blockstorage
   * "write coins cache to disk" to bench

  Also adds the hash of the block to the log message when AcceptBlockHeader is rejecting because of problems with the prev block.

ACKs for top commit:
  practicalswift:
    cr ACK b5950dd59c
  Empact:
    Code review ACK b5950dd59c
  laanwj:
    Code review ACK b5950dd59c
  promag:
    Code review ACK b5950dd59c.
  meshcollider:
    Code review ACK b5950dd59c

Tree-SHA512: a73fdbfe8d36da48a3e89c2d5e0b6a3c5045d280c1a57f61c38d0d21f4f198aece4bd85155be3439e179d5dabdb523bf15fa0395e0e3ceff19c878ba3112c840
2021-10-14 18:40:59 +13:00
Samuel Dobson
6531599f42 test: Add check that newkeypool flushes change addresses too 2021-10-14 16:52:59 +13:00
W. J. van der Laan
28d5074343
Merge bitcoin/bitcoin#23253: bitcoin-tx: Reject non-integral and out of range int strings
fa6f29de51 bitcoin-tx: Reject non-integral and out of range multisig numbers (MarcoFalke)
fafab8ea5e bitcoin-tx: Reject non-integral and out of range sequence ids (MarcoFalke)
fa53d3d826 test: Check that bitcoin-tx accepts whitespace around sequence id and multisig numbers (MarcoFalke)

Pull request description:

  Seems odd to silently accept arbitrary strings that don't even represent integral values.

  Fix that.

ACKs for top commit:
  practicalswift:
    cr ACK fa6f29de51
  laanwj:
    Code review ACK fa6f29de51
  Empact:
    Code review ACK fa6f29de51
  promag:
    Code review ACK fa6f29de51.

Tree-SHA512: e31f7f21fe55ac069e755557bdbcae8d5d29e20ff82e441ebdfc65153e3a31a4edd46ad3e6dea5190ecbd1b8ea5a8f94daa5d59a3b7558e46e794e30db0e6c79
2021-10-13 13:48:41 +02:00
brunoerg
b7884dd1b6 test: bip125-replaceable in listsinceblock 2021-10-12 12:10:48 -03:00
MarcoFalke
fa6f29de51
bitcoin-tx: Reject non-integral and out of range multisig numbers 2021-10-12 12:45:55 +02:00
MarcoFalke
fafab8ea5e
bitcoin-tx: Reject non-integral and out of range sequence ids 2021-10-12 12:45:50 +02:00
MarcoFalke
fa53d3d826
test: Check that bitcoin-tx accepts whitespace around sequence id and multisig numbers 2021-10-12 12:44:41 +02:00
MarcoFalke
fa8d492894
rest: Return error when header count is not integral 2021-10-12 09:10:19 +02:00
Samuel Dobson
fbbbc594ad
Merge bitcoin/bitcoin#23227: bitcoin-tx: Avoid treating integer overflow as OP_0
fa43e7c2d9 bitcoin-tx: Avoid treating overflow as OP_0 (MarcoFalke)
fa053c0019 style: Fix whitespace in Parse* functions (MarcoFalke)
fa03dec7e9 refactor: Use C++11 range based for loop in ParseScript (MarcoFalke)
fad55e79ca doc: Fixup ToIntegral docs (MarcoFalke)

Pull request description:

  Seems odd to treat integer overflow as `OP_0`, so fix that.

ACKs for top commit:
  theStack:
    re-ACK fa43e7c2d9
  shaavan:
    ACK fa43e7c2d9

Tree-SHA512: 1bbe2de62d853badc18d57d169c6e78ddcdff037e5a85357995dead11c8e67a4fe35087e08a181c60753f8ce91058b7fcc06f5b7901afedc78fbacea8bc3ef4f
2021-10-12 15:32:11 +13:00
Samuel Dobson
42d6a029e5 Refactor and add more tests for validateaddress 2021-10-12 12:03:14 +13:00
Samuel Dobson
0b06e720c0 More detailed error checking for base58 addresses 2021-10-12 12:03:14 +13:00
Andrew Chow
80dc829be7 tests: Calculate fees more similarly to CFeeRate::GetFee
Because of floating point precision issues, not all of the rounding done
is always correct. To fix this, the fee calculation for
assert_fee_amount is changed to better reflect how CFeeRate::GetFee does
it.

First the feerate is converted to an int representing sat/kvb. Then this
is multiplied by the transaction size, divivided by 1000, and rounded up
to the nearest sat. The result is then converted back to BTC (divided by
1e8) and then rounded down to the nearest sat to avoid precision errors.
2021-10-11 12:29:33 -04:00
Anthony Towns
31b2b802b5 blockstorage: use debug log category 2021-10-11 21:45:49 +10:00
MarcoFalke
1790a8ddac
Merge bitcoin/bitcoin#22794: test: Verify if wallet is compiled in rpc_invalid_address_message.py test
c2fbdca549 Add BECH32_INVALID_VERSION test (lsilva01)
b142f79ddb skip test_getaddressinfo() if wallet is disabled (lsilva01)

Pull request description:

  Most of  `test/functional/rpc_invalid_address_message.py` does not requires wallet.
  But if the project is compiled in disable-wallet mode, the entire test will be skipped.

  This PR changes the test to run the RPC tests first and then checks if the wallet is compiled.

ACKs for top commit:
  stratospher:
    tested ACK c2fbdca

Tree-SHA512: 11fa2fedf4a15aa45e3f12490df8e22290a867d5de594247211499533c32289c68c0b60bd42dbf8305e43dbcc042789e7139317ef5c9f8cf386f2d84c91b9ac2
2021-10-11 11:27:37 +02:00
MarcoFalke
fa43e7c2d9
bitcoin-tx: Avoid treating overflow as OP_0 2021-10-11 09:17:28 +02:00
fanquake
01129ca372
Merge bitcoin/bitcoin#23214: Replace stoul with ToIntegral in dbwrapper
fa165e9545 Replace stoul with ToIntegral in dbwrapper (MarcoFalke)

Pull request description:

  The string is created with `%llu`. See: 7fcf53f7b4/src/leveldb/db/db_impl.cc (L1436-L1437)

  So it seems odd to silently accept when parsing: whitespace, a sign character, trailing chars, overflow, ....

  Fix that by using the stricter ToIntegral.

ACKs for top commit:
  laanwj:
    Code review ACK fa165e9545
  practicalswift:
    cr ACK fa165e9545
  theStack:
    Code-review ACK fa165e9545

Tree-SHA512: b87f01431ca0b971ff84610022da8679d3c33470b88cfc3f4a337e6e176a0455715588aefd40e8e2bbe7459d902dc89d7bfe34e7fd66755f631cc18dc039fa2f
2021-10-11 08:51:00 +08:00
Andrew Chow
ce2cc44afd tests: Test for assertion when feerate is rounded down
When calculating a txs absolute fee, if the fee is rounded down to the
nearest satoshi, it is possible for the coin selection algorithms to
undercalculate the fee needed. This can lead to an assertion error in
some situations. One such scenario is added to
rpc_fundrawtransaction.py.
2021-10-08 13:53:48 -04:00
Andrew Chow
0fbaef9676 fees: Always round up fee calculated from a feerate
When calculating the fee for a given tx size from a fee rate, we should
always round up to the next satoshi. Otherwise, if we round down (via
truncation), the calculated fee may result in a fee with a feerate
slightly less than targeted.

This is particularly important for coin selection as a slightly lower
feerate than expected can result in a variety of issues.
2021-10-08 13:53:48 -04:00
MarcoFalke
fad55e79ca
doc: Fixup ToIntegral docs 2021-10-08 15:54:50 +02:00
W. J. van der Laan
991753e4d5
Merge bitcoin/bitcoin#23118: test: refactor: introduce script_util helper for creating P2PK scripts
429b49378e test: introduce script_util helper for creating P2PK scripts (Sebastian Falbesoner)

Pull request description:

  This PR is a follow-up to #22363, which took use of already existing `script_util` helpers to get rid of manual CScript for the P2{PKH,SH,WPKH,WSH} output types, in order to increase readability and maintainability of the test code. Here the same is done for P2PK scripts by introducing a helper `key_to_p2pk_script` and using it. Note that the helper only accepts ECDSA pubkeys (i.e. ones with a size of 33 or 65 bytes), hence it can't be used for scripts in the form of [x-only-pubkey, OP_CHECKSIG].

ACKs for top commit:
  brunoerg:
    Code review ACK 429b49378e
  laanwj:
    Code review ACK 429b49378e
  rajarshimaitra:
    Concept + tACK 429b49378e

Tree-SHA512: 984aea01eba5f38a328d69905d90a3a36f0a02419ca3e5baf3c8095895fb094e3780c7da16fad5851db3847bdb05ce8cda244ab09b79b8aa9602dfb3c5e0414c
2021-10-07 15:41:57 +02:00
W. J. van der Laan
6f0cbc75be
Merge bitcoin/bitcoin#22539: Re-include RBF replacement txs in fee estimation
3b613722f6 Add release notes for fee est with replacement txs (Antoine Poinsot)
4556406562 qa: test fee estimation with replacement transactions (Antoine Poinsot)
053415b297 qa: split run_test into smaller parts (Antoine Poinsot)
06c5ce9714 Re-include RBF replacement txs in fee estimation (Antoine Poinsot)

Pull request description:

  This effectively reverts #9519.

  RBF is now largely in use on the network (signaled for by around 20% of
  all transactions on average) and replacement logic is implemented in
  most end-user wallets. The rate of replaced transactions is also
  expected to rise as fee-bumping techniques are being developed for
  pre-signed transaction ("L2") protocols.

ACKs for top commit:
  prayank23:
    reACK 3b613722f6
  Zero-1729:
    re-ACK 3b613722f6
  benthecarman:
    reACK 3b613722f6
  glozow:
    ACK 3b613722f6
  theStack:
    re-ACK 3b613722f6 đŸȘ

Tree-SHA512: a6146d15c80ff4ba9249314b0ef953a66a15673e61b8f98979642814f1b169b5695e330e3ee069fa9a7e4d1f8aa10e1dcb7f9aa79181cea5a4c4dbcaf5483023
2021-10-07 13:47:36 +02:00
MarcoFalke
fadf1186c8
p2p: Use mocktime for ping timeout 2021-10-07 13:22:02 +02:00
MarcoFalke
fa165e9545
Replace stoul with ToIntegral in dbwrapper 2021-10-07 11:06:37 +02:00
MarcoFalke
c0b6c96eee
Merge bitcoin/bitcoin#23146: Test transactions conflicted by double spend in listtransactions
502f50da12 Test transactions conflicted by double spend in listtransactions (Jon Atack)

Pull request description:

  Test the properties of transactions conflicted by a double spend as returned by RPC listtransactions in the abandoned, confirmations, trusted and walletconflicts fields. These fields are also returned by RPCs listsinceblock and gettransactions.

ACKs for top commit:
  brunoerg:
    tACK 502f50da12
  rajarshimaitra:
    Concept + tACK 502f50da12

Tree-SHA512: 28968f4a5f1960ea45b2e6f5b20fe25c1b51f66944062dcddea52ea970ad21c74d583793d091b84e8a5e506d6aecc1f0435c5b918213975b22c38e02bba19aa1
2021-10-07 09:59:03 +02:00
MarcoFalke
b4437d7dfe
Merge bitcoin/bitcoin#23210: test: Replace satoshi_round with int() or Decimal()
fa2ac5881e test: Replace satoshi_round with int() or Decimal() (MarcoFalke)

Pull request description:

  satoshi_round will round down. To make the code easier to parse use
  Decimal() where possible, which does not round. Or use int(), which
  explicitly rounds down.

ACKs for top commit:
  lsilva01:
    Tested ACK fa2ac5881e on Ubuntu 20.04.

Tree-SHA512: 17795d906aa7652933d43e510e993cdd9cf8926da1febf1c42d463048cb38c92dc518ec08736efe29c0189ffd532b108bc7a715f32b4c2ee58b215df65352eb9
2021-10-07 09:09:11 +02:00
MarcoFalke
fa2ac5881e
test: Replace satoshi_round with int() or Decimal()
satoshi_round will round down. To make the code easier to parse use
Decimal() where possible, which does not round. Or use int(), which
explicitly rounds down.
2021-10-06 15:16:59 +02:00
MarcoFalke
fa3ab7b5b1
test: Avoid RPC roundtrip in MiniWallet get_descriptor() 2021-10-06 14:54:26 +02:00
MarcoFalke
fac62e6ff5
test: Delete generate* calls from TestNode 2021-10-06 13:41:08 +02:00
MarcoFalke
fac7f6102f
test: Use generate* node RPC, not wallet RPC 2021-10-06 13:39:44 +02:00
MarcoFalke
faac1cda6e
test: Use generate* from TestFramework, not TestNode 2021-10-06 13:39:39 +02:00
S3RK
3d71d16d1e test: listtranscations with externally generated addresses 2021-10-06 10:01:53 +02:00
Samuel Dobson
75a9305d45 Fix intermittent test failures due to missing sync_all 2021-10-06 12:19:04 +13:00
Samuel Dobson
eb02dbba3c Use self.generate not node.generate throughout tests 2021-10-06 12:18:33 +13:00
Jon Atack
22b44fc696
p2p: improve checkaddrman logging with duration in milliseconds
and update the function name to CheckAddrman (drop "Force") for
nicer log output as it is prefixed to each of these log messages:

2021-09-21T18:42:50Z [opencon] CheckAddrman: new 64864, tried 1690, total 66554 started
2021-09-21T18:42:50Z [opencon] CheckAddrman: completed (76.21ms)

The existing Doxygen documentation on the function already makes
clear that it is unaffected by m_consistency_check_ratio.
2021-10-05 18:34:22 +02:00
MarcoFalke
c4fc899442
Merge bitcoin/bitcoin#22950: [p2p] Pimpl AddrMan to abstract implementation details
021f86953e [style] Run changed files through clang formatter. (Amiti Uttarwar)
375750387e scripted-diff: Rename CAddrInfo to AddrInfo (Amiti Uttarwar)
dd8f7f2500 scripted-diff: Rename CAddrMan to AddrMan (Amiti Uttarwar)
3c263d3f63 [includes] Fix up included files (Amiti Uttarwar)
29727c2aa1 [doc] Update comments (Amiti Uttarwar)
14f9e000d0 [refactor] Update GetAddr_() function signature (Amiti Uttarwar)
40acd6fc9a [move-only] Move constants to test-only header (Amiti Uttarwar)
7cf41bbb38 [addrman] Change CAddrInfo access (Amiti Uttarwar)
e3f1ea659c [move-only] Move CAddrInfo to test-only header file (Amiti Uttarwar)
7cba9d5618 [net, addrman] Remove external dependencies on CAddrInfo objects (Amiti Uttarwar)
8af5b54f97 [addrman] Introduce CAddrMan::Impl to encapsulate addrman implementation. (Amiti Uttarwar)
f2e5f38f09 [move-only] Match ordering of CAddrMan declarations and definitions (Amiti Uttarwar)
5faa7dd6d8 [move-only] Move CAddrMan function definitions to cpp (Amiti Uttarwar)

Pull request description:

  Introduce the pimpl pattern for AddrMan to separate the implementation details from the externally used object representation. This reduces compile-time dependencies and conceptually clarifies AddrMan's interface from the implementation specifics.

  Since the unit & fuzz tests currently rely on accessing AddrMan internals, this PR introduces addrman_impl.h, which is exclusively imported by addrman.cpp and test files.

ACKs for top commit:
  jnewbery:
    ACK 021f86953e
  GeneFerneau:
    utACK [021f869](021f86953e)
  mzumsande:
    ACK 021f86953e
  rajarshimaitra:
    Concept + Code Review ACK 021f86953e
  theuni:
    ACK 021f86953e

Tree-SHA512: aa70cb77927a35c85230163c0cf6d3872382d79048b0fb79341493caa46f8e91498cb787d8b06aba4da17b2f921f2230e73f3d66385519794fff86a831b3a71d
2021-10-05 16:48:33 +02:00
MarcoFalke
fa1e5de2db
scripted-diff: Move bloom to src/common
-BEGIN VERIFY SCRIPT-
 # Move to directory
 mkdir                src/common
 git mv src/bloom.cpp src/common/
 git mv src/bloom.h   src/common/

 # Replace occurrences
 sed -i 's|\<bloom\.cpp\>|common/bloom.cpp|g' $(git grep -l 'bloom.cpp')
 sed -i 's|\<bloom\.h\>|common/bloom.h|g'     $(git grep -l 'bloom.h')
 sed -i 's|BITCOIN_BLOOM_H|BITCOIN_COMMON_BLOOM_H|g' $(git grep -l 'BLOOM_H')
-END VERIFY SCRIPT-
2021-10-05 11:10:37 +02:00
fyquah
459104b2aa rest: Add test for prevout fields in getblock 2021-10-05 10:42:34 +02:00
fyquah
4330af6f72 rpc: Add test for level 3 verbosity getblock rpc call. 2021-10-05 10:42:34 +02:00
W. J. van der Laan
9e530c6352
Merge bitcoin/bitcoin#20487: Add syscall sandboxing using seccomp-bpf (Linux secure computing mode)
4747da3a5b Add syscall sandboxing (seccomp-bpf) (practicalswift)

Pull request description:

  Add experimental syscall sandboxing using seccomp-bpf (Linux secure computing mode).

  Enable filtering of system calls using seccomp-bpf: allow only explicitly allowlisted (expected) syscalls to be called.

  The syscall sandboxing implemented in this PR is an experimental feature currently available only under Linux x86-64.

  To enable the experimental syscall sandbox the `-sandbox=<mode>` option must be passed to `bitcoind`:

  ```
    -sandbox=<mode>
         Use the experimental syscall sandbox in the specified mode
         (-sandbox=log-and-abort or -sandbox=abort). Allow only expected
         syscalls to be used by bitcoind. Note that this is an
         experimental new feature that may cause bitcoind to exit or crash
         unexpectedly: use with caution. In the "log-and-abort" mode the
         invocation of an unexpected syscall results in a debug handler
         being invoked which will log the incident and terminate the
         program (without executing the unexpected syscall). In the
         "abort" mode the invocation of an unexpected syscall results in
         the entire process being killed immediately by the kernel without
         executing the unexpected syscall.
  ```

  The allowed syscalls are defined on a per thread basis.

  I've used this feature since summer 2020 and I find it to be a helpful testing/debugging addition which makes it much easier to reason about the actual capabilities required of each type of thread in Bitcoin Core.

  ---

  Quick start guide:

  ```
  $ ./configure
  $ src/bitcoind -regtest -debug=util -sandbox=log-and-abort
  

  2021-06-09T12:34:56Z Experimental syscall sandbox enabled (-sandbox=log-and-abort): bitcoind will terminate if an unexpected (not allowlisted) syscall is invoked.
  

  2021-06-09T12:34:56Z Syscall filter installed for thread "addcon"
  2021-06-09T12:34:56Z Syscall filter installed for thread "dnsseed"
  2021-06-09T12:34:56Z Syscall filter installed for thread "net"
  2021-06-09T12:34:56Z Syscall filter installed for thread "msghand"
  2021-06-09T12:34:56Z Syscall filter installed for thread "opencon"
  2021-06-09T12:34:56Z Syscall filter installed for thread "init"
  

  # A simulated execve call to show the sandbox in action:
  2021-06-09T12:34:56Z ERROR: The syscall "execve" (syscall number 59) is not allowed by the syscall sandbox in thread "msghand". Please report.
  

  Aborted (core dumped)
  $
  ```

  ---

  [About seccomp and seccomp-bpf](https://en.wikipedia.org/wiki/Seccomp):

  > In computer security, seccomp (short for secure computing mode) is a facility in the Linux kernel. seccomp allows a process to make a one-way transition into a "secure" state where it cannot make any system calls except exit(), sigreturn(), and read() and write() to already-open file descriptors. Should it attempt any other system calls, the kernel will terminate the process with SIGKILL or SIGSYS. In this sense, it does not virtualize the system's resources but isolates the process from them entirely.
  >
  > [
]
  >
  > seccomp-bpf is an extension to seccomp that allows filtering of system calls using a configurable policy implemented using Berkeley Packet Filter rules. It is used by OpenSSH and vsftpd as well as the Google Chrome/Chromium web browsers on Chrome OS and Linux. (In this regard seccomp-bpf achieves similar functionality, but with more flexibility and higher performance, to the older systrace—which seems to be no longer supported for Linux.)

ACKs for top commit:
  laanwj:
    Code review and lightly tested ACK 4747da3a5b

Tree-SHA512: e1c28e323eb4409a46157b7cc0fc29a057ba58d1ee2de268962e2ade28ebd4421b5c2536c64a3af6e9bd3f54016600fec88d016adb49864b63edea51ad838e17
2021-10-04 22:45:43 +02:00
W. J. van der Laan
cdb4dfcbf1
Merge bitcoin/bitcoin#20452: util: Replace use of locale dependent atoi(
) with locale-independent std::from_chars(
) (C++17)
4343f114cc Replace use of locale dependent atoi(
) with locale-independent std::from_chars(
) (C++17) (practicalswift)

Pull request description:

  Replace use of locale dependent `atoi(
)` with locale-independent `std::from_chars(
)` (C++17).

ACKs for top commit:
  laanwj:
    Code review ACK 4343f114cc
  jonatack:
    Code review ACK 4343f114cc

Tree-SHA512: e4909da282b6cefc5ca34e13b02cc489af56cab339a77ae5c35ac9ef355d9b941b129a2bfddc1b37426b11c79a21c8b729fbb5255e6d9eaa344406b18b825494
2021-10-04 12:59:28 +02:00
MarcoFalke
c6f710ec98
Merge bitcoin/bitcoin#23052: test: use miniwallet in test_rpc function in feature_rbf.py
74c0d81b46 test: use miniwallet in test_rpc() function in feature_rbf.py (Shubhankar)

Pull request description:

  This PR aims to further increase MiniWallet usage in the functional test feature_rbf.py by using it in the test_rpc(...) . Sub test needs wallet to get a utxo for creating raw txn, and to get address for output, address can be hardcoded and mini wallet can be used for utxo. fund raw transaction is a wallet rpc and should be tested only when bitcoin core is compiled with wallet

ACKs for top commit:
  laanwj:
    Code review ACK 74c0d81b46
  theStack:
    tACK 74c0d81b46

Tree-SHA512: a98cc0df0fe70ee113a293cd4fd659c5bece47c17937d368193b65b150b331a2c694cdeb2792386f1a6deefb8d6750ed83ffa0ae6f9d13fa2b7625cd80bc692a
2021-10-04 11:11:45 +02:00
Samuel Dobson
573b4621cc
Merge bitcoin/bitcoin#17211: Allow fundrawtransaction and walletcreatefundedpsbt to take external inputs
928af61cdb allow send rpc take external inputs and solving data (Andrew Chow)
e39b5a5e7a Tests for funding with external inputs (Andrew Chow)
38f5642ccc allow fundtx rpcs to work with external inputs (Andrew Chow)
d5cfb864ae Allow Coin Selection be able to take external inputs (Andrew Chow)
a00eb388e8 Allow CInputCoin to also be constructed with COutPoint and CTxOut (Andrew Chow)

Pull request description:

  Currently `fundrawtransaction` and `walletcreatefundedpsbt` both do not allow external inputs as the wallet does not have the information necessary to estimate their fees.

  This PR adds an additional argument to both those RPCs which allows the user to specify solving data. This way, the wallet can use that solving data to estimate the size of those inputs. The solving data can be public keys, scripts, or descriptors.

ACKs for top commit:
  prayank23:
    reACK 928af61cdb
  meshcollider:
    Re-utACK 928af61cdb
  instagibbs:
    crACK 928af61cdb
  yanmaani:
    utACK 928af61.

Tree-SHA512: bc7a6ef8961a7f4971ea5985d75e2d6dc50c2a90b44c664a1c4b0f1be5c1c97823516358fdaab35771a4701dbefc0862127b1d0d4bfd02b4f20d2befa4434700
2021-10-04 22:08:46 +13:00
katesalazar
2198f79e87 Add an argparse abbreviated mode to --failfast
Short options should only be a single character. If not, they can't be
concatenated in a single "-word" (from review by luke-jr).

F is chosen instead of f, because f could be reserved to the nested
wallet_hd.py (test_framework/test_framework.py) arguments parser.
2021-10-04 08:08:52 +02:00
Andrew Chow
928af61cdb allow send rpc take external inputs and solving data 2021-10-03 13:24:14 -04:00
Andrew Chow
e39b5a5e7a Tests for funding with external inputs 2021-10-03 13:24:14 -04:00
Jon Atack
502f50da12
Test transactions conflicted by double spend in listtransactions
Test the properties of transactions conflicted by a double
spend as returned by RPC listtransactions in the "abandoned",
"confirmations", "trusted" and "walletconflicts" fields.

These fields are also returned by RPCs listsinceblock and
gettransactions.
2021-10-02 15:27:40 +02:00
practicalswift
4747da3a5b Add syscall sandboxing (seccomp-bpf) 2021-10-01 13:51:10 +00:00
brunoerg
bda620aecd test: check abandoned tx in listsinceblock 2021-10-01 09:51:14 -03:00
MarcoFalke
35a31d5f7e
Merge bitcoin/bitcoin#23136: test: update fee rate assertion helper in the functional test framework
b658d7d5c5 test: update assert_fee_amount() in test_framework/util.py (Jon Atack)

Pull request description:

  Follow-up to 42e1b5d979 (#12486).
  - update call to `round()` with our utility function `satoshi_round()` to avoid intermittent test failures
  - rename `fee_per_kB` to `feerate_BTC_kvB` for precision
  - store division result in `feerate_BTC_vB`

  Possibly resolves #19418.

ACKs for top commit:
  meshcollider:
    utACK b658d7d5c5

Tree-SHA512: f124ded98c913f98782dc047a85a05d3fdf5f0585041fa81129be562138f6261ec1bd9ee2af89729028277e75b591b0a7ad50244016c2b2fa935c6e400523183
2021-10-01 10:54:23 +02:00
MarcoFalke
4e1de1fc59
Merge bitcoin/bitcoin#22340: p2p: Use legacy relaying to download blocks in blocks-only mode
18c5b23a0f [test] Test that -blocksonly nodes still serve compact blocks. (Niklas Gögge)
a79ad65fc2 [test] Test that getdata(CMPCT) is still sent on regular low bandwidth connections. (Niklas Gögge)
5e231c116b [test] Test that -blocksonly nodes do not send getdata(CMPCT) on a low bandwidth connection. (Niklas Gögge)
5bf6587457 [test] Test that -blocksonly nodes do not request high bandwidth mode. (Niklas Gögge)
0dc8bf5b92 [net processing] Dont request compact blocks in blocks-only mode (Niklas Gögge)

Pull request description:

  A blocks-only node does not participate in transaction relay to reduce its own bandwidth usage and therefore does not have a mempool. The use of compact blocks is not beneficial to such a node since it will always have to download full blocks.

  In both high- and low-bandwidth relaying the `cmpctblock` message is sent. This represent a bandwidth overhead for blocks-only nodes because the `cmpctblock` message is several times larger in the average case than the equivalent `headers` or `inv` announcement.

  ![compact blocks](https://raw.githubusercontent.com/bitcoin/bips/master/bip-0152/protocol-flow.png)

  >**Example:**
  >A block with 2000 txs results in a `cmpctblock` with 2000*6 bytes in short ids. This is several times larger than the equivalent 82 bytes for a `headers` message or 37 bytes for an `inv`.

  ## Approach

  This PR makes blocks-only nodes always use the legacy relaying to download new blocks.
  It does so by making blocks-only nodes never initiate a high-bandwidth block relay connection by disabling the sending of `sendcmpct(1)`. Additionally a blocks-only node will never request a compact block using `getdata(CMPCT)`.

  A blocks-only node will continue to serve compact blocks to its peers in both high- and low-bandwidth mode.

ACKs for top commit:
  naumenkogs:
    ACK 18c5b23a0f
  rajarshimaitra:
    tACK 18c5b23a0f
  jnewbery:
    reACK 18c5b23a0f
  theStack:
    re-ACK 18c5b23a0f đŸ„›

Tree-SHA512: 0c78804aa397513d41f97fe314efb815efcd852d452dd903df9d4749280cd3faaa010fa9b51d7d5168b8a77e08c8ab0a491ecdbdb3202f2e9cd5137cddc74624
2021-10-01 08:16:54 +02:00
W. J. van der Laan
571bb94dfb
Merge bitcoin/bitcoin#23123: Remove -rescan startup parameter
dc3ec74d67 Add rescan removal release note (Samuel Dobson)
bccd1d942d Remove -rescan startup parameter (Samuel Dobson)
f963b0fa8c Corrupt wallet tx shouldn't trigger rescan of all wallets (Samuel Dobson)
6c006495ef Remove outdated dummy wallet -salvagewallet arg (Samuel Dobson)

Pull request description:

  Remove the `-rescan` startup parameter.

  Rescans can be run with the `rescanblockchain` RPC.

  Rescans are still done on wallet-load if needed due to corruption, for example.

ACKs for top commit:
  achow101:
    ACK dc3ec74d67
  laanwj:
    re-ACK dc3ec74d67

Tree-SHA512: 608360d0e7d73737fd3ef408b01b33d97a75eebccd70c6d1b47a32fecb99b9105b520b111b225beb10611c09aa840a2b6d2b6e6e54be5d0362829e757289de5c
2021-09-30 20:49:40 +02:00
Jon Atack
b658d7d5c5
test: update assert_fee_amount() in test_framework/util.py
- update call to round() with satoshi_round() to avoid intermittent test failures
- rename fee_per_kB to feerate_BTC_kvB for precision
- store division result in feerate_BTC_vB
2021-09-30 16:38:55 +02:00
practicalswift
4343f114cc Replace use of locale dependent atoi(
) with locale-independent std::from_chars(
) (C++17)
test: Add test cases for LocaleIndependentAtoi

fuzz: Assert legacy atoi(s) == LocaleIndependentAtoi<int>(s)

fuzz: Assert legacy atoi64(s) == LocaleIndependentAtoi<int64_t>(s)
2021-09-30 14:21:17 +00:00
W. J. van der Laan
2d8e0c0c3c
Merge bitcoin/bitcoin#20457: util: Make Parse{Int,UInt}{32,64} use locale independent std::from_chars(
) (C++17) instead of locale dependent strto{l,ll,ul,ull}
4747db8761 util: Introduce ToIntegral<T>(const std::string&) for locale independent parsing using std::from_chars(
) (C++17) (practicalswift)

Pull request description:

  Make `Parse{Int,UInt}{32,64}` use locale independent `std::from_chars(
)` (C++17) instead of locale dependent `strto{l,ll,ul,ull}`.

  [About `std::from_chars`](https://en.cppreference.com/w/cpp/utility/from_chars): _"Unlike other parsing functions in C++ and C libraries, `std::from_chars` is locale-independent, non-allocating, and non-throwing."_

ACKs for top commit:
  laanwj:
    Code review ACK 4747db8761

Tree-SHA512: 40f2cd582bc19ddcf2c498eca3379167619eff6aa047bbac2f73b8fd8ecaefe5947c66700a189f83848751f9f8c05645e83afd4a44a1679062aee5440dba880a
2021-09-30 15:14:58 +02:00
W. J. van der Laan
1cf7fb9fd6
Merge bitcoin/bitcoin#23104: log: Avoid breaking single log lines over multiple lines in the log file
2222c04e1b log: Adjust coin selection log string (MarcoFalke)
fa6c1e850f test: Fix typos in tests (MarcoFalke)
faeae2980f log: Avoid broken DEBUG_LOCKORDER log (MarcoFalke)
faffaa85cd log: Avoid broken SELECTCOINS log (MarcoFalke)

Pull request description:

  Follow up to commit d8b4b3077f

ACKs for top commit:
  laanwj:
    re-ACK 2222c04e1b
  practicalswift:
    cr ACK 2222c04e1b

Tree-SHA512: e0daf76815a1b7c4898ceffedeaf7ede093223abf709874f9a0d78c8e41551c14e8b56d055c8fdf06ec698df64e67dfc168bbd8716131b23648d1d1294fa6636
2021-09-30 14:42:11 +02:00
fanquake
69a66dcd0d
Merge bitcoin/bitcoin#23126: doc: update developer docs for subtree renaming
2b90eae33c doc: update developer docs for subtree renaming (fanquake)

Pull request description:

  Update the developer docs after the [recent subtree renaming](https://github.com/bitcoin/bitcoin/pull/22646#issuecomment-921154730).

ACKs for top commit:
  hebasto:
    ACK 2b90eae33c

Tree-SHA512: ed0eec8db888e60595c07f4fad0a506673e4b10345fb2dd6d1a98d785da22bddf1fe8896aa52fd67f5e1688e3c91c6b642739e08646f1b920f50f0d35037d961
2021-09-30 08:52:36 +08:00
Samuel Dobson
bccd1d942d Remove -rescan startup parameter 2021-09-30 12:06:27 +13:00
Jon Atack
296cfa312f
test: add listtransactions/listsinceblock "trusted" coverage 2021-09-29 22:36:57 +02:00
Jon Atack
d95913fc43
rpc: fix "trusted" description in TransactionDescriptionString
The helps for RPCs gettransaction, listtransactions, and
listsinceblock returned by TransactionDescriptionString()
state that the "trusted" boolean field is only present if the
transaction is trusted and safe to spend from.

The "trusted" boolean field is in fact returned by
WalletTxToJSON() when the transaction has 0 confirmations,
or negative confirmations, if conflicted, and it can be
true or false.

This commit updates TransactionDescriptionString() to a
more accurate description for "trusted" and updates the
existing line of test coverage to fail more helpfully.
2021-09-29 22:35:43 +02:00
MarcoFalke
fa6c1e850f
test: Fix typos in tests 2021-09-29 18:47:45 +02:00
Antoine Poinsot
4556406562
qa: test fee estimation with replacement transactions
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-09-29 17:24:28 +02:00
Antoine Poinsot
053415b297
qa: split run_test into smaller parts
Let's not have run_test get into a giant function as we add more tests

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-09-29 17:15:18 +02:00
Shubhankar
74c0d81b46 test: use miniwallet in test_rpc() function in feature_rbf.py 2021-09-29 20:43:45 +05:30
Sebastian Falbesoner
429b49378e test: introduce script_util helper for creating P2PK scripts 2021-09-29 14:09:14 +02:00
MarcoFalke
d648bbb0a7
Merge bitcoin/bitcoin#23124: Fix feature_segwit.py failure due to witness
b207971465 Fix feature_segwit failure due to witness (Samuel Dobson)

Pull request description:

  Fixes #23116

  The failure is due to sometimes spending segwit outputs, which add an additional 1 sigop in the witness, added to the 2 (*4) in the outputs.

ACKs for top commit:
  brunoerg:
    tACK b207971465

Tree-SHA512: 7e3c09d162e6941a3028514e95ae3aab2a3f858e2f056229c5faff5e37ece897dc63e3f8c0e07fad9fc4621b74a6dee5ff777e910b2b009a41bb6e72a09217bd
2021-09-29 13:36:19 +02:00
MarcoFalke
33e31f8df9
Merge bitcoin/bitcoin#23079: test: use MiniWallet for p2p_filter.py
cfdb6baa22 test: use MiniWallet for p2p_filter.py (Sebastian Falbesoner)
6fc2cd3f09 test: introduce helper to create random P2WPKH scriptPubKeys (Sebastian Falbesoner)
aa26797f69 test: MiniWallet: add `send_to` method to create arbitrary txouts (Sebastian Falbesoner)

Pull request description:

  This PR enables one more of the non-wallet functional tests (p2p_filter.py) to be run even with the Bitcoin Core wallet disabled by using the MiniWallet instead, as proposed in #20078.
  For this purpose, a MiniWallet method `send_to` is introduced first, which allows to create arbitrary outputs (scriptPubKey/amount). Note that the implementation for this is already present in feature_rbf.py (recently added in PR #22998), i.e. it is simply moved to the MiniWallet interface.

ACKs for top commit:
  laanwj:
    Code review ACK cfdb6baa22

Tree-SHA512: 13b063631f0d7af065b7757cfe8b47c9be6cb9850ac5db2968a2bba4f5a18cdc9f89173a9b03971545356225082042f5fdbe49d3036027d18e8b7eb042d04f5e
2021-09-29 09:13:07 +02:00
fanquake
2b90eae33c
doc: update developer docs for subtree renaming 2021-09-29 15:12:12 +08:00
MarcoFalke
7d4ea7c7ef
Merge bitcoin/bitcoin#23120: test: Remove unused and confusing main parameter from script_util
fa54efda9b test: pep-8 touched test (MarcoFalke)
fa46768059 test: Remove unused and confusing main parameter from script_util (MarcoFalke)

Pull request description:

ACKs for top commit:
  fanquake:
    ACK fa54efda9b

Tree-SHA512: 124e888e16c92bb24ab4d6f68a768d295500a48f8c6c0b4f069493effcd761f80be78dd93b31edbb529ebe4c8aaca764aaff48d1e3b23659dde722981dc787a5
2021-09-29 08:08:25 +02:00
Samuel Dobson
b207971465 Fix feature_segwit failure due to witness 2021-09-29 17:41:35 +13:00
Amiti Uttarwar
dd8f7f2500 scripted-diff: Rename CAddrMan to AddrMan
-BEGIN VERIFY SCRIPT-
git grep -l CAddrMan src/ test/ | xargs sed -i 's/CAddrMan/AddrMan/g'
-END VERIFY SCRIPT-
2021-09-28 22:21:10 -04:00
Andrew Chow
a99ed89865 psbt: sign without finalizing
We don't always want to finalize after signing, so make it possible to
do that.
2021-09-28 19:13:42 -04:00
Samuel Dobson
6a5381a06b
Merge bitcoin/bitcoin#20591: wallet, bugfix: fix ComputeTimeSmart function during rescanning process.
240ea294d5 doc: update doxygen documention of ComputeTimeSmart() and AddToWalletIfInvolvingMe() regarding rescanning_old_block parameter (BitcoinTsunami)
d6eb39af21 test: add functional test to check transaction time determination during block rescanning (BitcoinTsunami)
07b44f16e7 wallet: fix ComputeTimeSmart algorithm to use blocktime during old block rescanning (BitcoinTsunami)

Pull request description:

  The function ComputeTimeSmart in wallet.cpp assume that transaction are discovered in the right order.
  Moreover the 'smarttime' determination algorithm is coded with realtime scenario in mind and not rescanning of old block.

  The functional test demonstrate that if the user import a wallet, then rescan only recent history, and then rescan the entire history, the older transaction discovered would have an incorrect time determination.
  In the context of rescanning old block, the only time value that as a meaning is the blocktime.

  That's why I've fixed the problem with a simple separation between rescanning of old block and realtime time determination. The fix is written to have no impact on every realtime scenario and only impact the behaviour during a rescanning process.
  This PR Fixes #20181.

  To be fair, I don't think that this bug could be triggered with the wallet GUI, because it always proceed with a proper rescan.
  But RPC API provide the possibility to trigger it. I've discovered it, because Specter desktop v0.10.0 was impacted. (https://github.com/cryptoadvance/specter-desktop/issues/680).

ACKs for top commit:
  jonatack:
    ACK 240ea294d5 per `git diff b92d552 240ea29`, re-verified rebase to latest master + debug build clean + new test passes on the branch and fails on master, only change since my review a few hours ago is incorporation of latest review suggestions
  meshcollider:
    re-utACK 240ea294d5

Tree-SHA512: 514b02e41d011ddfa325f5e8080b93800e1ea4ed5853fa420670a6ac700e8b463000dbea65f8ced8565cfb950c7f51b69154034dcb111e67aca3b964a0061494
2021-09-29 11:18:23 +13:00
Samuel Dobson
b55232a337
Merge bitcoin/bitcoin#22722: rpc: update estimatesmartfee to return max of CBlockPolicyEstimator::estimateSmartFee, mempoolMinFee and minRelayTxFee
ea31caf6b4 update estimatesmartfee rpc to return max of estimateSmartFee, mempoolMinFee and minRelayTxFee. (pranabp-bit)

Pull request description:

  This PR is in response to the issue [#19699](https://github.com/bitcoin/bitcoin/issues/19699).

  Based on the discussion in the comments of PR [#22673](https://github.com/bitcoin/bitcoin/pull/22673) changes have been made in the `estimatesmartfee` itself such that it takes into account `mempoolMinFee` and `relayMinFee` . Hence it provides a fee estimate that is most likely to be paid by the user in an actual transaction, preventing issues such as [#16072](https://github.com/bitcoin/bitcoin/issues/16072).

  The test file test/functional/feature_fee_estimation.py has also been updated to check this functionality.

ACKs for top commit:
  meshcollider:
    re-utACK ea31caf6b4

Tree-SHA512: 8f36153a07cbd552c5c13d11d9c6e987a7a555ea4cc83f2573c0c92dd97c706d90c30a7248671437c2f3a836d3272f8fad53d15a5fa6efaa0409ae8009b0a18d
2021-09-29 10:55:29 +13:00
Samuel Dobson
d6492d4ed0
Merge bitcoin/bitcoin#22650: Remove -deprecatedrpc=addresses flag and corresponding code/logic
43cd6b8af9 doc: add release notes for removal of the -deprecatedrpc=addresses flag (Michael Dietz)
2b1fdc2c6c refactor: minor styling, prefer snake case and same line if (Michael Dietz)
d64deac7b8 refactor: share logic between ScriptPubKeyToUniv and ScriptToUniv (Michael Dietz)
8721638daa rpc: remove deprecated addresses and reqSigs from rpc outputs (Michael Dietz)

Pull request description:

  Resolves #21797 now that we've branched-off to v23 ("addresses" and "reqSigs" deprecated) "ExtractDestinations" should be removed.

   `-deprecatedrpc=addresses` was initially added in this PR #20286 (which resolved the original issue #20102).

  Some chunks of code and logic are no longer used/necessary with the removal of this, and therefore some minor refactoring is done in this PR as well (separated commits)

ACKs for top commit:
  MarcoFalke:
    re-ACK 43cd6b8af9 🐉
  meshcollider:
    Code review ACK 43cd6b8af9
  jonatack:
    ACK 43cd6b8af9 per `git range-diff a9d0cec 92dc5e9 43cd6b8`, also rebased to latest master, debug built + quick re-review of each commit to bring back context, and ran tests locally at the final commit

Tree-SHA512: fba83495e396d3c06f0dcf49292f14f4aa6b68fa758f0503941fade1a6e7271cda8378e2734af1faea550d1b43c85a36c52ebcc9dec0732936f9233b4b97901c
2021-09-29 10:41:30 +13:00
Niklas Gögge
18c5b23a0f [test] Test that -blocksonly nodes still serve compact blocks. 2021-09-28 22:11:30 +02:00
Niklas Gögge
a79ad65fc2 [test] Test that getdata(CMPCT) is still sent on regular low bandwidth connections.
Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
2021-09-28 22:11:30 +02:00
Niklas Gögge
5e231c116b [test] Test that -blocksonly nodes do not send getdata(CMPCT) on a low bandwidth connection.
Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
2021-09-28 22:11:30 +02:00
Niklas Gögge
5bf6587457 [test] Test that -blocksonly nodes do not request high bandwidth mode.
Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
2021-09-28 22:11:30 +02:00
BitcoinTsunami
d6eb39af21 test: add functional test to check transaction time determination during block rescanning 2021-09-28 21:49:22 +02:00
MarcoFalke
fa54efda9b
test: pep-8 touched test
Can be reviewed with "--word-diff-regex=.".
2021-09-28 15:48:55 +02:00
MarcoFalke
fa46768059
test: Remove unused and confusing main parameter from script_util
Bitcoin script opcodes are equal on all chains (main and test) anyway.

Can be reviewed with "--word-diff-regex=.".
2021-09-28 15:46:57 +02:00
W. J. van der Laan
efa227f5df
Merge bitcoin/bitcoin#23097: Run specified functional tests with all matching flags
b8909b0746 Run functional tests with all possible flags (Samuel Dobson)

Pull request description:

  Functional tests which use flags like `--descriptors` or `--legacy-wallet` won't run if only the base script is given to `test_runner.py` because it doesn't match any script in the list exactly. It would be easier if it would just run both options.

  For example, instead of:
  ```
  test_runner.py 'wallet_basic.py --legacy-wallet' 'wallet_basic.py --descriptors'
  ```

  We can now just run:
  ```
  test_runner.py wallet_basic
  ```

  Also useful for `--usecli`, the IPv4/IPv6/nonloopback `rpc_bind.py` variations, etc.

ACKs for top commit:
  laanwj:
    Code review ACK b8909b0746
  MarcoFalke:
    review ACK b8909b0746

Tree-SHA512: d367037cb170e705551726d47fe4569ebc3ceadece280dd3edbb3ecb41e19f3263d6d272b407316ed6011164e850df4321fb340b1b183b34497c9f7cc439f4d8
2021-09-28 15:32:23 +02:00