Commit Graph

4734 Commits

Author SHA1 Message Date
MacroFake
5f65afff9c
Merge bitcoin/bitcoin#24178: p2p: Respond to getheaders if we have sufficient chainwork
a35f963edf Add test for getheaders behavior (Suhas Daftuar)
ef6dbe6863 Respond to getheaders if we have sufficient chainwork (Suhas Daftuar)

Pull request description:

  Previously, we would check to see if we were in IBD and ignore getheaders requests accordingly. However, the IBD criteria -- an optimization mostly targeted at behavior when we have peers serving us many blocks we need to download -- is difficult to reason about in edge-case scenarios, such as if the network were to go a long time without any blocks found and nodes are getting restarted during that time.

  To make things simpler to reason about, just use `nMinimumChainWork` as our anti-DoS threshold for responding to a getheaders request; as long as our chain has that much work, it should be fine to respond to a peer asking for our headers (and this should allow such a peer to request blocks from us if needed).

ACKs for top commit:
  klementtan:
    crACK a35f963edf
  naumenkogs:
    ACK a35f963edf
  MarcoFalke:
    review ACK a35f963edf 🗯

Tree-SHA512: 131e3872e7fe80382ea9c1ec202d6c2dc59c006355c69000aa3f4ce6bccd02a6c689c8cb8f3542b5d9bc48bfa61edcbd1a78535c0b79018971d02bed2655d284
2022-05-31 12:05:46 +02:00
MacroFake
269fa667f2
Merge bitcoin/bitcoin#25044: test: Use MiniWallet in rpc_rawtransaction.py
e8959000b6 test: Use MiniWallet in rpc_rawtransaction.py (Daniela Brozzoni)
e93046c10b MOVEONLY: Move signrawtransactionwithwallet test (Daniela Brozzoni)

Pull request description:

  This PR allows `rpc_rawtransaction.py` to be run even without the Core wallet by using the MiniWallet instead, as proposed in https://github.com/bitcoin/bitcoin/issues/20078.
  This test was previously run twice, once with `--legacy-wallet` and once with
  `--descriptors`. Since this would have meant running the same test twice
  if the wallet wasn't compiled, now we run it just once with the legacy
  wallet.

ACKs for top commit:
  jonatack:
    ACK e8959000b6

Tree-SHA512: d1580570a54dad8e30a5df1ab7d03ecb3f824efe6843323e1f3aef63592045d823c7d54fc86321dc7c1d414854a253431a01a7baa9f30426ea9a09ef11ae3a04
2022-05-30 16:57:47 +02:00
Daniela Brozzoni
e8959000b6
test: Use MiniWallet in rpc_rawtransaction.py
This test was previously run twice, once with `--legacy-wallet` and once with
`--descriptors`.
Now we run it only with `--legacy-wallet`, as all the tests has been
ported to the MiniWallet but `raw_multisig_transaction_legacy_tests`,
which can be run only with the legacy wallet.
We also decrease the number of nodes used from 4 to 3, making the test
run slightly faster.
2022-05-30 16:25:18 +02:00
Daniela Brozzoni
e93046c10b
MOVEONLY: Move signrawtransactionwithwallet test
Put signrawtransactionwithwallet_tests in rpc_signrawtransaction.py,
as the test is mainly testing the signrawtransaction RPC.
Review with `git show --color-moved=dimmed-zebra`
2022-05-30 16:25:17 +02:00
James O'Beirne
6120e8e287 test: allow passing sequence through create_self_transfer_multi
And some little type annotation additions.
2022-05-27 13:40:06 -04:00
Sebastian Falbesoner
387ae8bc09 rpc: remove deprecated fee fields from mempool entries 2022-05-27 17:29:04 +02:00
MacroFake
3ba6dd6f4b
Merge bitcoin/bitcoin#24408: rpc: add rpc to get mempool txs spending specific prevouts
4185570340 Add RPC to get mempool txs spending outputs (t-bast)

Pull request description:

  We add an RPC to fetch mempool transactions spending any of the given outpoints.

  Without this RPC, application developers need to first call `getrawmempool` which returns a long list of `txid`, then fetch each of these transactions individually (`getrawtransaction`) to check whether they spend the given outpoints, which wastes a lot of bandwidth (in the worst case we need to transfer the whole mempool).

  For example in lightning, when we discover that one of our channel funding transactions has been spent, we need to find the spending transaction to claim our outputs from it. We are currently forced to fetch the whole mempool to do the analysis ourselves, which is quite costly.

  I believe that this RPC is also generally useful when doing some introspection on your mempool after one of your transactions failed to broadcast, for example when you implement RBF at the application level. Fetching and analyzing the conflicting transaction gives you more information to successfully replace it.

ACKs for top commit:
  darosior:
    re-utACK 4185570340
  vincenzopalazzo:
    re-ACK 4185570340
  danielabrozzoni:
    re-tACK 4185570340
  w0xlt:
    reACK 4185570340

Tree-SHA512: 206687efb720308b7e0b6cf16dd0a994006c0b5a290c8eb386917a80130973a6356d0d5cae1c63a01bb29e066dd721594969db106cba7249214fcac90d2c3dbc
2022-05-27 15:16:00 +02:00
Jon Atack
75848ec2da scripts and tools: update lint-logs.py to detect LogPrintLevel()
and add WalletLogPrintf() (already detected) to the lint-logs.py suggestion

Co-authored-by: laanwj <126646+laanwj@users.noreply.github.com>
2022-05-26 14:59:29 +02:00
MacroFake
8c721fff3a
Merge bitcoin/bitcoin#25192: test: add coverage for unknown value to -blockfilterindex
295ff61934 test: add coverage for unknown -blockfilterindex (brunoerg)

Pull request description:

  This PR adds test coverage for the following init error:
  44037a2912/src/init.cpp (L844)

  Passing an unknown value to -blockfilterindex should throw an error.

ACKs for top commit:
  dunxen:
    cr-ACK 295ff61

Tree-SHA512: 1444903cf0696406c485ce0575f951d527fe7d699094d5845622c0b57c954d6d7dcf1e78ef0c4e8b9b26f53b79583f07fec0e8d8e7f04aa744d2a8cd98329db9
2022-05-25 10:02:24 +02:00
Ben Woosley
bf209ac7a7
doc: Fix spelling errors identified by codespell in coments
From the output here:
src/qt/test/addressbooktests.cpp:185: wilcard ==> wildcard
src/qt/test/addressbooktests.cpp:191: wilcard ==> wildcard
src/test/miniscript_tests.cpp:227: nd ==> and, 2nd
src/test/versionbits_tests.cpp:260: everytime ==> every time
src/util/time.h:89: precicion ==> precision
src/util/time.h:90: precicion ==> precision
^ Warning: codespell identified likely spelling errors. Any false positives? Add them to the list of ignored words in test/lint/spelling.ignore-words.txt
https://cirrus-ci.com/task/5275612980969472?logs=lint#L849

I added 'nd' to the spelling.ignored-words.txt, as it's valid miniscript.
2022-05-25 00:26:21 -05:00
laanwj
7008087548
Merge bitcoin/bitcoin#24410: [kernel 2a/n] Split hashing/index GetUTXOStats codepaths, decouple from coinstatsindex
664a14ba7c coinstats: Move GetUTXOStats to rpc/blockchain (Carl Dong)
f100687566 kernel: Use ComputeUTXOStats in validation (Carl Dong)
faa52387e8 style-only: Rearrange using decls after scripted-diff (Carl Dong)
f329a9298c scripted-diff: Move src/kernel/coinstats to kernel:: (Carl Dong)
0e54456f04 Use only kernel/coinstats.h in index/coinstatsindex.h (Carl Dong)
80970985c9 coinstats: Split node/coinstats.h to kernel/coinstats.h (Carl Dong)
35f73ce4b2 coinstats: Move hasher codepath to kernel/coinstats (Carl Dong)
b7634fe02b Move logic from LookupUTXOStatsWithIndex to CoinStatsIndex::LookUpStats (Carl Dong)
1352e410a5 coinstats: Separate hasher/index lookup codepaths (Carl Dong)
524463daf6 coinstats: Return purely out-param CCoinsStats (Carl Dong)
46eb9fc56a coinstats: Extract index_requested in-member to in-param (Carl Dong)
a789f3f2b8 coinstats: Extract hash_type in-member to in-param (Carl Dong)
102294898d includes: Remove rpc/util.h -> node/coinstats.h (Carl Dong)
0848db9c35 fuzz: Remove useless GetUTXOStats fuzz case (Carl Dong)
52b1939993 kernel: Remove unnecessary blockfilter{index,}.cpp (Carl Dong)

Pull request description:

  Part of: #24303
  Depends on: #24322

  The `GetUTXOStats` function has 2 codepaths:
    - One which queries the `CoinStatsIndex` for the UTXO hash
    - One which actually performs the hashing

  For `libbitcoinkernel`, the only place where we call `GetUTXOStats` is in `PopulateAndValidateSnapshots`, which uses the `SHA256D` hash, and is therefore unable to use the `CoinStatsIndex` since that only provides `MuHash` hashes. Not that I think indices necessarily belong in `libbitcoinkernel` anyway.

  This PR separates these 2 aforementioned codepaths of `GetUTXOStats`, uses the hashing codepath in `PopulateAndValidateSnapshots`, and removes the need to link in `index/coinstatsindex.cpp` and `node/coinstats.cpp`.

  -----

  Logistically, this PR:
  - Extracts out the `index_requested` and `hash_type` members of `CoinStats`, which served as "in-params" to `GetUTXOStats` embedded within the `CoinStats` struct. This allows `CoinStats` to only consist of "out-param" members, and be returned by `GetUTXOStats` without needing to be an "in-out" param
  - Introduce the purely virtual `UTXOHashers` class, with 3 implementations: `SHA256DHasher`, `MuHashHasher`, and `NullHasher`. These replace the existing template-based polymorphism.
  - Split `GetUTXOStats` into:
      - `CalculateUTXOStatsWithHasher(UTXOHasher&, ...)`, and
      - `LookupUTXOStatsWithIndex(CoinStatsIndex&, ...)`
  - Use `CalculateUTXOStatsWithHasher` directly where appropriate (`src/validation.cpp` and `src/fuzz`)
  - Move `GetUTXOStats` to `rpc/blockchain`, which is the only place that depends on `GetUTXOStats`'s weird fallback behaviour
  - Move `LookupUTXOStatsWithIndex` to `index/coinstatsindex`

  Code organization:
  - `src/`
    - `kernel/` → only contains the hashing codepath
      - `coinstats.cpp` → hashing codepath implementations
      - `coinstats.h` → header for `kernel/coinstats.cpp`
    - `index/` → only contains the index codepath
      - `coinstatsindex.cpp` → index codepath implementations
      - `coinstatsindex.h`
    - `validation.cpp` → only uses the hashing codepath
    - `rpc/blockchain.cpp` → uses both the hashing and index codepath, old `GetUTXOStats` fallback logic moved here as static
    - `test/fuzz/coins_view.cpp` → only uses the hashing codepath

  TODOs:
  - [x] Commit messages could be fleshed out more

  Would love any feedback!

ACKs for top commit:
  laanwj:
    Code review ACK 664a14ba7c

Tree-SHA512: 18722c7bd279174d2d1881fec33ea04a9b261aae1c12e998cf434ef297d8ded47de69c526c8033a2ba7abc93ba3d2ff5faf4ce05e8888c725c31cf885ce3ef73
2022-05-24 14:43:00 +02:00
brunoerg
295ff61934 test: add coverage for unknown -blockfilterindex 2022-05-23 18:06:13 -03:00
Carl Dong
f100687566 kernel: Use ComputeUTXOStats in validation
This is the "fruit of our labor" for this patchset.
ChainstateManager::PopulateAndValidateSnapshot can now directly call
ComputeUTXOStats(...).

Our consensus engine is now fully decoupled from all indices.

See the src/Makefile.am for some satisfying removals.
2022-05-23 14:53:35 -04:00
Carl Dong
0e54456f04 Use only kernel/coinstats.h in index/coinstatsindex.h
Removes a circular dependency, horray!
2022-05-23 14:53:35 -04:00
MacroFake
fbb90c44ac
Merge bitcoin/bitcoin#25015: test: Use permissions from git in lint-files.py
908fb7e2ec test: Use permissions from git in `lint-files.py` (laanwj)
48d2e80a74 test: Don't use shell=True in `lint-files.py` (laanwj)

Pull request description:

  Improvements to the `lint-files.py` script:

  - Avoid use of `shell=True`.
  - Check the permissions in git's metadata instead of in the filesystem. This stops the umask or filesystem from interfering. It's also more efficient as it only needs a single call to `git ls-files`.

  (what triggered this change was `File "..." contains a shebang line, but has the file permission 775 instead of the expected executable permission 755.` errors running the script locally).

ACKs for top commit:
  vincenzopalazzo:
    re-tACK 908fb7e2ec

Tree-SHA512: 2eaf868c55a9c3508b12658a5b3ac429963fd0551e645332d0ac54be56fefccee95115e4667386df24b46b545593cb0d0bf8c6cecab73f9cb19d37ddf704c614
2022-05-23 18:59:26 +02:00
Andrew Chow
5ebff43025
Merge bitcoin/bitcoin#25122: rpc: getreceivedbylabel, return early if no addresses were found in the address book
baa3ddc49c doc: add release notes about `getreceivedbylabel` returning an error if the label is not in the address book. (furszy)
8897a21658 rpc: getreceivedbylabel, don't loop over the entire wallet txs map if no destinations were found for the input label. (furszy)

Pull request description:

  Built on top of #23662, coming from comment https://github.com/bitcoin/bitcoin/pull/23662#pullrequestreview-971407999.

  If `wallet.GetLabelAddresses()` returns an empty vector (the wallet does not have stored destinations with that label in the addressbook) or if none of the returned destinations are from the wallet, we can return the function right away.
  Otherwise, we are walking through all the wallet txs + outputs for no reason (`output_scripts` is empty).

ACKs for top commit:
  achow101:
    ACK baa3ddc49c
  theStack:
    re-ACK baa3ddc49c
  w0xlt:
    ACK baa3ddc49c

Tree-SHA512: 00e10365b179bf008da2f3ef8fbb3ee04a330426374020e3f2d0151b16991baba4ef2b944e4659452f3e4d6cb20f128d0918ddf0453933a25a4d9fd8414a1911
2022-05-23 12:15:14 -04:00
laanwj
908fb7e2ec test: Use permissions from git in lint-files.py
Instead of using permissions from the local file system, which might
depend on the umask, directly check the permissions from git's metadata.
2022-05-23 11:09:07 +02:00
furszy
8897a21658
rpc: getreceivedbylabel, don't loop over the entire wallet txs map if no destinations were found for the input label.
If wallet.GetLabelAddresses() returns an empty vector (the wallet does not have addresses with that label in the addressbook) or if none of the returned destinations are from the wallet, we can return the function right away.
2022-05-20 16:32:09 -03:00
MacroFake
a7e3afb221
Merge bitcoin/bitcoin#25171: rpc: wallet: remove -deprecatedrpc=exclude_coinbase logic
a4703ce9d7 doc: add release notes about removal of the `deprecatedrpc=exclude_coinbase` (Sebastian Falbesoner)
ef0aa74836 rpc: wallet: remove `-deprecatedrpc=exclude_coinbase` logic (Sebastian Falbesoner)

Pull request description:

  Including coinbase transactions in `receivedby` RPCs and adding the `-deprecatedrpc=exclude_coinbase` was done in PR #14707 (released in v23.0). For the next release v24.0, this configuration option can be removed.

ACKs for top commit:
  fanquake:
    ACK a4703ce9d7

Tree-SHA512: 97cd4e78501e64f678c78d2ebb5be5376688c023e34fced71dd24e432d27aa31a74b5483545f49ba0bdf48656d8b8b7bee74e3db26cf6daf112613f1caa4dfa4
2022-05-20 08:48:09 +01:00
MacroFake
4a8709821e
Merge bitcoin/bitcoin#24830: init: Allow -proxy="" setting values
1d4122dfef init: Allow -proxy="" setting values (Ryan Ofsky)

Pull request description:

  This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>` error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or `settings.json` value is specified, and just makes bitcoin connect and listen normally in these cases.

  The error was originally added in https://github.com/bitcoin/bitcoin/pull/20003 to prevent a bare `-proxy` command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty `-proxy=` assignments as well.

  The motivation for this change is to prevent a GUI bug that happens with https://github.com/bitcoin/bitcoin/pull/15936, reported in https://github.com/bitcoin/bitcoin/pull/15936#pullrequestreview-937685759 by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message.

ACKs for top commit:
  hebasto:
    re-ACK 1d4122dfef, only rebased since my recent [review](https://github.com/bitcoin/bitcoin/pull/24830#pullrequestreview-941255672).

Tree-SHA512: 753adfce199ed078a6cd9e0ea78e76c0b14070f8fcfe2a4632cd0c6dfe6b4e135ddffbe11a97e5e30520ea9e5bda00bad1493cbaef74cf425aa8613249167f53
2022-05-20 08:28:08 +01:00
MacroFake
d433f59f1e
Merge bitcoin/bitcoin#25173: test: add coverage for unknown network in -onlynet
055d94d1ab test: add coverage for unknown network in -onlynet (brunoerg)

Pull request description:

  This PR adds test coverage for the following init error by passing an unknown network in -onlynet
  0de36941ec/src/init.cpp (L1311)

ACKs for top commit:
  MarcoFalke:
    rACK 055d94d1ab

Tree-SHA512: 01bbb297afff371f6345889fa04117ff195b68f0bbf934878ba446049791fdbd7d2ce119ee4f9b3616cc0a81330d7055507dc81151acf68532c077f3575258e9
2022-05-20 08:18:02 +01:00
brunoerg
055d94d1ab test: add coverage for unknown network in -onlynet 2022-05-19 18:39:23 -03:00
Sebastian Falbesoner
1da5e45725 test: use MiniWallet for feature_dbcrash.py
This test can now be run even with the Bitcoin Core wallet disabled.
2022-05-19 17:53:30 +02:00
Sebastian Falbesoner
ef0aa74836 rpc: wallet: remove -deprecatedrpc=exclude_coinbase logic 2022-05-19 16:10:59 +02:00
fanquake
fdb82a30be
Merge bitcoin/bitcoin#25147: Net processing: follow ups to #20799 (removing support for v1 compact blocks)
bf6526f4a0 [test] Remove segwit argument from build_block_on_tip() (John Newbery)
c65bf50b44 Remove fUseWTXID parameter from CBlockHeaderAndShortTxIDs constructor (John Newbery)

Pull request description:

  This implements two of the suggestions from code reviews of PR 20799:

  - Remove fUseWTXID parameter from CBlockHeaderAndShortTxIDs constructor
  - Remove segwit argument from build_block_on_tip()

ACKs for top commit:
  dergoegge:
    Code review ACK bf6526f4a0
  naumenkogs:
    ACK bf6526f4a0

Tree-SHA512: d553791d1364b9e655183755e829b195c9b47f59c62371dbae49d9c0f8d84fec58cf18f4dde89591672ef5658e18c9cf0206c2efd70606980f87e506bc3bd4e5
2022-05-19 09:37:32 +01:00
MacroFake
bb83aba6c9
Merge bitcoin/bitcoin#25161: rpc: Put undocumented JSON failure mode behind a runtime flag
b953ea6cc6 rpc: Put undocumented JSON failure mode behind a runtime flag (Suhail Saqan)

Pull request description:

  Fixes #24695 (Put undocumented JSON failure mode behind a runtime flag)

ACKs for top commit:
  luke-jr:
    utACK b953ea6cc6
  vincenzopalazzo:
    ACK b953ea6cc6

Tree-SHA512: 2005ee1b1f3b637918390b2ecd4166f2fd8c86e3c59fba3da8a0cbd5b1dffd03190c92f6dca3c489ecce4276eaf3108b2edcf9cd6224b713adb52f5bb848163b
2022-05-19 06:44:55 +02:00
Suhail Saqan
b953ea6cc6 rpc: Put undocumented JSON failure mode behind a runtime flag
rpc: Put undocumented JSON failure mode behind a runtime flag
2022-05-18 10:50:59 -07:00
MacroFake
e016c00e98
Merge bitcoin/bitcoin#25126: test: add BIP157 message parsing support (via MESSAGEMAP)
5dc6d92077 test: make BIP157 messages default-constructible (MESSAGEMAP compatibility) (Sebastian Falbesoner)
71e4cfefe7 test: p2p: add missing BIP157 message types to MESSAGEMAP (Sebastian Falbesoner)

Pull request description:

  The script [message-capture-parser.py](https://github.com/bitcoin/bitcoin/blob/master/contrib/message-capture/message-capture-parser.py) currently doesn't support parsing the BIP157 messages `getcfilters`, `getcfheaders` and `getcfcheckpt`, e.g.
  ```
  $ ./contrib/message-capture/message-capture-parser.py msgs_recv.dat
  ...
      WARNING - Unrecognized message type b'getcfcheckpt' in /home/thestack/bitcoin/msgs_recv.dat
  ...
  ```

  This PR fixes this by adding the missing message type mappings to the [`MESSAGEMAP`](225e5b57b2/test/functional/test_framework/p2p.py (L95-L127)) in the test framework and add default-constructors for the corresponding `msg_`... classes.

  Without the second commit, the following error message would occur:
  ```
    File "/home/thestack/bitcoin/./contrib/message-capture/message-capture-parser.py", line 141, in process_file
      msg = MESSAGEMAP[msgtype]()
  TypeError: __init__() missing 2 required positional arguments: 'filter_type' and 'stop_hash'
  ```

ACKs for top commit:
  dunxen:
    tACK [5dc6d92](5dc6d92077)

Tree-SHA512: d656c4d38a856373f01d7c293ae7d2b27378a9fc248048ebf2a64725ef8b498b3ddf4f420704abdb20d0c68ca548f1777602c5e73b66821a20c97ae618f1d63f
2022-05-18 19:08:48 +02:00
MacroFake
139f789d7a
Merge bitcoin/bitcoin#25124: test: Fix intermittent race in p2p_unrequested_blocks.py
faac67cab0 test: Fix intermittent race in p2p_unrequested_blocks.py (MacroFake)

Pull request description:

  Disconnect may also result in an `OSError`, not only an `AssertionError`. Instead of maintaining a dead code path and enumerating disconnect reasons, just assume disconnection happens every time.

ACKs for top commit:
  jamesob:
    Code review ACK faac67cab0

Tree-SHA512: d2cec003168e421a5faed275cb2e1ef9fc63f9e8514f41d21da17e8964c79e5b453ccd72cd7ec62805f45293cf877be5bc8124ae98a515c0aa42d6e053409653
2022-05-18 15:39:20 +02:00
John Newbery
bf6526f4a0 [test] Remove segwit argument from build_block_on_tip()
The only place that segwit=True is for a block that contains only the
coinbase transaction. Since the witness commitment is optional if none
of the transactions have a witness, we can leave it out. This doesn't
change the test coverage, which is testing p2p compact block logic.

Suggested in https://github.com/bitcoin/bitcoin/pull/20799#discussion_r867782119
2022-05-18 13:47:54 +01:00
S3RK
7832e9438f test: fundrawtransaction preset input weight calculation 2022-05-18 08:25:08 +02:00
ishaanam
c6122f560b test: use sendall in wallet_taproot.py tests
Fixes #25129 (subtractfeefromamount=true fails with insufficient
funds)
2022-05-17 13:40:15 -04:00
fanquake
d5d40d59f8
Merge bitcoin/bitcoin#23679: Sanitize port in addpeeraddress()
ada8358ef5 Sanitize port in `addpeeraddress()` (amadeuszpawlik)

Pull request description:

  In connection to #22087, it has been [pointed out](https://github.com/bitcoin/bitcoin/pull/22087#pullrequestreview-674786285) that `addpeeraddress` needs to get its port-value sanitized.

ACKs for top commit:
  fanquake:
    ACK ada8358ef5

Tree-SHA512: 48771cd4f6940aa7840fa23488565c09dea86bd5ec5a5a1fc0374afb4857aebcd2a1f51e2d4cb7348460e0ad9793dc5d2962df457084ed2b8d8142cae650003f
2022-05-17 16:39:10 +01:00
Suhas Daftuar
48262a00f5 Add functional test for block sync from inbound peers 2022-05-17 09:36:49 -04:00
John Newbery
42882fc8fc [net processing] Only accept sendcmpct with version=2
Subsequent commits will remove support for other versions of compact blocks.

Add a test that a received `sendcmpct` message with version = 1 is
ignored.
2022-05-15 15:37:56 -04:00
John Newbery
16730b64bb [net processing] Only advertise support for version 2 compact blocks
Subsequent commits will remove support.
2022-05-15 15:37:56 -04:00
John Newbery
cba909eaf9 [net] Stop testing version 1 compact blocks.
Support for version 1 is removed in the following commits.
2022-05-15 15:37:56 -04:00
MacroFake
b74a6dde8c
Merge bitcoin/bitcoin#25123: test: Fix race condition in index prune test
4faa550072 test: Fix race condition in index pruning test (Fabian Jahr)

Pull request description:

  Fixes #25031

  The `feature_index_prune.py` test seems to be racy because connections are reestablished after restarts and the blocks are synced via the `sync_blocks` function. The `sync_blocks` function has a sanity check at the beginning to check that all nodes in the set have at least one established connection and that is not always the case.

  As a solution nodes are not connected via the `-connect` parameter on start but instead via the `connect_nodes` helper.

Top commit has no ACKs.

Tree-SHA512: f88377715f455f1620725fe8ebd6b486fa0209660b193bf68d1ce1452e2086ac5d169d8ca4c2b61443566232e96fb9c6386ee482bc546cce38078d72e7c3c29f
2022-05-15 09:19:43 +02:00
Fabian Jahr
4faa550072
test: Fix race condition in index pruning test
Nodes are restarted and reconnected as part of the test. Afterwards
`sync_blocks` is called immediately on the nodes. `sync_blocks`
first checks that all the included nodes have at least one
connection. Since adding a connection is usually happening in a
thread, sometimes nodes could run into this check before the
connection was fully established so that it would fail the entire
test.

This fix uses the `connect_nodes` helper to make the connection the
nodes. `connect_nodes` has a wait for the connection built into it.
2022-05-14 17:33:41 +02:00
amadeuszpawlik
ada8358ef5 Sanitize port in addpeeraddress()
- Ensures port sanitization in `addpeeraddress()`
- Adds test to check for invalid port values
2022-05-14 10:22:16 +02:00
Sebastian Falbesoner
5dc6d92077 test: make BIP157 messages default-constructible (MESSAGEMAP compatibility)
In order to deserialize received or read messages via lookup in
MESSAGEMAP (e.g.: `t = MESSAGEMAP[msgtype]()`), the messages must have a
default constructor, i.e. there needs to be the possibility to
initialize them with zero arguments.
2022-05-13 13:53:25 +02:00
Sebastian Falbesoner
71e4cfefe7 test: p2p: add missing BIP157 message types to MESSAGEMAP 2022-05-13 13:37:46 +02:00
MacroFake
faac67cab0
test: Fix intermittent race in p2p_unrequested_blocks.py 2022-05-13 09:15:12 +02:00
MacroFake
1d5325a8f9
Merge bitcoin/bitcoin#25117: test: Check msg type in msg capture is followed by zeros
faa5a7a573 test: Check msg type in msg capture is followed by zeros (MacroFake)

Pull request description:

  Checking that they are not printable is an odd (and wrong) way to check that all chars are zero.

ACKs for top commit:
  theStack:
    Code-review ACK faa5a7a573

Tree-SHA512: 63e001bd25298dcf47606f8ab11ddfb704ca963304149b0f6e188eb7dcf45c41f92d39f26bda32bceb03384720c9bdddb2673dba513cd9242dc9663d498b3f29
2022-05-13 07:49:22 +02:00
brunoerg
1df42bc262 test: compare /mempool/info response with getmempoolinfo RPC 2022-05-12 17:49:50 -03:00
MacroFake
faa5a7a573
test: Check msg type in msg capture is followed by zeros 2022-05-12 17:07:35 +02:00
Sebastian Falbesoner
9feb887082 rpc: check fopen return code in dumptxoutset
This change improves the usability of the `dumptxoutset` RPC in two ways,
in the case that an invalid path is passed:
  1. return from the RPC immediately, rather then when the file is first
     tried to be written (which is _after_ calculating the UTXO set hash)
  2. return a proper return code and error message instead of the cryptic
     "CAutoFile::operator<<: file handle is nullptr: unspecified
      iostream_category error" (-1)
2022-05-11 16:03:40 +02:00
laanwj
ed4eeafbb6
Merge bitcoin/bitcoin#24793: test: Change color of skipped functional tests
3258bad996 changes color of skipped functional tests (Jacob P. Fickes)

Pull request description:

  changes the color of skipped functional tests (currently grey and can be hard to read/invisible on dark backgrounds) to yellow.

  resolves #24791

ACKs for top commit:
  theStack:
    Tested ACK 3258bad996
  jarolrod:
    Tested ACK 3258bad996

Tree-SHA512: 3fe5ae0d3b4902b2b6bda6e89ab780feb8bf4b7cb1ce7e8467057b94a1e0a26ddeaf3cac0bc19b06ef10d8bccaac9c495029d42740fbedab8fb0d5fdd7d02eaf
2022-05-10 13:12:38 +02:00
laanwj
efae252f30 test: Remove extended lint (cppcheck)
These are unreferenced in the CI and documentation, and have been since
2019 (see #17549).

I'm not sure the cppcheck is worthwhile. It takes a long time
to run (I think this is why it isn't in the normal lints), and right
now it only appears to find implicit constructors. The list of
exceptions is out of date. But if anyone wants to bring it back at any
time in the future they can do so from git history (and port it to Python).
2022-05-09 15:01:00 +02:00
MacroFake
77a9997d97
Merge bitcoin/bitcoin#25063: test: previous releases: add v23.0
dba1231672 test: previous releases: add v23.0 (Sjors Provoost)

Pull request description:

  Follows the same pattern as d8b705f1ca (v22.0) and 8a57a06a50 (v0.21.0).

  Starting from v23.0 there is a separate macOS release for x86_64 and aarch64.

ACKs for top commit:
  prusnak:
    Approach ACK dba1231672

Tree-SHA512: 249aeddd5e80e163578581e5c8e9b6579f3694abc3d1fb68dddb7b42d75021ad85266688ec4a365a6631d82a65a19873aff7ba61c0ea59d21f8adbe4b772dc16
2022-05-06 11:38:03 +02:00
Sjors Provoost
dba1231672
test: previous releases: add v23.0
Starting from v23.0 there is a separate macOS release for x86_64 and aarch64.

Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
2022-05-06 10:00:47 +02:00
MacroFake
c367736f85
Merge bitcoin/bitcoin#24840: test: port 'lint-shell.sh' to python
bd6ceb4049 test: port 'lint-shell.sh' to python (whiteh0rse)

Pull request description:

  Converts `test/lint/lint-shell.sh` to Python and updates the docs accordingly. In order for the linter to run, it requires `git` and the `shellcheck` linter to be installed on the system. The script will fail gracefully with a help message if `shellcheck` is not installed.

Top commit has no ACKs.

Tree-SHA512: edc3f1af582b736a0b46f32bd7448e859201dc43f5dd086f16aab49037a1ab936f5376c29fc1006a932b9e98b4f2423d83d98e9666304781a06eb4d2a16f54e3
2022-05-05 17:07:15 +02:00
whiteh0rse
bd6ceb4049
test: port 'lint-shell.sh' to python 2022-05-05 08:44:08 -05:00
t-bast
4185570340
Add RPC to get mempool txs spending outputs
We add an RPC to fetch the mempool transactions spending given outpoints.
Without this RPC, application developers would need to first call
`getrawmempool` which returns a long list of `txid`, then fetch each of
these txs individually to check whether they spend the given outpoint(s).

This RPC can later be enriched to also find confirmed transactions instead
of being restricted to mempool transactions.
2022-05-05 14:56:48 +02:00
laanwj
5e1aacab57
Merge bitcoin/bitcoin#24933: util: Replace non-threadsafe strerror
e3a06a3c6c test: Add `strerror` to locale-dependence linter (laanwj)
f00fb1265a util: Increase buffer size to 1024 in SysErrorString (laanwj)
718da302c7 util: Refactor SysErrorString logic (laanwj)
e7f2f77756 util: Use strerror_s for SysErrorString on Windows (laanwj)
46971c6dbf util: Replace non-threadsafe strerror (laanwj)

Pull request description:

  Some uses of non-threadsafe `strerror` have snuck into the code since they were removed in #4152. Add a wrapper `SysErrorString` for thread-safe strerror alternatives (with code from `NetworkErrorString`) and replace all uses of `strerror` with this.

  Edit: I've also added a commit that refactors the code so that buf[] is never read at all if the function fails, making some fragile-looking code unnecessary.

  Edit2: from the linux manpage:
  ```
  ATTRIBUTES
         For an explanation of the terms used in this section, see attributes(7).

         ┌───────────────────┬───────────────┬─────────────────────────┐
         │Interface          │ Attribute     │ Value                   │
         ├───────────────────┼───────────────┼─────────────────────────┤
         │strerror()         │ Thread safety │ MT-Unsafe race:strerror │
         ├───────────────────┼───────────────┼─────────────────────────┤
  …
         ├───────────────────┼───────────────┼─────────────────────────┤
         │strerror_r(),      │ Thread safety │ MT-Safe                 │
         │strerror_l()       │               │                         │
         └───────────────────┴───────────────┴─────────────────────────┘
  ```
  As the function can be called from any thread at any time, using a non-thread-safe function is unacceptable.

ACKs for top commit:
  jonatack:
    ACK e3a06a3c6c

Tree-SHA512: 20e71ebb9e979d4e1d8cafbb2e32e20c2a63f09115fe72cdde67c8f80ae98c531d286f935fd8a6e92a18b72607d7bd3e846b2d871d9691a6036b0676de8aaf25
2022-05-04 21:08:30 +02:00
laanwj
0047d9b89b
Merge bitcoin/bitcoin#24993: test, contrib, refactor: use with when opening a file
027aab663a test, contrib, refactor: use `with` when opening a file (brunoerg)

Pull request description:

  When manipulating a file in Python without using `with()`, you have to close the file manually, so this PR does it in `get_block_hashes` (`contrib/linearize/linearize-data.py`).

  Edit: this PR does it for all occurances that previously weren't using `with`.

ACKs for top commit:
  laanwj:
    Code review ACK 027aab663a

Tree-SHA512: 879400968e0013e8678ec16f1fe5d0963a73c1e0d442ca34802d885214f0783d2e9a9b500fc6be7c3b93560a367b6a3d685eee24d2f9ce53fddf064ea6feecf8
2022-05-04 19:52:16 +02:00
fanquake
bde5836f99
Merge bitcoin/bitcoin#25057: refactor: replace remaining boost::split with SplitString
f849e63bad fuzz: SplitString with multiple separators (Martin Leitner-Ankerl)
d1a9850102 http: replace boost::split with SplitString (Martin Leitner-Ankerl)
0d7efcdf75 core_read: Replace boost::split with SplitString (Martin Leitner-Ankerl)
b7ab9db545 Extend Split to work with multiple separators (Martin Leitner-Ankerl)

Pull request description:

  As a followup of #22953, this removes the remaining occurrences of `boost::split` and replaces them with our own `SplitString`. To be able to do so, this extends the function `spanparsing::Split` to work with multiple separators. Finally this removes 3 more files from `lint-includes.py`.

ACKs for top commit:
  theStack:
    Code-review ACK f849e63bad

Tree-SHA512: f37d4dbe11cab2046e646045b0f018a75f978d521443a2c5001512737a1370e22b09247d5db0e5c9e4153229a4e2d66731903c1bba3713711c4cae8cedcc775d
2022-05-04 18:20:27 +01:00
MacroFake
9b42d62f42
Merge bitcoin/bitcoin#25045: test: add coverage for invalid requests for blockfilterheaders (REST)
d1bfe5ebdb test: add coverage for invalid requests for `blockfilterheaders` (brunoerg)

Pull request description:

  This PR adds test coverage for invalid requests (`Invalid hash` and `Unknown filtertype`) for `/blockfilterheaders` in REST functional test.

ACKs for top commit:
  jonatack:
    ACK d1bfe5ebdb
  vincenzopalazzo:
    ACK d1bfe5ebdb

Tree-SHA512: 9ab7efe7131296577c60642f95921799cf1dbae9c2aaea6752d2ac9f35a1bcc72b9d742a146c314f82fe1848190a80c88836ab78fc28773ed12e97fa327828e7
2022-05-04 09:57:40 +02:00
Martin Leitner-Ankerl
d1a9850102
http: replace boost::split with SplitString
Also removes boost/algorithm/string.hpp from expected includes
2022-05-04 07:34:48 +02:00
Martin Leitner-Ankerl
0d7efcdf75
core_read: Replace boost::split with SplitString
Note that `SplitString` doesn't support token compression, but in this case
it does not matter as empty strings are already skipped anyways.

Also removes split.hpp and classification.hpp from expected includes
2022-05-04 07:34:47 +02:00
brunoerg
d1bfe5ebdb test: add coverage for invalid requests for blockfilterheaders 2022-05-03 15:04:54 -03:00
MacroFake
d24318a40c
Merge bitcoin/bitcoin#24941: test: MiniWallet: support skipping mempool checks (feature_fee_estimation.py performance fix)
a498acce45 test: MiniWallet: skip mempool check if `mempool_valid=False` (Sebastian Falbesoner)
01552e8f67 test: MiniWallet: always rehash after signing (P2PK mode) (Sebastian Falbesoner)

Pull request description:

  MiniWallet's core method for creating txs (`create_self_transfer`) right now always executes the `testmempoolaccept` RPC to check for mempool validity or invalidity. In some test cases where we use MiniWallet to create a huge number of transactions this can lead to performance issues, in particular feature_fee_estimation.py where the execution time after MiniWallet usage (PR #24817) doubled, see https://github.com/bitcoin/bitcoin/issues/24828#issuecomment-1100058100, https://github.com/bitcoin/bitcoin/issues/24828#issuecomment-1100301980. This PR mitigates this by skipping the mempool check if the parameter `mempool_valid` is set to `False`.

  As a preparatory commit, the test feature_csv_activation.py has to be adapted w.r.t. to rehashing of transactions, as we now hash all transactions immediately in `create_self_transfer` in order to get the txid (before we relied on the result of `testmempoolaccept`).

  On my machine, this decreases the execution time quite noticably:

  master branch:
  ```
  $ time ./test/functional/feature_fee_estimation.py
  real    3m20.771s
  user    2m52.360s
  sys     0m39.340s
  ```

  PR branch:
  ```
  $ time ./test/functional/feature_fee_estimation.py
  real    2m1.386s
  user    1m42.510s
  sys     0m22.980s
  ```

  Partly fixes #24828 (hopefully).

ACKs for top commit:
  danielabrozzoni:
    tACK a498acce45

Tree-SHA512: f20c358ba42b2ded86175f46ff3ff9eaefb84175cbd1c2624f44904c8d8888e67ce64d6dcbb26aabbf07906e6f5bdea40353eba9ae668618cadcfc517ef7201b
2022-05-03 09:59:52 +02:00
laanwj
037c5e511f
Merge bitcoin/bitcoin#25042: lint: Fix lint-circular-dependencies.py file list
fad0abf539 lint: Fix lint-circular-dependencies.py file list (MacroFake)

Pull request description:

  currently in-tree files like `wallet/test/fuzz/coinselection.cpp` are missed. Also out-of-tree files like `test/data/bip341_wallet_vectors.json.h` or `qt/moc_qvaluecombobox.cpp` are included.

  Change the script to only use in-tree files.

  Also, change `'python3'` to `sys.executable`.

ACKs for top commit:
  laanwj:
    Code review ACK fad0abf539

Tree-SHA512: baf150fbae6a7120b2692f2eaef6a7773f2681e1610f8776f8d2ae6736c74736502a505df080b2182880f753b90f94e76a1e365fb45185f46f0e4d5521ca8e86
2022-05-02 16:35:23 +02:00
MacroFake
fa12706fc6
Reject invalid rpcauth formats 2022-04-30 12:53:35 +02:00
MacroFake
fad0abf539
lint: Fix lint-circular-dependencies.py file list 2022-04-30 11:16:44 +02:00
Martin Zumsande
a3cd7dbfd8 test: stop node before calling assert_start_raises_init_error
...in feature_coinstatsindex and feature_pruning.
Also add an assert to assert_start_raises_init_error that the node is
not already running.
2022-04-29 22:50:26 +02:00
Andrew Chow
606ce05ec2
Merge bitcoin/bitcoin#18554: wallet: ensure wallet files are not reused across chains
5f213213cb tests: add tests for cross-chain wallet use prevention (Seibart Nedor)
968765973b wallet: ensure wallet files are not reused across chains (Seibart Nedor)

Pull request description:

  This implements a proposal in #12805 and is a rebase of #14533.

  This seems to be a working approach, but I'm not sure why the `p2p_segwit.py` functional test needed a change, so I'll look into it more.

ACKs for top commit:
  achow101:
    ACK 5f213213cb
  dongcarl:
    Code Review ACK 5f213213cb
  [deleted]:
    tACK 5f213213cb

Tree-SHA512: 2c934300f113e772fc31c16ef5588526300bbc36e4dcef7d77bd0760c5c8f0ec77f766b1bed5503eb0157fa26dc900ed54d2ad1b41863c1f736ce5c1f3b67bec
2022-04-28 15:59:47 -04:00
laanwj
47b8256da8
Merge bitcoin/bitcoin#24937: test: Remove previous release check in feature_taproot.py
fafd67479a test: Remove previous release check (MarcoFalke)

Pull request description:

  Now that the commit (7c08d81e11) which changes taproot to be enforced for all blocks is sufficiently buried by other commits, and thus less likely to be reverted,  it seems a good time to remove no longer needed test code.

  The `feature_taproot` functional test is cleaned up to no longer run against a previous release. Since previous releases are static and impossible to change, it is sufficient to run the test once against the release. Now that this is done, the check can be removed without decreasing test coverage.

ACKs for top commit:
  laanwj:
    Concept and code review ACK fafd67479a
  vincenzopalazzo:
    ACK fafd67479a

Tree-SHA512: fcb1a93f3bf9deb5f5c7327a7cd23be10ba09c9f4cbfa73ee2764a93c6ce7d6fa98ca32f2cf4023c20ab624aee601beec949fd02a57a3a658fdbd4be1a9ff338
2022-04-28 19:25:27 +02:00
fanquake
e36c612e5a
Merge bitcoin/bitcoin#24988: lint: Mention NONFATAL_UNREACHABLE in lint-assertions.py
fa82a1ed83 lint: Mention NONFATAL_UNREACHABLE in lint-assertions.py (MacroFake)

Pull request description:

  Follow up to commit b1c5991eeb. Also remove empty newline added in that commit.

ACKs for top commit:
  fanquake:
    ACK fa82a1ed83

Tree-SHA512: cf398eceb135672137183bfa19ee57a82553a3dbcbce74db954c6fcd79f9606092cc0d8217610fe6cd67b7ef2d4f01d90329f0f568516d9b14aa2cd0f0715478
2022-04-28 12:40:36 +01:00
laanwj
48d2e80a74 test: Don't use shell=True in lint-files.py
Avoid the use of shell=True.
2022-04-28 12:29:24 +02:00
laanwj
85aea18ae6
Merge bitcoin/bitcoin#24982: tests: Port lint-all.sh to lint-all.py
29f44fed36 Converting `lint-all.sh` to `lint-all.py`. (hiago)

Pull request description:

  This PR is converting `test/lint/lint-all.sh` to `test/lint/lint-assertions.py`. It's an item of https://github.com/bitcoin/bitcoin/issues/24783.

ACKs for top commit:
  laanwj:
    Tested ACK 29f44fed36

Tree-SHA512: 5427936aaa8e009613048448cbd79d9225675bdcadcf4fbb70fd091e0aab85e350ef1678da1b388f70d62ca16f40409409f90da3f6bbf057480522cd50fde811
2022-04-28 12:28:30 +02:00
laanwj
e3a06a3c6c test: Add strerror to locale-dependence linter
Add `strerror` to the locale-dependence linter to catch its use. Add
exemptions for bdb interface code (false positive) and strerror.cpp
(the only allowed use).

Also fix a bug in the regexp so that `_r` and `_s` variants are detected
again.
2022-04-28 10:24:06 +02:00
MacroFake
4381681e55
Merge bitcoin/bitcoin#25011: tests: Do not always create a descriptor wallet in wallet_createwallet
786b3a7c44 tests: Do not always create a descriptor wallet in wallet_createwallet (Andrew Chow)

Pull request description:

  The createwallet test for some invalid parameters incorrectly always creates a descriptor wallet. This is unnecessary and also breaks the test when bdb is not compiled in.

  Fixes #25007

ACKs for top commit:
  jacobpfickes:
    ACK 786b3a7c44

Tree-SHA512: 97b0953a08adf83d5ea84cac2651253d790b43d606a2f746dd45d3ccd1fb576bab63e3835e3de592715ef8a5cb133e6f19a3ab810fedf4684072143c3cb578d4
2022-04-28 07:41:22 +02:00
brunoerg
027aab663a test, contrib, refactor: use with when opening a file 2022-04-27 20:04:33 -03:00
Andrew Chow
786b3a7c44 tests: Do not always create a descriptor wallet in wallet_createwallet
The createwallet teswt for some invalid parameters incorrectly always
creates a descriptor wallet. This is unnecessary and also breaks the
test when bdb is not compiled in.
2022-04-27 14:50:04 -04:00
MacroFake
f0a834e2f1
Merge bitcoin/bitcoin#18642: Use std::chrono for the time to rotate destination of addr messages + tests
2ff8f4dd81 Add tests for addr destination rotation (Gleb Naumenko)
77ccb7fce1 Use std::chrono for salting when randomizing ADDR destination (Gleb Naumenko)

Pull request description:

  We currently assign a destination peer for relaying particular addresses of nodes every 24 hours, and then rotate. This is done for rate-limiting (ultimately for privacy leak reduction I think?).

  Before this change, 24 hours was defined as uint. I replaced it with std::chrono, which is mockable and type-safe.

  Also added couple tests for this behavior.

ACKs for top commit:
  jonatack:
    ACK 2ff8f4dd81

Tree-SHA512: 16f703ef3ffee13ce3afa82ca7b4baa27308af18cd2eececdce5565badfb68656a2ad9c4594b73772e4bfa99b3fb15f8e4089c1cb4be98c0bae6730a9d2f8a25
2022-04-27 18:59:46 +02:00
MacroFake
f58c1f1a44
Merge bitcoin/bitcoin#24739: test: Fix intermittent test failure in wallet_listreceivedby.py
fa1f6df21e test: Fix intermittent test failure in wallet_listreceivedby.py (MarcoFalke)

Pull request description:

  * Remove not needed "Generate block to get out of IBD"
  * Sync blocks where possible to avoid incoming blocks on the p2p `msghand` thread while blocks are mined in the RPC thread. See https://github.com/bitcoin/bitcoin/issues/24730 for discussion.

Top commit has no ACKs.

Tree-SHA512: eca0242e7793886535555fec62f7acd4c0955bf26fab78725b4fe53f84f0b118cb12c9ee35627503fc68b83c3a228842e861fab89aab1226e08e18596357aaae
2022-04-27 08:44:21 +02:00
fanquake
34ae04d775
Merge bitcoin/bitcoin#21726: Improve Indices on pruned nodes via prune blockers
71c3f0356c move-only: Rename index + pruning functional test (Fabian Jahr)
de08932efa test: Update test for indices on pruned nodes (Fabian Jahr)
825d19839b Index: Allow coinstatsindex with pruning enabled (Fabian Jahr)
f08c9fb0c6 Index: Use prune locks for blockfilterindex (Fabian Jahr)
2561823531 blockstorage: Add prune locks to BlockManager (Fabian Jahr)
231fc7b035 refactor: Introduce GetFirstStoredBlock helper function (Fabian Jahr)

Pull request description:

  # Motivation
  The main motivation of this change and only behavior change noticeable by user is to allow running `coinstatsindex` on pruned nodes as has been requested [here for example](https://twitter.com/benthecarman/status/1388170854140452870?s=20).

  # Background
  `coinstatsindex` on pruned nodes can be enabled in a much simpler than it is done here but it comes with downside. The ability to run `blockfilterindex`on pruned nodes was added in #15946 but it also added the `blockfilterindex` as a dependency to `validation` and it introduced two new circular dependencies. Enabling `coinstatsindex` on pruned nodes in a similar way would add it as a dependency as well and introduce another circular dependency.

  Instead, this PR introduces a `m_prune_blockers` map to `BlockManager` as a flexible approach to block pruning. Entities like `blockfilterindex`, for example, can add a key and a height to block pruning over that height. These entities need to update that value to allow more pruning when they are ready.

  # Alternative approach
  Upon completing the first draft of this PR I found #19463 as an alternative that follows the same but follows a very different approach. I am listing the main differences here as I see them:
  - Usage of globals
  - Blocks pruning with a start and a stop height
  - Can persist blockers across restarts
  - Blockers can be set/unset via RPCs

  Personally, I don't think any of these are necessary to be added here but if the general approach or specific features are more appealing to reviewers I am happy to change to a solution based on that PR or port over specific parts of it here.

ACKs for top commit:
  mzumsande:
    Code review ACK 71c3f0356c
  ryanofsky:
    Code review ACK 71c3f0356c. Changes since last review: just tweaking comments and asserts, and rebasing
  w0xlt:
    tACK 71c3f0356c on signet.

Tree-SHA512: de7efda08b44aa31013fbebc47a02cd2de32db170b570f9643e1f013fee0e8e7ca3068952d1acc6e5e74a70910735c5f263437981ad73df841ad945b52d36b71
2022-04-26 19:42:45 +01:00
fanquake
260ede1d99
Merge bitcoin/bitcoin#24644: wallet: add tracepoints and algorithm information to coin selection
ab5af9ca72 test: Add test for coinselection tracepoints (Andrew Chow)
ca02b68e8a doc: document coin selection tracepoints (Andrew Chow)
8e3f39e4fa wallet: Add some tracepoints for coin selection (Andrew Chow)
15b58383d0 wallet: compute waste for SelectionResults of preset inputs (Andrew Chow)
912f1ed181 wallet: track which coin selection algorithm produced a SelectionResult (Andrew Chow)

Pull request description:

  Tracepoints can be useful for coin selection as they would allow us to observe what is being selected, selection parameters, and calculation results. So this PR adds 4 new tracepoints:

  1. After `SelectCoins` returns in order to observe the `SelectionResult`
  2. After the first `CreateTransactionInternal` to observe the created transaction
  3. Prior to the second `CreateTransactionInternal` to notify that the optimistic avoid partial spends selection is occurring
  4. After the second `CreateTransactionInternal` to observe the created transaction and inform which solution is being used.

  This PR also adds an algorithm enum to `SelectionResult` so that the first tracepoint will be able to report which algorithm was used to produce that result.

  The primary use case for these tracepoints is in running coin selection simulations. The script I use to run these simulations use these tracepoints in order to gather data on the algorithm used and the calculated waste.

ACKs for top commit:
  jb55:
    crACK ab5af9ca72
  josibake:
    crACK ab5af9ca72
  0xB10C:
    ACK ab5af9ca72. Code reviewed, ran the `interface_usdt_coinselection.py` test, and tested with the above bpftrace script (updated `%d` -> `%ld` where necessary, ty achow101).

Tree-SHA512: a4bf7a910cdf464622f2f3b5d44c15b891f24852df6e7f8c5b177fe3d8aaa4a1164593a24c3960eb22b16544fa7140e5c745345367b9e291b78395084c0ac8ff
2022-04-26 19:16:27 +01:00
Ryan Ofsky
1d4122dfef init: Allow -proxy="" setting values
This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>`
error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or
`settings.json` value is specified, and just makes bitcoin connect and listen
normally in these cases.

The error was originally added in https://github.com/bitcoin/bitcoin/pull/20003
to prevent a bare `-proxy` command line argument with no assignment from
clearing proxy settings. But it was implemented in an overbroad way breaking
empty `-proxy=` assignments as well.

The motivation for this change is to prevent a GUI bug that happens with
https://github.com/bitcoin/bitcoin/pull/15936, reported in
https://github.com/bitcoin/bitcoin/pull/15936#pullrequestreview-937685759 by
vasild, that happens after a proxy setting is enabled and disabled in the GUI.
But this change also makes sense on its own to remove a potentially confusing
error message.
2022-04-26 10:09:39 -04:00
fanquake
269dcad16e
Merge bitcoin/bitcoin#24789: init, index: disallow indexes when running reindex-chainstate
dac44fc06f init: disallow reindex-chainstate with optional indexes (Martin Zumsande)
62e14285f9 doc: Add note that -reindex will rebuild optional indexes (Martin Zumsande)

Pull request description:

  When started together with `-reindex-chainstate`, currently coinstatsindex gets corrupted and the blockfilterindex flatfiles duplicated. See the OP of #24630 for more a more detailed explanation on why this happens.

  This is an alternative to #24630 which does not wipe and rebuild the indexes but returns an `InitError` when they are activated, thus requiring the user to deactivate them temporarily until the `-reindex-chainstate` run is finished.

  This also disallows `-reindex-chainstate` in combination with `-txindex`, which is not leading to corruption, but currently still rebuilds the index unnecessarily and unexpectedly.

  As a long-term goal, it would be desirable to have the indexes tolerate `reindex-chainstate` by ignoring their `BlockConnected` notifications (there is discussion in #24630 about this) or possibly move `reindex-chainstate` option  into a `bitcoin-chainstate` executable, which could also solve the problem. But these would be larger projects - until then, it might be better to disallow the interaction than having corrupted indexes.

  The first commit adjusts the `-reindex` doc to mention that this option does rebuild all active indexes.

ACKs for top commit:
  ryanofsky:
    Code review ACK dac44fc06f. Just fixed IsArgSet call and edited error messages since last review

Tree-SHA512: c1abf7d350648ae227c3fd6c95d9a54c3bac9de70915275dea1c87cca6d9a76a056c0e306d95ef8cfe4df1f8525b418e0e7a4f52ded3be464041c0dc297f8930
2022-04-26 12:11:39 +01:00
hiago
29f44fed36 Converting lint-all.sh to lint-all.py.
Converting `lint-all.sh` to `lint-all.py`.
2022-04-26 06:25:01 -03:00
MacroFake
fa82a1ed83
lint: Mention NONFATAL_UNREACHABLE in lint-assertions.py 2022-04-26 10:01:54 +02:00
Fabian Jahr
71c3f0356c
move-only: Rename index + pruning functional test 2022-04-25 23:22:00 +02:00
Fabian Jahr
de08932efa
test: Update test for indices on pruned nodes 2022-04-25 23:22:00 +02:00
Fabian Jahr
825d19839b
Index: Allow coinstatsindex with pruning enabled 2022-04-25 23:22:00 +02:00
Fabian Jahr
f08c9fb0c6
Index: Use prune locks for blockfilterindex
Prior to this change blocks could be pruned up to the last block before the blockfilterindex current best block.
2022-04-25 23:22:00 +02:00
laanwj
1e7db37e76
Merge bitcoin/bitcoin#24856: lint: Converting lint-assertions.sh to lint-assertions.py
172c2333f0 Porting lint-assertions.sh to lint-assertions.py (hiago)

Pull request description:

  This PR is converting `test/lint/lint-assertions.sh` to `test/lint/lint-assertions.py`. It's an item of #24783.

ACKs for top commit:
  laanwj:
    Tested ACK 172c2333f0

Tree-SHA512: 94d5b03acfeaf2303fad95d489d6c3aa7bd655889ddaa807cc97e0613b8eb8f5ef094feee2a98d974606890deb554e76490a5c523d64eb5bc55afa6a43221aae
2022-04-25 19:47:17 +02:00
laanwj
16fa967d3c
Merge bitcoin/bitcoin#24915: lint: Convert lint-circular-dependencies.sh to Python
79635c79e0 lint: Convert lint-circular-dependencies.sh to Python (Smlep)

Pull request description:

  Here is a port of `/test/lint/lint-circular-dependencies.sh` to a Python-script as part of the request of https://github.com/bitcoin/bitcoin/issues/24783.

  It aims to provide the same output as the bash version.

ACKs for top commit:
  laanwj:
    Tested ACK 79635c79e0

Tree-SHA512: f18077018f1229dd933cfe2bf0cfe7dc7d6538961c96a83c7a1f05e0cec4b068ca05502d68410d2aa4b6864523424db386e38233735190525904c2a8e9d2ba13
2022-04-25 19:37:19 +02:00
laanwj
9eedbe98c8
Merge bitcoin/bitcoin#24815: lint: convert lint-tests.sh to python
ae0e06a439 Converted lint-tests.sh to python (TakeshiMusgrave)

Pull request description:

  Reference issue: https://github.com/bitcoin/bitcoin/issues/24783

ACKs for top commit:
  laanwj:
    Tested ACK ae0e06a439

Tree-SHA512: a118295b5b6b5199b52d46b54de871d88dd544112e7dd5001a9575d65b093af0aea390f9ad223462a4fc6a201bd8c4debe5e26bfa4860a90c97cfe300477c04a
2022-04-25 19:27:37 +02:00
laanwj
0342ae1d39
Merge bitcoin/bitcoin#24802: lint: convert format strings linter test to python
267684ee34 lint: convert format strings linter test to python (Eunoia)

Pull request description:

  Refs #24783

  Attempted to keep the style and flow of implementation as it is.

  ### Additional Notes(Optional):
  1. There is scope of improvement on how the related files are fetched. In this `git grep` with `subprocess` is still used as I found it to be the simplest. Any pointers on this are appreciated.
  2. Removed sort operation on the matching files as I couldn't think of any strong arguments to have it. Any pointers on this are appreciated.
  3. Not important, but one small detail is that the previous implementation was storing matched files for all the `function_names` iterated so far. Fixed that in this PR.

ACKs for top commit:
  laanwj:
    Code review ACK 267684ee34

Tree-SHA512: 54ceae0c3501e561fdd9c5167b2dd8dd06da1b3697a077a042210970ce7004bda8c4e19abb1905ee64cbdce635f0a078508da645846ae7e81c016091f3f02458
2022-04-25 18:32:40 +02:00
laanwj
777b89b300
Merge bitcoin/bitcoin#24929: lint: convert shell locale linter test to Python
2c838cc309 lint: convert shell locale linter test to Python (Eunoia)

Pull request description:

  Refs #24783

ACKs for top commit:
  laanwj:
    Code review ACK 2c838cc309

Tree-SHA512: 3cb5e7c7cd2acbdf0dc45096055b33cbfa0ec9e47ea567452d23a49a7441b3b62a8416879f234459c86fa892c42205c91d8a575115346c023ab0152cf713e20c
2022-04-25 18:23:02 +02:00
laanwj
8b686776ef
Merge bitcoin/bitcoin#24902: lint: Convert lint-include-guards.sh to Python
d5fdec5cf8 Convert lint-include-guards.sh to python (brydinh)

Pull request description:

  This PR addresses [issue 24783](https://github.com/bitcoin/bitcoin/issues/24783).  Converted lint-include-guards.sh to python.

ACKs for top commit:
  KevinMusgrave:
    Tested ACK d5fdec5cf8
  laanwj:
    Code review ACK d5fdec5cf8

Tree-SHA512: cae566fc1b222b447c0d60ea20fd012f1cfde4dd07c1762ede2b2c9f84ed59ee8e629db1264dab8ac20bcac410e4c389827addf0a59757f94b40a65ea9bab466
2022-04-25 18:14:54 +02:00
laanwj
c90b42bcdb
Merge bitcoin/bitcoin#24916: lint: Convert lint-python-utf8-encoding.sh to Python
035eef4be6 lint: Convert lint-python-utf8-encoding.sh to Python (Dimitri)

Pull request description:

  A port of `test/lint/lint-python-utf8-encoding.sh` to a Python-script as part of the request of #24783. Checked for output-consistency.

ACKs for top commit:
  laanwj:
    Code review ACK 035eef4be6

Tree-SHA512: a8a2f505bf7953d318837182101346c44e73cfd1bf3b5342ff1400fb1c67c5292519fa99db1035da87cf27fb5f5ac5d28871bf55a1c085b5f8a3bb33ff0fa3fb
2022-04-25 17:58:25 +02:00
laanwj
7134327be5
Merge bitcoin/bitcoin#24932: lint: Convert lint-locale-dependence.sh to Python
3043a1bc9d lint: Make known violations more specific in lint-locale-dependence (Dimitri)
229917d3d4 lint: Convert lint-locale-dependence.sh to Python (Dimitri)

Pull request description:

  A port of `test/lint/lint-locale-dependence.sh` to a Python-script as part of the request of #24783. Checked for output-consistency.

ACKs for top commit:
  laanwj:
    Tested and code review ACK 3043a1bc9d

Tree-SHA512: 80555cf7aac156bab5488f85098731d1c12a42667fe7d0df0c35487ab8fc951654a70a15351a759282eabab8319f5aabd8bdb153412b9edc3a9033bef64fd609
2022-04-25 17:53:53 +02:00
fanquake
aa54132bac
Merge bitcoin/bitcoin#24454: tests: Fix calculation of external input weights
9f5ab670e7 tests: Use descriptor that requires both legacy and segwit (Andrew Chow)
8a04a386f7 tests: Calculate input weight more accurately (Andrew Chow)

Pull request description:

  The external input tests with specifying input weight would sometimes result in a test failure because it would add 2 to the calculated byte size in order to account for some of the variation in signature and script sizes. However 1 in 128 signatures are actually 1 byte smaller than we expect, so the difference between the actual signature size and our calculated size becomes 3 bytes which is outside of the tolerance of `assert_fee_amount` and would thus cause the test failure.

  To resolve this, the 2 byte buffer is reduced to 1 byte, so in the above scenario, the difference is 2 bytes which is within the tolerance of `assert_fee_amount`. Additionally, instead of putting a fixed size that we assume is the correct size for the length of the compact size length prefix of data, we actually get the length of the compact size uint.

  Lastly, the size calculation for a scriptWitness was simply incorrect and used fields that did not exist. This is fixed, and the test slightly modified so that it also produces a scriptWitness.

  Fixes #24151

ACKs for top commit:
  jonatack:
    re-ACK 9f5ab670e7
  glozow:
    code review ACK 9f5ab670e7

Tree-SHA512: b7c7ffe8fb0c07bc9e72fbff1f9ef57ee01a57c56bf54b8873345c8b9572c3ce9402b24dc211910b478114a9e6420faef5a4bf8866f38c299971354e54ec4745
2022-04-25 09:54:40 +01:00
Martin Zumsande
dac44fc06f init: disallow reindex-chainstate with optional indexes
It currently leads to corruption (coinstatsindex) or
data duplication (blockfilterindex), so disable it.
2022-04-24 22:28:25 +02:00
MarcoFalke
b1c5991eeb
Merge bitcoin/bitcoin#24812: util/check: Add CHECK_NONFATAL identity function and NONFATAL_UNREACHABLE macro
ee02c8bd9a util/check: Add CHECK_NONFATAL identity function, NONFATAL_UNREACHABLE AND UNREACHABLE macros (Aurèle Oulès)

Pull request description:

  This PR replaces the macro `CHECK_NONFATAL` with an identity function.
  I simplified the usage of `CHECK_NONFATAL` where applicable in `src/rpc`.
  This function is useful in sanity checks for RPC and command-line interfaces.

  Context: https://github.com/bitcoin/bitcoin/pull/24804#discussion_r846182474.

  Also adds `UNREACHABLE_NONFATAL` macro.

ACKs for top commit:
  jonatack:
    ACK ee02c8bd9a
  MarcoFalke:
    ACK ee02c8bd9a 🍨

Tree-SHA512: 3cba09223cd7b22e62fe5d0b46c4a024c1d9957d4268ba6d3fb07fcc0a5854fc0886bb3266184e6a7df5df91373b3e84edd6adf6999c4e934aeef8c043b01aa2
2022-04-24 12:00:05 +02:00
Sebastian Falbesoner
a498acce45 test: MiniWallet: skip mempool check if mempool_valid=False
MiniWallet's core method for creating txs (`create_self_transfer`)
right now always executes the `testmempoolaccept` RPC to check for
mempool validity or invalidity. In some test cases where we use
MiniWallet to create a huge number of transactions this can lead
to performance issues (e.g. feature_fee_estimation.py where the
execution time after MiniWallet usage almost doubled). Providing
the possibility to skip the mempool checks is a mitigation for
this.

master branch:
$ time ./test/functional/feature_fee_estimation.py
real    3m20.771s
user    2m52.360s
sys     0m39.340s

PR branch:
$ time ./test/functional/feature_fee_estimation.py
real    2m1.386s
user    1m42.510s
sys     0m22.980s
2022-04-22 15:07:10 +02:00
Sebastian Falbesoner
01552e8f67 test: MiniWallet: always rehash after signing (P2PK mode)
Also explicitly rehash in the cases where we modify a tx after signing
in feature_csv_activation.py. Parts of this test relied on the fact that
rehashing of transactions is done in the course of calculating a block's
merkle root (`calc_merkle_root`), which only works if no hash was
calculated before due to a caching mechanism.

In the following commit the txid in MiniWallet is calculated via
`rehash()`, i.e. this doesn't work anymore and we always have to
explicitely have the right hash before we calculate the merkle root.
2022-04-22 15:06:44 +02:00