Commit graph

22484 commits

Author SHA1 Message Date
MacroFake
66664384a6
Remove ::g_max_datacarrier_bytes global 2022-08-02 15:29:16 +02:00
MacroFake
fad0b4fab8
Pass datacarrier setting into IsStandard 2022-08-02 15:28:30 +02:00
MacroFake
fa2a6b8516
Combine datacarrier globals into one 2022-08-02 15:28:10 +02:00
MacroFake
fa477d32ee
Remove ::GetVirtualTransactionSize() alias
Each alias is only used in one place.
2022-08-02 15:27:20 +02:00
MacroFake
fa2f6c1a61
Remove ::fIsBareMultisigStd global 2022-08-02 15:27:19 +02:00
MacroFake
fadc14e4f5
Remove ::dustRelayFee 2022-08-02 15:26:49 +02:00
MacroFake
fa8a7f01fe
Remove ::IsStandardTx(tx, reason) alias
Apart from tests, it is only used in one place, so there is no need for
an alias.
2022-08-02 15:26:24 +02:00
MacroFake
fa7a9114e5
test: Remove unused cs_main 2022-08-02 15:25:10 +02:00
MacroFake
fa9cba7afb
Remove ::incrementalRelayFee and ::minRelayTxFee globals 2022-08-02 15:23:36 +02:00
MacroFake
fa148602e6
Remove ::fRequireStandard global 2022-08-02 15:23:24 +02:00
MacroFake
fa468bdfb6
Return optional error from ApplyArgsManOptions
Also pass in a (for now unused) reference to the params.

Both changes are needed for the next commit.
2022-08-02 15:21:50 +02:00
MacroFake
816ca01650
Merge bitcoin/bitcoin#25736: univalue: Remove unused and confusing set*() return value
fa7bef2e80 univalue: Remove unused and confusing set*() return value (MacroFake)

Pull request description:

  The value is:

  * currently unused, and useless without `[[nodiscard]]`
  * confusing, because it is always `true`, unless a num-string is set

  Instead of adding `[[nodiscard]]`, throw when setting is not possible.

ACKs for top commit:
  shaavan:
    ACK fa7bef2e80
  aureleoules:
    ACK fa7bef2e80.

Tree-SHA512: 0d74f96f34cb93b66019ab75e12334c964630cc83434f22e58cc7a4fff2ee96a5767e42ab37f08acb67aeacba6811b09c75f1edc68d5e903ccfc59b1c82de891
2022-08-02 12:30:49 +02:00
MacroFake
da23320998
Merge bitcoin/bitcoin#25651: refactor: make all NodeImpl/ChainImpl/ExternalSignerImpl members public, rm temporaries, simplify
4bedfd702a refactor: remove unneeded temporaries in node/interfaces, simplify code (Jon Atack)
b27ba169eb refactor: make all NodeImpl/ChainImpl/ExternalSignerImpl members public (Jon Atack)

Pull request description:

  - Make all `NodeImpl`, `ChainImpl` and `ExternalSignerImpl` class members `public` (and document why), to be consistent in all the `*Impl` classes in `src/node/interfaces.cpp` and `src/wallet/interfaces.cpp` and to help future reviewers and contributors.

  - Remove unneeded temporaries in `NodeImpl` and `ChainImpl` methods in `src/node/interfaces.cpp` and simplify, to make the code easier to read and understand and to improve performance by avoiding unnecessary move operations.

ACKs for top commit:
  ryanofsky:
    Code review ACK 4bedfd702a. Changes since last review, applying suggested style & simplifiying first commit. Also avoiding another lock in second commit.

Tree-SHA512: 112f7cad5e2838c94c5b79d61328f42fe75fdb97f401ab49eccf696fc2c6a8a0c0ee55ec974c0602acf7423f78bb82e90eb8a0cc531e1d3347f73b7c83685504
2022-08-01 11:19:55 +02:00
MacroFake
f5eadcb148
Merge bitcoin/bitcoin#25663: tracing: do not use coin after move in CCoinsViewCache::AddCoin
f8e228476f tracing: do not use `coin` after move in `CCoinsViewCache::AddCoin` (Seibart Nedor)

Pull request description:

  This is fix for https://github.com/bitcoin/bitcoin/issues/25640.

ACKs for top commit:
  0xB10C:
    ACK f8e228476f

Tree-SHA512: e7643ac8e6b6247aaf250f44572c4b458da4aea030ac0268227564e6857200e9c23efe325cfc535f46498cbeccaf46301551efeeb54b062f71d2dcf1ffe71fb8
2022-08-01 11:05:02 +02:00
MacroFake
c5ba1d92b6
Merge bitcoin/bitcoin#25610: wallet, rpc: Opt in to RBF by default
ab3c06db1a doc: Release notes for default RBF (Andrew Chow)
61d9149e78 rpc: Default rbf enabled (Andrew Chow)
e3c33637ba wallet: Enable -walletrbf by default (Andrew Chow)

Pull request description:

  The GUI currently opts in to RBF by default, but RPCs do not, and `-walletrbf` is default disabled. This PR makes the default in those two places to also opt in.

  The last time this was proposed (#9527), the primary objections were the novelty at the time, the inability to bump transactions, and the gui not having the option to disable rbf. In the 5 years since, RBF usage has steadily grown, with ~27% of txs opting in. The GUI has the option to enable/disable RBF, and is also defaulted to having it enabled. And we have the ability to bump RBF'd transactions in both the RPC and the GUI. So I think it makes sense to finally change the default to always opt in to RBF.

ACKs for top commit:
  darosior:
    reACK ab3c06db1a
  aureleoules:
    ACK ab3c06db1a.
  glozow:
    utACK ab3c06db1a

Tree-SHA512: 81b012c5033e270f86a87a6a196ccc549eb54b158eebf88e917cc6621d40d7bdcd1566b602688907dd5d364b95a557b29f97dce869cea512e339588262c027b6
2022-08-01 10:53:11 +02:00
fanquake
28be13ec99
Merge bitcoin/bitcoin#25739: Update leveldb subtree
f608f25313 Squashed 'src/leveldb/' changes from 330dd6235f..22f1e4a02f (fanquake)

Pull request description:

  Replaces #25463 (for master).

  Includes:
  - https://github.com/bitcoin-core/leveldb-subtree/pull/32

  Guix Build (arm64):
  ```bash
  ed41ae2555ae3b638b65d870cef385805e621481831ae992e84645f5c234af63  guix-build-bec911e37ac8/output/arm-linux-gnueabihf/SHA256SUMS.part
  7d8237026bfccedee0e56e14d7b89cf2dcb52195b94070dc4b6c3c6970fdc774  guix-build-bec911e37ac8/output/arm-linux-gnueabihf/bitcoin-bec911e37ac8-arm-linux-gnueabihf-debug.tar.gz
  1afeff9d70864be66f7ac48d31d1977c7844e2cc117d3f0438fb2f9c6f6a56a4  guix-build-bec911e37ac8/output/arm-linux-gnueabihf/bitcoin-bec911e37ac8-arm-linux-gnueabihf.tar.gz
  ab2df265897a0142093b582d3c61e2b17a713d93e478b47c7aa2b0a677295007  guix-build-bec911e37ac8/output/arm64-apple-darwin/SHA256SUMS.part
  025a52babdee479800801e951f6fe1fe490e1f5fe8361104eb85e7b0319cdb37  guix-build-bec911e37ac8/output/arm64-apple-darwin/bitcoin-bec911e37ac8-arm64-apple-darwin-unsigned.dmg
  7b2992bf5543891b1e6ef4f48c52fc5febc58cc31ccf4307edd27d4d630aa54a  guix-build-bec911e37ac8/output/arm64-apple-darwin/bitcoin-bec911e37ac8-arm64-apple-darwin-unsigned.tar.gz
  3d93eb009ab6459cdca5fe767795f94ba5e00e5969e44bac19c7a5f344d42030  guix-build-bec911e37ac8/output/arm64-apple-darwin/bitcoin-bec911e37ac8-arm64-apple-darwin.tar.gz
  b8c30c5c561c96bc4e280ececc0dd1cd673bc6194591b848903aa6c54c9d37cf  guix-build-bec911e37ac8/output/dist-archive/bitcoin-bec911e37ac8.tar.gz
  cb2632b9b5ff473e504d3d6244191eb5a852718f8ac8bb1032ba1c65e07d6b3f  guix-build-bec911e37ac8/output/powerpc64-linux-gnu/SHA256SUMS.part
  26ecc2f42ce37f8bd7ba24bf2f80f493cd1fd45b58409de71c44e2445c291c8c  guix-build-bec911e37ac8/output/powerpc64-linux-gnu/bitcoin-bec911e37ac8-powerpc64-linux-gnu-debug.tar.gz
  4a83381ea472cc71b4a1c6569483a7e85a5f53065c1633828bf7a75d357b0297  guix-build-bec911e37ac8/output/powerpc64-linux-gnu/bitcoin-bec911e37ac8-powerpc64-linux-gnu.tar.gz
  455a9af5e7ee1c2857d87abec29284ae7bb447cf7cb2b3befa2f8e0a0a8cbec6  guix-build-bec911e37ac8/output/powerpc64le-linux-gnu/SHA256SUMS.part
  3445f53fd150032ec3c3f324e001b4ecf72728900961a7a7789c32ceb7616617  guix-build-bec911e37ac8/output/powerpc64le-linux-gnu/bitcoin-bec911e37ac8-powerpc64le-linux-gnu-debug.tar.gz
  baefeaac88bb4fbf8662c8e1150b043aa2534535a82e828c13e971d2c5fa5cbd  guix-build-bec911e37ac8/output/powerpc64le-linux-gnu/bitcoin-bec911e37ac8-powerpc64le-linux-gnu.tar.gz
  543484396a47def1636d4e54d4a105c7093265c8896165a4140edec10aeef880  guix-build-bec911e37ac8/output/riscv64-linux-gnu/SHA256SUMS.part
  ac1f6e57016703f1319a3ef80014581aee96053e56525b8cd11ada2395496b86  guix-build-bec911e37ac8/output/riscv64-linux-gnu/bitcoin-bec911e37ac8-riscv64-linux-gnu-debug.tar.gz
  f9a2b65ed21f777524b078046c84b98239b0fbb92eae8d840bc7a25cab0eec6d  guix-build-bec911e37ac8/output/riscv64-linux-gnu/bitcoin-bec911e37ac8-riscv64-linux-gnu.tar.gz
  a08ed0ee78ab1c4c815ba8368f1a21d3bd4327ce1104cb3793d63edd2bde1ef4  guix-build-bec911e37ac8/output/x86_64-apple-darwin/SHA256SUMS.part
  74059397c6c8f0e899b60415d1aae04f2f7df18b8f39cea9f314e5e0c2e0ede6  guix-build-bec911e37ac8/output/x86_64-apple-darwin/bitcoin-bec911e37ac8-x86_64-apple-darwin-unsigned.dmg
  6909ff6f59b78059d505f2b98e6fad63a4e3deb843566061c4cd6e94be1de066  guix-build-bec911e37ac8/output/x86_64-apple-darwin/bitcoin-bec911e37ac8-x86_64-apple-darwin-unsigned.tar.gz
  21b45719d927422acc69662108e7255d8cd0b1d832493e70c622c1b1b3a3a314  guix-build-bec911e37ac8/output/x86_64-apple-darwin/bitcoin-bec911e37ac8-x86_64-apple-darwin.tar.gz
  b5fdee6fd2dbcdaa6302f388c7fcaa6d130ff91fd5760e19facf6e24c7216ef6  guix-build-bec911e37ac8/output/x86_64-linux-gnu/SHA256SUMS.part
  56db24b0b0d2f463c8085a12502977c6d4f4ee5b85484e52522361f54ab3a6aa  guix-build-bec911e37ac8/output/x86_64-linux-gnu/bitcoin-bec911e37ac8-x86_64-linux-gnu-debug.tar.gz
  96dbe08e2ed0f68fe734dd6f0280c2d22af7b56c84debde424367054f118173f  guix-build-bec911e37ac8/output/x86_64-linux-gnu/bitcoin-bec911e37ac8-x86_64-linux-gnu.tar.gz
  70ac424b229befb2834a8a02ce27551e3ddde2d438497e8c11a3cedf0cea5d3c  guix-build-bec911e37ac8/output/x86_64-w64-mingw32/SHA256SUMS.part
  bad144a599b28e8dc0018cc2fd1754543e79df39d651e58f565c197241f2b8cb  guix-build-bec911e37ac8/output/x86_64-w64-mingw32/bitcoin-bec911e37ac8-win64-debug.zip
  7ce2e72621eb070a8d23b7edbaaccc9f06257b82b9851c1cad4c61f08d2c7451  guix-build-bec911e37ac8/output/x86_64-w64-mingw32/bitcoin-bec911e37ac8-win64-setup-unsigned.exe
  5f726ef8b478e3ac90b93cd3ae3c38a0e7bffa5f80306c46a7535518a73251c7  guix-build-bec911e37ac8/output/x86_64-w64-mingw32/bitcoin-bec911e37ac8-win64-unsigned.tar.gz
  87cf1a23e948e471ed35c6a518813505c907c58788b55665829e7f12f33bd312  guix-build-bec911e37ac8/output/x86_64-w64-mingw32/bitcoin-bec911e37ac8-win64.zip
  ```

ACKs for top commit:
  hebasto:
    ACK bec911e37a, I have reviewed the code and it looks OK, I agree it can be merged.
  jarolrod:
    ACK bec911e37a

Tree-SHA512: 190381d9489ec6cc52bb9557750925c8574f1344eb6893095e9e31e66a579bd1bc283e8cbfcba52cec3fb072985895f929103b6f5351a23f908bdd0a04b474f1
2022-08-01 09:40:04 +01:00
MacroFake
5215c80edc
Merge bitcoin/bitcoin#25709: script: actually trigger the optimization in BuildScript
00897d0677 script: actually trigger the optimization in BuildScript (Antoine Poinsot)

Pull request description:

  The counter is an optimization over calling `ret.empty()`. It was
  suggested that the compiler would realize `cnt` is only `0` on the first
  iteration, and not actually emit the check and conditional.

  This optimization was actually not triggered at all, since we
  incremented `cnt` at the beginning of the first iteration. Fix it by
  incrementing at the end instead.

  This was reported by Github user "Janus".

  Fixes #25682. Note this does *not* change semantics. It only allows the optimization of moving instead of copying on first `CScript` element to actually be reachable.

ACKs for top commit:
  sipa:
    utACK 00897d0677
  MarcoFalke:
    review ACK 00897d0677

Tree-SHA512: b575bd444b0cd2fe754ec5f3e2f3f53d2696d5dcebedcace1e38be372c82365e75938dfe185429ed5a83efe1a395e204bfb33efe56c10defc5811eaee50580e3
2022-07-30 17:49:02 +02:00
Jon Atack
4bedfd702a refactor: remove unneeded temporaries in node/interfaces, simplify code
- make the code easier to read and understand

- improve performance by avoiding unnecessary move operations

- the cleaner, simpler, and easier to read the code is, the
  better chance the compiler has at implementing it well
2022-07-29 19:41:23 +02:00
Jon Atack
b27ba169eb refactor: make all NodeImpl/ChainImpl/ExternalSignerImpl members public
as the classes themselves are private, and to be consistent within all the
*Impl classes in src/node/interfaces.cpp and src/wallet/interfaces.cpp
following this order:

public:
  // ... virtual methods ...
  // ... nonvirtual helper methods ...
  // ... data members ...

and add documentation in src/node/interfaces.cpp and src/wallet/interfaces.cpp
to help future reviewers and contributors.
2022-07-29 19:27:16 +02:00
fanquake
5871b5b5ab
Merge bitcoin/bitcoin#25571: refactor: Make mapBlocksUnknownParent local, and rename it
dd065dae9f refactor: Make mapBlocksUnknownParent local, and rename it (Hennadii Stepanov)

Pull request description:

  This PR is a second attempt at #19594. This PR has two motivations:

  - Improve code hygiene by eliminating a global variable, `mapBlocksUnknownParent`
  - Fix fuzz test OOM when running too long ([see #19594 comment](https://github.com/bitcoin/bitcoin/pull/19594#issuecomment-958801638))

  A minor added advantage is to release `mapBlocksUnknownParent` memory when the reindexing phase is done. The current situation is somewhat similar to a memory leak because this map exists unused for the remaining lifetime of the process. It's true that this map should be empty of data elements after use, but its internal metadata (indexing structures, etc.) can have non-trivial size because there can be many thousands of simultaneous elements in this map.

  This PR helps our efforts to reduce the use of global variables. This variable isn't just global, it's hidden inside a function (it looks like a local variable but has the `static` attribute).

  This global variable exists because the `-reindex` processing code calls `LoadExternalBlockFile()` multiple times (once for each block file), but that function must preserve some state between calls (the `mapBlocksUnknownParent` map). This PR fixes this by allocating this map as a local variable in the caller's scope and passing it in on each call. When reindexing completes, the map goes out of scope and is deallocated.

  I tested this manually by reindexing on mainnet and signet. Also, the existing `feature_reindex.py` functional test passes.

ACKs for top commit:
  mzumsande:
    re-ACK dd065dae9f
  theStack:
    re-ACK dd065dae9f
  shaavan:
    reACK dd065dae9f

Tree-SHA512: 9cd20e44d2fa1096dd405bc107bc065ea8f904f5b3f63080341b08d8cf57b790df565f58815c2f331377d044d5306708b4bf6bdfc5ef8d0ed85d8e97d744732c
2022-07-29 15:47:23 +01:00
MacroFake
b1c8ea45c9
Merge bitcoin/bitcoin#25683: refactor: log nEvicted message in LimitOrphans then return void
b4b657ba57 refactor: log `nEvicted` message in `LimitOrphans` then return void (chinggg)

Pull request description:

  Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=49347

  LimitOrphans() can log expired tx and it should log evicted tx as well instead of returning the `nEvicted` number for caller to print the message.
  Since `LimitOrphans()` now returns void, the redundant assertion check in fuzz test is also removed.

Top commit has no ACKs.

Tree-SHA512: 18c41702321b0e59812590cd389f3163831d431f4ebdc3b3e1e0698496a6bdbac52288f28f779237a58813c6717da1a35e8933d509822978ff726c1b13cfc778
2022-07-29 16:17:16 +02:00
fanquake
bec911e37a
Update leveldb-subtree subtree to latest upstream 2022-07-29 14:43:11 +01:00
MacroFake
fa7bef2e80
univalue: Remove unused and confusing set*() return value 2022-07-29 15:24:42 +02:00
Andrew Chow
1abbae65eb
Merge bitcoin/bitcoin#24584: wallet: avoid mixing different OutputTypes during coin selection
71d1d13627 test: add unit test for AvailableCoins (josibake)
da03cb41a4 test: functional test for new coin selection logic (josibake)
438e04845b wallet: run coin selection by `OutputType` (josibake)
77b0707206 refactor: use CoinsResult struct in SelectCoins (josibake)
2e67291ca3 refactor: store by OutputType in CoinsResult (josibake)

Pull request description:

  # Concept

  Following https://github.com/bitcoin/bitcoin/pull/23789, Bitcoin Core wallet will now generate a change address that matches the payment address type. This improves privacy by not revealing which of the outputs is the change at the time of the transaction in scenarios where the input address types differ from the payment address type. However, information about the change can be leaked in a later transaction. This proposal attempts to address that concern.

  ## Leaking information in a later transaction

  Consider the following scenario:

  ![mix input types(1)](https://user-images.githubusercontent.com/7444140/158597086-788339b0-c698-4b60-bd45-9ede4cd3a483.png)

  1. Alice has a wallet with bech32 type UTXOs and pays Bob, who gives her a P2SH address
  2. Alice's wallet generates a P2SH change output, preserving her privacy in `txid: a`
  3. Alice then pays Carol, who gives her a bech32 address
  4. Alice's wallet combines the P2SH UTXO with a bech32 UTXO and `txid: b` has two bech32 outputs

  From a chain analysis perspective, it is reasonable to infer that the P2SH input in `txid: b` was the change from `txid: a`. To avoid leaking information in this scenario, Alice's wallet should avoid picking the P2SH output and instead fund the transaction with only bech32 Outputs. If the payment to Carol can be funded with just the P2SH output, it should be preferred over the bech32 outputs as this will convert the P2SH UTXO to bech32 UTXOs via the payment and change outputs of the new transaction.

  **TLDR;** Avoid mixing output types, spend non-default `OutputTypes` when it is economical to do so.

  # Approach

  `AvailableCoins` now populates a struct, which makes it easier to access coins by `OutputType`. Coin selection tries to find a funding solution by each output type and chooses the most economical by waste metric. If a solution can't be found without mixing, coin selection runs over the entire wallet, allowing mixing, which is the same as the current behavior.

  I've also added a functional test (`test/functional/wallet_avoid_mixing_output_types.py`) and unit test (`src/wallet/test/availablecoins_tests.cpp`.

ACKs for top commit:
  achow101:
    re-ACK 71d1d13627
  aureleoules:
    ACK 71d1d13627.
  Xekyo:
    reACK 71d1d13627 via `git range-diff master 6530d19 71d1d13`
  LarryRuane:
    ACK 71d1d13627

Tree-SHA512: 2e0716efdae5adf5479446fabc731ae81d595131d3b8bade98b64ba323d0e0c6d964a67f8c14c89c428998bda47993fa924f3cfca1529e2bd49eaa4e31b7e426
2022-07-28 18:16:51 -04:00
glozow
41205bf442
Merge bitcoin/bitcoin#25674: add unit tests for RBF rules in isolation
c320cddb1b [unit tests] individual RBF Rules in isolation (glozow)

Pull request description:

  Test each RBF rule more thoroughly and in isolation so we're not relying on things like overall mempool acceptance logic, ordering of mempool checks, RPC results, etc.

  RBF was pretty recently refactored out, so there isn't much unit test coverage. From https://marcofalke.github.io/btc_cov/test_bitcoin.coverage/src/policy/rbf.cpp.gcov.html:
  ![image](https://user-images.githubusercontent.com/25183001/180783280-6777f4b4-ef95-462a-b414-1a9e268836a6.png)

ACKs for top commit:
  instagibbs:
    reACK c320cddb1b
  jonatack:
    ACK c320cddb1b
  w0xlt:
    ACK c320cddb1b

Tree-SHA512: dab555214496255801b9ea92b7bf708bba1ff23edf055c85e29be5eab7d7a863440ee19588aacdce54b2c03feaa4b5963eb159ed89473560bd228737cbfec160
2022-07-28 17:15:15 +01:00
glozow
c320cddb1b
[unit tests] individual RBF Rules in isolation
Test each component of the RBF policy in isolation. Unlike the RBF
functional tests, these do not rely on things like RPC results, mempool
submission, etc.
2022-07-28 12:05:05 +01:00
chinggg
b4b657ba57 refactor: log nEvicted message in LimitOrphans then return void
`LimitOrphans()` can log expired tx and it should log evicted tx as well
instead of returning the number for caller to print the message.
Since `LimitOrphans()` now return void, the redundant assertion check in
fuzz test is also removed.
2022-07-28 14:39:45 +08:00
Hennadii Stepanov
ba9a8e6cc1
test: Drop unused boost workaround 2022-07-27 20:38:05 +01:00
fanquake
9ba73758c9
Merge bitcoin/bitcoin#24697: refactor address relay time
fa64dd6673 refactor: Use type-safe std::chrono for addrman time (MarcoFalke)
fa2ae373f3 Add type-safe AdjustedTime() getter to timedata (MarcoFalke)
fa5103a9f5 Add ChronoFormatter to serialize (MarcoFalke)
fa253d385f util: Add HoursDouble (MarcoFalke)
fa21fc60c2 scripted-diff: Rename addrman time symbols (MarcoFalke)
fa9284c3e9 refactor: Remove not needed std::max (MacroFake)

Pull request description:

  Those refactors are overlapping with, but otherwise largely unrelated to #24662.

ACKs for top commit:
  naumenkogs:
    utACK fa64dd6673
  dergoegge:
    Code review ACK fa64dd6673

Tree-SHA512: a50625e78036e7220a11997e6d9b6c6b317cb38ce02b1835fb41cbee2d8bfb1faf29b29d8990be78d6b5e15e9a9d8dec33bf25fa439b47610ef708950969724b
2022-07-27 10:30:32 +01:00
MacroFake
7f79746bf0
Merge bitcoin/bitcoin#25705: tidy: enable readability-redundant-string-init
49168df073 tidy: enable readability-redundant-string-init (fanquake)
4ddd746bf9 refactor: remove unnecessary string initializations (fanquake)

Pull request description:

  Remove unnecessary `std::string` = "" initializations. Enable `readability-redundant-string-init`.

  See:
  https://releases.llvm.org/14.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/readability-redundant-string-init.html

ACKs for top commit:
  shaavan:
    ACK 49168df073

Tree-SHA512: 69e72a434908c9166d407551657b310361ae2ef0170f8289cb1c2b8e96a4632be718c0d55cb12af03a3c3d621d9583eced88e5e9d924abb0a8b1a9b36c903d66
2022-07-26 17:47:55 +02:00
fanquake
5671217477
Merge bitcoin/bitcoin#24974: refactor: Make FEELER_SLEEP_WINDOW type safe (std::chrono)
fa74e726c4 refactor: Make FEELER_SLEEP_WINDOW type safe (std::chrono) (MacroFake)
fa3b3cb9b5 Expose underlying clock in CThreadInterrupt (MacroFake)

Pull request description:

  This gets rid of the `value*1000` manual conversion.

ACKs for top commit:
  naumenkogs:
    utACK fa74e726c4
  dergoegge:
    Code review ACK fa74e726c4

Tree-SHA512: 90409c05c25f0dd2f1c4dead78f707ebfd78b7d84ea4db9fcefd9c4958a1a3338ac657cd9e99eb8b47d52d4485fa3c947dce4ee1559fb56ae65878685e1ed9a3
2022-07-26 15:09:21 +01:00
MacroFake
c90f86e4c7
Merge bitcoin/bitcoin#25694: refactor: Make CTransaction constructor explicit
fa2247a9f9 refactor: Make CTransaction constructor explicit (MacroFake)

Pull request description:

  It involves calculating two hashes, so the performance impact should be
  made explicit.

  Also, add the module to iwyu.

ACKs for top commit:
  aureleoules:
    ACK fa2247a9f9.
  hebasto:
    ACK fa2247a9f9, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: e236c352a472c7edfd4f0319a5a16a59f627b0ab7eb8531b53c75d730a3fa3e990a939978dcd952cd73e647925fc79bfa6d9fd87624bbc3ef180f40f95acef19
2022-07-26 13:15:00 +02:00
Antoine Poinsot
00897d0677
script: actually trigger the optimization in BuildScript
The counter is an optimization over calling `ret.empty()`. It was
suggested that the compiler would realize `cnt` is only `0` on the first
iteration, and not actually emit the check and conditional.

This optimization was actually not triggered at all, since we
incremented `cnt` at the beginning of the first iteration. Fix it by
incrementing at the end instead.

This was reported by Github user "Janus".
2022-07-26 13:02:48 +02:00
glozow
31c1b14754
Merge bitcoin/bitcoin#25689: fuzz: Remove no-op SetMempoolConstraints
fa57c449cf fuzz: Remove no-op SetMempoolConstraints (MacroFake)

Pull request description:

  Now that the mempool no longer uses the args manager (after commit e4e201dfd9), there is no point setting the mempool limits after it is constructed.

  Fix that by setting them once right before the mempool is constructed.

ACKs for top commit:
  dongcarl:
    utACK fa57c449cf
  glozow:
    utACK fa57c449cf

Tree-SHA512: d236f9cdcee8c2076272b82c97f8a5942f1ecf119ab36edafd42088ef97554592348a61e1fbe504fd52b30301ef0177813042599ad12e8cb95b4a20586c85bb0
2022-07-26 10:54:14 +01:00
fanquake
49168df073
tidy: enable readability-redundant-string-init
See:
https://releases.llvm.org/14.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/readability-redundant-string-init.html
2022-07-26 10:16:42 +01:00
fanquake
4ddd746bf9
refactor: remove unnecessary string initializations 2022-07-26 10:16:42 +01:00
fanquake
a65f6d8cbb
Merge bitcoin/bitcoin#25699: scripted-diff: Replace NullUniValue with UniValue::VNULL
fa28d0f3c3 scripted-diff: Replace NullUniValue with UniValue::VNULL (MacroFake)
fa962103e8 fuzz: refactor: Replace NullUniValue with UniValue{} (MacroFake)

Pull request description:

  This refactor is needed to disable the (potentially expensive for large json) UniValue copy constructors.

ACKs for top commit:
  fanquake:
    ACK fa28d0f3c3

Tree-SHA512: 7d4204cce0a6fc4ecda96973de77d15b7e4c7caa3e0e890e1f5b9a4b9ace8b240b1f7565d6ab586e168a5fa1201b6c60a924868ef34d6abfbfd8ab7f0f99fbc7
2022-07-26 10:08:15 +01:00
MarcoFalke
fa64dd6673
refactor: Use type-safe std::chrono for addrman time 2022-07-26 11:06:10 +02:00
MarcoFalke
fa2ae373f3
Add type-safe AdjustedTime() getter to timedata
Also, fix includes.

The getter will be used in a future commit.
2022-07-26 11:05:54 +02:00
MarcoFalke
fa5103a9f5
Add ChronoFormatter to serialize 2022-07-26 11:05:04 +02:00
MarcoFalke
fa253d385f
util: Add HoursDouble 2022-07-26 11:04:14 +02:00
MarcoFalke
fa21fc60c2
scripted-diff: Rename addrman time symbols
-BEGIN VERIFY SCRIPT-
 ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); }

 ren nLastTry          m_last_try
 ren nLastSuccess      m_last_success
 ren nLastGood         m_last_good
 ren nLastCountAttempt m_last_count_attempt
 ren nSinceLastTry     since_last_try
 ren nTimePenalty      time_penalty
 ren nUpdateInterval   update_interval
 ren fCurrentlyOnline  currently_online
-END VERIFY SCRIPT-
2022-07-26 11:04:08 +02:00
MacroFake
fa9284c3e9
refactor: Remove not needed std::max 2022-07-26 11:03:31 +02:00
Greg Weber
850b0850cc fix comment spellings from the codespell lint
test/lint/all-lint.py includes the codespell lint
2022-07-25 16:13:26 -05:00
Aurèle Oulès
4fa79837ad
psbt: Fix unsigned integer overflow 2022-07-25 18:45:57 +02:00
MacroFake
fa28d0f3c3
scripted-diff: Replace NullUniValue with UniValue::VNULL
This is required for removing the UniValue copy constructor.

-BEGIN VERIFY SCRIPT-
 sed -i 's/return NullUniValue/return UniValue::VNULL/g' $(git grep -l NullUniValue ':(exclude)src/univalue')
-END VERIFY SCRIPT-
2022-07-25 17:27:53 +02:00
MacroFake
fa962103e8
fuzz: refactor: Replace NullUniValue with UniValue{}
This is needed for the scripted-diff to compile in the next commit
2022-07-25 17:20:56 +02:00
MacroFake
5057adf22f
Merge bitcoin/bitcoin#25349: CBlockIndex/CDiskBlockIndex improvements for safety, consistent behavior
3a61fc56a0 refactor: move CBlockIndex#ToString() from header to implementation (Jon Atack)
57865eb512 CDiskBlockIndex: rename GetBlockHash() to ConstructBlockHash() (Jon Atack)
99e8ec8721 CDiskBlockIndex: remove unused ToString() class member (Jon Atack)
14aeece462 CBlockIndex: ensure phashBlock is not nullptr before dereferencing (Jon Atack)

Pull request description:

  Fix a few design issues, potential footguns and inconsistent behavior in the CBlockIndex and CDiskBlockIndex classes.

  - Ensure phashBlock in `CBlockIndex#GetBlockHash()` is not nullptr before dereferencing and remove a now-redundant assert preceding a GetBlockHash() caller.  This protects against UB here, and in case of failure (which would indicate a consensus bug), the debug log will print `bitcoind: chain.h:265: uint256 CBlockIndex::GetBlockHash() const: Assertion 'phashBlock != nullptr' failed. Aborted` instead of `Segmentation fault`.
  - Remove the unused `CDiskBlockIndex#ToString()` class member, and mark the inherited `CBlockIndex#ToString()` public interface member as deleted to disallow calling it in the derived CDiskBlockIndex class.
  - Rename the `CDiskBlockIndex GetBlockHash()` class member to `ConstructBlockHash()`, which also makes sense as they perform different operations to return a blockhash, and mark the inherited `CBlockIndex#GetBlockHash()` public interface member as deleted to disallow calling it in the derived CDiskBlockIndex class.
  - Move `CBlockIndex#ToString()` from header to implementation, which also allows dropping `tinyformat.h` from the header file.

  Rationale and discussion regarding the CDiskBlockIndex changes:

  Here is a failing test on master that demonstrates the inconsistent behavior of the current design: calling the same inherited public interface functions on the same CDiskBlockIndex object should yield identical behavior, but does not.

  ```diff
  diff --git a/src/test/validation_chainstatemanager_tests.cpp b/src/test/validation_chainstatemanager_tests.cpp
  index 6dc522b421..dac3840f32 100644
  --- a/src/test/validation_chainstatemanager_tests.cpp
  +++ b/src/test/validation_chainstatemanager_tests.cpp
  @@ -240,6 +240,15 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)

       const CBlockIndex* tip = chainman.ActiveTip();

       BOOST_CHECK_EQUAL(tip->nChainTx, au_data.nChainTx);

  +    // CDiskBlockIndex "is a" CBlockIndex, as it publicly inherits from it.
  +    // Test that calling the same inherited interface functions on the same
  +    // object yields identical behavior.
  +    CDiskBlockIndex index{tip};
  +    CBlockIndex *pB = &index;
  +    CDiskBlockIndex *pD = &index;
  +    BOOST_CHECK_EQUAL(pB->GetBlockHash(), pD->GetBlockHash());
  +    BOOST_CHECK_EQUAL(pB->ToString(), pD->ToString());
  ```

  (build and run: `$ ./src/test/test_bitcoin -t validation_chainstatemanager_tests`)

  The GetBlockHash() test assertion only passes on master because the different methods invoked by the current design happen to return the same result.  If one of the two is changed, it fails like the ToString() assertion does.

  Redefining inherited non-virtual functions is well-documented as incorrect design to avoid inconsistent behavior (see Scott Meyers, Effective C++, Item 36). Class usage is confusing when the behavior depends on the pointer definition instead of the object definition (static binding happening where dynamic binding was expected). This can lead to unsuspected or hard-to-track bugs.

  Outside of critical hot spots, correctness usually comes before optimisation, but the current design dates back to main.cpp and it may possibly have been chosen to avoid the overhead of dynamic dispatch.  This solution does the same: the class sizes are unchanged and no vptr or vtbl is added.

  There are better designs for doing this that use composition instead of inheritance, or that separate the public interface from the private implementations.  One example of the latter would be a non-virtual public interface that calls private virtual implementation methods, i.e. the Template pattern via the Non-Virtual Interface (NVI) idiom.

ACKs for top commit:
  vasild:
    ACK 3a61fc56a0

Tree-SHA512: 9ff358ab0a6d010b8f053ad8303c6d4d061e62d9c3755a56b9c9f5eab855d02f02bee42acc77dfa0cbf4bb5cb775daa72d675e1560610a29bd285c46faa85ab7
2022-07-25 16:20:13 +02:00
fanquake
73a0d6d0d4
Merge bitcoin/bitcoin#25611: univalue: Avoid brittle, narrowing and verbose integral type confusions
fa23c19750 univalue: Avoid narrowing and verbose int constructors (MacroFake)
fa3a9a1e8d rpc: Select int-UniValue constructor for enum value in upgradewallet RPC (MacroFake)

Pull request description:

  As UniValue provides several constructors for integral types, the
  compiler is unable to select one if the passed type does not exactly
  match. This is unintuitive for developers and forces them to write
  verbose and brittle code. (Refer to `-Wnarrowing` compiler warning)

  For example, there are many places where an unsigned int is cast to a
  signed int. While the cast is safe in practice, it is still needlessly
  verbose and confusing as the value can never be negative. In fact it
  might even be unsafe if the unsigned value is large enough to map to a
  negative signed one.

  Fix this issue and other (minor) type issues.

ACKs for top commit:
  aureleoules:
    ACK fa23c19750.

Tree-SHA512: 7d99b5b90c7d8eed2e3448167255a59e817dd6b8fcfc1b17c69ddefd0db33d1bf4344fbcd8b7f8685b58182c0f572ab9ffa99467afa666ac21843df7ea645033
2022-07-25 15:12:41 +01:00
MacroFake
fa2247a9f9
refactor: Make CTransaction constructor explicit
It involves calculating two hashes, so the performance impact should be
made explicit.

Also, add the module to iwyu.
2022-07-25 12:16:54 +02:00