Commit graph

22484 commits

Author SHA1 Message Date
Ryan Ofsky
230a2f4cc3 wallet test: Add unit test for wallet scan save_progress option 2022-06-23 17:13:40 -03:00
w0xlt
a89ddfbe22 wallet: Save wallet scan progress
Currently, the wallet scan progress is not saved.
If it is interrupted,  it will be necessary to start from
scratch on the next load.
With this change, progress is saved every 60 seconds.

Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
Co-authored-by: Jon Atack <jon@atack.com>
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2022-06-23 17:13:40 -03:00
laanwj
2598720d6c
Merge bitcoin/bitcoin#25457: Use more specific path when including memenv.h header
f3b5c1e452 Use more specific path when including `memenv.h` header (Hennadii Stepanov)

Pull request description:

  This PR makes our code base compatible with `leveldb`'s own CMake [project](https://github.com/bitcoin/bitcoin/blob/master/src/leveldb/CMakeLists.txt).

  Required for https://github.com/hebasto/bitcoin/pull/3.

  As a justification, please note that internally `leveldb` uses `#include "helpers/memenv/memenv.h"` rather `#include "memenv.h"`.

  #### Guix builds on `arm64`:
  ```
  # find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
  0e069318a681f9f848e803e5df8b25426b47ddc8994a21e0b83f0f86e7db7ae0  guix-build-f3b5c1e4522f/output/arm-linux-gnueabihf/SHA256SUMS.part
  e68e1b65514d42f1e33b2754356b68d3ddea1fe9df89d02df51375792867dd8c  guix-build-f3b5c1e4522f/output/arm-linux-gnueabihf/bitcoin-f3b5c1e4522f-arm-linux-gnueabihf-debug.tar.gz
  6b1b5c1f9525e8e467d038751bfc070ed6cbfbd42b17add2faac76fee421343e  guix-build-f3b5c1e4522f/output/arm-linux-gnueabihf/bitcoin-f3b5c1e4522f-arm-linux-gnueabihf.tar.gz
  9f8e941f37aa243fd36c1eaade9b88081b2a27562bfe7d8208d3c6021ecb6f03  guix-build-f3b5c1e4522f/output/arm64-apple-darwin/SHA256SUMS.part
  88cf46d00e67f3493e6ecbb85002ca0ff93dd47af3e93e51d95f92ed3218752f  guix-build-f3b5c1e4522f/output/arm64-apple-darwin/bitcoin-f3b5c1e4522f-arm64-apple-darwin-unsigned.dmg
  5afa9ae6943386ae600d612f1ed4831c0e92011f87284ae25465c2ffc6b8bb2b  guix-build-f3b5c1e4522f/output/arm64-apple-darwin/bitcoin-f3b5c1e4522f-arm64-apple-darwin-unsigned.tar.gz
  0b72a400f842ff31233ced2aadf0b8309ba6695b075b9f4345708dca235f6368  guix-build-f3b5c1e4522f/output/arm64-apple-darwin/bitcoin-f3b5c1e4522f-arm64-apple-darwin.tar.gz
  7912417348175c293002ccd3413ecb53c5a1d29a234959a94bdbd6481bd58d08  guix-build-f3b5c1e4522f/output/dist-archive/bitcoin-f3b5c1e4522f.tar.gz
  f8d28c57dc97fd1e6844fcb2679f2a44fc360ef37aad3fc4185fa1d091baf4b1  guix-build-f3b5c1e4522f/output/powerpc64-linux-gnu/SHA256SUMS.part
  c219a024c95bcdfe28961c18b8118152becf201b00f9e0e28ff35a7a2646fc9b  guix-build-f3b5c1e4522f/output/powerpc64-linux-gnu/bitcoin-f3b5c1e4522f-powerpc64-linux-gnu-debug.tar.gz
  2790ff48593be1699e4175cc31a6cc11fd2e758cdc99220c5a87ddb658d8a794  guix-build-f3b5c1e4522f/output/powerpc64-linux-gnu/bitcoin-f3b5c1e4522f-powerpc64-linux-gnu.tar.gz
  8d13f9f6141776263faceb396cbe3089e5c165523a5da160ba9ec6814744f7d4  guix-build-f3b5c1e4522f/output/powerpc64le-linux-gnu/SHA256SUMS.part
  72c1e8d7a9f2f0ff76c1dd84b4614202ce6734cb8ff29b2cf2cfc20a218d3aa5  guix-build-f3b5c1e4522f/output/powerpc64le-linux-gnu/bitcoin-f3b5c1e4522f-powerpc64le-linux-gnu-debug.tar.gz
  ed0494b336a1ae00050137ed0d18130d5c1213e6d45fada439de4e799ebfb720  guix-build-f3b5c1e4522f/output/powerpc64le-linux-gnu/bitcoin-f3b5c1e4522f-powerpc64le-linux-gnu.tar.gz
  a2a11b57a4a93b0b079c87c303e4c5250b16994d20f87ae362850efc1c181e57  guix-build-f3b5c1e4522f/output/riscv64-linux-gnu/SHA256SUMS.part
  ff63220629ef4b318cc9c2b858204961bc29fd0e901817a39e50e6893925f153  guix-build-f3b5c1e4522f/output/riscv64-linux-gnu/bitcoin-f3b5c1e4522f-riscv64-linux-gnu-debug.tar.gz
  eb0c0b3709a2d4fe9a6c18ad7a14b90a32fe8a5a7d72f75400ae014f2c847264  guix-build-f3b5c1e4522f/output/riscv64-linux-gnu/bitcoin-f3b5c1e4522f-riscv64-linux-gnu.tar.gz
  a82bb28e2a8c6523854f4f9d6ff89d6ba096fff526f17bf6182fd6b2ebf96395  guix-build-f3b5c1e4522f/output/x86_64-apple-darwin/SHA256SUMS.part
  91d2eea67bfde7a363c6ede8c358fb3de842b55cfe428abafa7b5985d619c62c  guix-build-f3b5c1e4522f/output/x86_64-apple-darwin/bitcoin-f3b5c1e4522f-x86_64-apple-darwin-unsigned.dmg
  f3cbc79b8fac7e8a8c9ba63b774cadb5a09cd64cc942e7b68cd1fc566b371021  guix-build-f3b5c1e4522f/output/x86_64-apple-darwin/bitcoin-f3b5c1e4522f-x86_64-apple-darwin-unsigned.tar.gz
  91fb98ed086613bb85959e9fc060ef0f816d5b4d52087b003c6a72ecf1c1309b  guix-build-f3b5c1e4522f/output/x86_64-apple-darwin/bitcoin-f3b5c1e4522f-x86_64-apple-darwin.tar.gz
  62309af3fc8316abd4c8f8285c666c568c140b9312f252a47ca6611fb51fef5e  guix-build-f3b5c1e4522f/output/x86_64-linux-gnu/SHA256SUMS.part
  deb27b75f52fb40cd13bfc6d594ed5ff0d82d1c211e2a6a91b9ca06ee3b8335b  guix-build-f3b5c1e4522f/output/x86_64-linux-gnu/bitcoin-f3b5c1e4522f-x86_64-linux-gnu-debug.tar.gz
  89faeb1f32f0447d26a73253a9f581b40b01982862351a7dd0cee05c8dbf29cc  guix-build-f3b5c1e4522f/output/x86_64-linux-gnu/bitcoin-f3b5c1e4522f-x86_64-linux-gnu.tar.gz
  5de46eec42bcd1e2e0fd3c9c6978a8a945b95411a9051fac9bb8a65d6b4875a5  guix-build-f3b5c1e4522f/output/x86_64-w64-mingw32/SHA256SUMS.part
  3271137a901889a38214173f01f96ae98385ea607e9573eaa2966e68c68401e1  guix-build-f3b5c1e4522f/output/x86_64-w64-mingw32/bitcoin-f3b5c1e4522f-win64-debug.zip
  7a74bf455bffa0d2abb99ce31ea1ef8088928f54c1f3c6e27044392f27e3e752  guix-build-f3b5c1e4522f/output/x86_64-w64-mingw32/bitcoin-f3b5c1e4522f-win64-setup-unsigned.exe
  73a23fd9846e615afcd569adc79fafdcf55b0efa9c383d2d0c9579fb0f79b91a  guix-build-f3b5c1e4522f/output/x86_64-w64-mingw32/bitcoin-f3b5c1e4522f-win64-unsigned.tar.gz
  ee5f3f9eb65f0ac1c0879d0aaa88cf20d8ca9329ba505f77580a0c9b57cd3244  guix-build-f3b5c1e4522f/output/x86_64-w64-mingw32/bitcoin-f3b5c1e4522f-win64.zip
  ```

ACKs for top commit:
  laanwj:
    Code review ACK f3b5c1e452
  fanquake:
    ACK f3b5c1e452

Tree-SHA512: 62e7cf49bc4ce08c8373a0fcfaf4ca10a83d18d0d00bdb21983c25b4b9192ace74acf64362b47faa429d13dbaf63be953fd3aa3b92366603866a472f95ef09a1
2022-06-23 19:32:10 +02:00
fanquake
e05564d706
Merge bitcoin/bitcoin#25446: p2p: Set CNode::m_relays_txs=true when receiving BIP37 filters
e7a9133766 [net processing] Set CNode::m_relays_txs=true when receiving BIP37 filters (dergoegge)

Pull request description:

  This line was accidentally removed in https://github.com/bitcoin/bitcoin/pull/22778.

  Receiving a `filterload` message implies that we should relay txs to the sender (`CNode::m_relays_txs = true`). `CNode::m_relays_txs` is only used for the inbound eviction logic, so removing the line might have slightly changed the eviction behaviour but nothing else.

ACKs for top commit:
  laanwj:
    Code review ACK e7a9133766
  vasild:
    ACK e7a9133766

Tree-SHA512: 19c5df0f579f707c6c7900d12a6b71ac69e802be64f7d2fdcc40ac714c918dc4c17def164592f8836cc105a03daefefca3ca5e10423145eca8db4348c27c9cfc
2022-06-23 16:18:07 +01:00
glozow
fa076515b0 [rpc] add new submitpackage RPC
It could be unsafe/confusing to create an actual mainnet interface while
package relay doesn't exist. However, a regtest-only interface allows
wallet/application devs to test current package policies.
2022-06-23 14:35:04 +01:00
Hennadii Stepanov
f3b5c1e452
Use more specific path when including memenv.h header 2022-06-23 15:33:01 +02:00
MacroFake
fabae3541a
rpc: Use steady_clock for getrpcinfo durations 2022-06-23 15:32:17 +02:00
Sebastian Falbesoner
e4b4db5610 refactor: remove unused method CDBWrapper::CompactRange
This method hasn't been used since the txindex migration code has been
removed (PR #22626, commit fa20f815a9).

Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
2022-06-23 13:59:25 +02:00
laanwj
bc83710fdc
Merge bitcoin-core/gui#623: Getting ready to Qt 6 (9/n). Apply Qt 6 specific changes
d8d99d041a qt6: Do not use deprecated high DPI attributes in Qt 6 (Hennadii Stepanov)
8927bb8f06 refactor: Fix style in `initTranslations()` function (Hennadii Stepanov)
ad73447dc2 qt6: Do not use deprecated `QLibraryInfo::path` in Qt 6 (Hennadii Stepanov)
3f51d0b8b2 qt6: Fix type registration (Hennadii Stepanov)

Pull request description:

  One more step in migration to Qt 6.

  Could be tested with hebasto/bitcoin#3 or bitcoin/bitcoin#24798.

  No behavior change when compiling with Qt 5.

ACKs for top commit:
  laanwj:
    Code review ACK d8d99d041a
  jarolrod:
    ACK d8d99d041a

Tree-SHA512: e5f92a80f8622e5f95dd98a90783956a26d3c8382b9ca8e479fb6c152cfdc85a2f6084e78d463ceea1e0f0b3ac72d2b086c8ca24967b2b6070553317e9e3252e
2022-06-23 11:47:51 +02:00
Carl Dong
ccbaf546a6 scripted-diff: Rename DEFAULT_MAX_MEMPOOL_SIZE to indicate SI unit
Better to be explicit when it comes to sizes to avoid unintentional
bugs. We use MB and KB all over the place.

-BEGIN VERIFY SCRIPT-
find_regex="DEFAULT_MAX_MEMPOOL_SIZE" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@\0_MB@g"
-END VERIFY SCRIPT-
2022-06-22 18:18:56 -04:00
Carl Dong
fc02f77ca6 ArgsMan: Add Get*Arg functions returning optional
This allows the caller to not provide a default at all and just check
inside the optional to see if the arg was set or not.
2022-06-22 18:18:52 -04:00
furszy
324f00a642
refactor: 'ListReceived' use optional for filtered address
Plus remove open bracket jump line
2022-06-22 12:51:30 -03:00
furszy
b459fc122f
refactor: RPC 'ListReceived', encapsulate m_address_book access 2022-06-22 12:51:30 -03:00
furszy
fa9f2ab8fd
refactor: RPC 'listlabels', encapsulate 'CWallet::ListAddrBookLabels' functionality
Mainly to not access 'm_address_book' externally.
2022-06-22 12:51:30 -03:00
laanwj
a085a55491
Merge bitcoin/bitcoin#25428: Remove Sock::Release() and CloseSocket()
a724c39606 net: rename Sock::Reset() to Sock::Close() and make it private (Vasil Dimov)
e8ff3f0c52 net: remove CloseSocket() (Vasil Dimov)
175fb2670a net: remove now unused Sock::Release() (Vasil Dimov)

Pull request description:

  _This is a piece of #21878, chopped off to ease review._

  * `Sock::Release()` is unused, thus remove it
  * `CloseSocket()` is only called from `Sock::Reset()`, so move the body of `CloseSocket()` inside `Sock::Reset()` and remove `CloseSocket()` - this helps to hide low level file descriptor sockets inside the `Sock` class.
  * Rename `Sock::Reset()` to `Sock::Close()` and make it `private` - to be used only in the destructor and in the `Sock` assignment operator. This simplifies the public API by removing one method from it.

ACKs for top commit:
  laanwj:
    Code review ACK a724c39606

Tree-SHA512: 4b12586642b3d049092fadcb1877132e285ec66a80af92563a7703c6970e278e0f2064fba45c7eaa78eb65db94b3641fd5e5264f7b4f61116d1a6f3333868639
2022-06-22 11:07:17 +02:00
dergoegge
e7a9133766 [net processing] Set CNode::m_relays_txs=true when receiving BIP37 filters
This line was accidentally removed in #22778.
2022-06-22 11:03:35 +02:00
MarcoFalke
fa1fe2e500
Remove LOCKTIME_MEDIAN_TIME_PAST constant 2022-06-22 09:54:15 +02:00
MarcoFalke
fa07f84e31
Fix signed integer overflow in prioritisetransaction RPC 2022-06-22 09:32:09 +02:00
MarcoFalke
fa52cf8e11
refactor: Replace feeDelta by m_modified_fee
* feeDelta tracked the delta (to be applied on top of the actual fee)
* m_modified_fee tracks the actual fee with the delta included
* Instead of passing in the new total delta to the Updater, pass in by
  how much the total delta should be modified.

This is needed for the next commit, but makes sense on its own because
the same is done by UpdateDescendantState and UpdateAncestorState.
2022-06-22 09:32:07 +02:00
Vasil Dimov
a724c39606
net: rename Sock::Reset() to Sock::Close() and make it private
Outside of `Sock`, `Sock::Reset()` was used in just one place (in
`i2p.cpp`) which can use the assignment operator instead.

This simplifies the public `Sock` API by having one method less.
2022-06-22 09:19:43 +02:00
MarcoFalke
fa7cbc6e5c
build: Remove negated --enable-fuzz checks from build system 2022-06-22 08:12:23 +02:00
MacroFake
e3b06e8dd8
Merge bitcoin/bitcoin#25440: log: Use consistent wording in random.cpp log
c01ae8f5ea Use consistent wording in log (Igor Bubelov)

Pull request description:

  It's a trivial change, but it bothers me a bit that two log lines in a row aren't grammatically identical while following exactly the same pattern. I've read `contributing.md` and I'm aware that changes like this are usually being ignored and dropped, but I decided to leave it here anyway in case someone feels the same way about inconsistent log messages or grammar =)

ACKs for top commit:
  laanwj:
    Code review ACK c01ae8f5ea

Tree-SHA512: d5b3849b3a6e3de7ea9b468c05f17cacd1dbd1aca2f3401b5138383dc8d385cea9e221db558ab472c1c4c7f6921d57dcc7af89a54776c5765fa00e429694b4e7
2022-06-22 07:49:22 +02:00
laanwj
a4e066af85
Merge bitcoin/bitcoin#24352: Add doc/design/libraries.md
dc1e7ad7a5 Add doc/design/libraries.md (Ryan Ofsky)

Pull request description:

  Prompted by the [libbitcoinkernel issue #24303](https://github.com/bitcoin/bitcoin/issues/24303) and PRs, I started looking at  existing libraries and what their dependencies are and wrote this document to describe them and where `libbitcoinkernel` fits in.

  Readable link is:  https://github.com/ryanofsky/bitcoin/blob/pr/libs/doc/design/libraries.md

  Feedback is welcome

ACKs for top commit:
  laanwj:
    ACK dc1e7ad7a5
  hebasto:
    Approach ACK dc1e7ad7a5, using this doc as a guide in https://github.com/hebasto/bitcoin/pull/3 :)

Tree-SHA512: 7687b1847797c50de1f5ea721bd201cc8304690064743fbe6d69e2198cc239084e9da7d158be65bea948a6ec3d71d74c84122c0e523c390b389b49ea8d2cddc9
2022-06-22 07:13:17 +02:00
laanwj
58b9d6cf9e
Merge bitcoin-core/gui#620: Replace QRegExp with QRegularExpression
67364ebe4c test, qt: Add tests for `GUIUtil::extractFirstSuffixFromFilter` (w0xlt)
ace9af5688 qt: Replace `QRegExp` with `QRegularExpression` (w0xlt)
c378535e28 qt: Add a function that extracts the suffix from a filter (w0xlt)

Pull request description:

  Picking up https://github.com/bitcoin-core/gui/pull/606 (labeled "Up for grabs") and applying https://github.com/bitcoin-core/gui/pull/606#pullrequestreview-984607067 and https://github.com/bitcoin-core/gui/pull/606#issuecomment-1137149907.

  Replaces occurrences of `QRegExp` usage with `QRegularExpression` as part of the roadmap for Qt6 integration.

  Fixes https://github.com/bitcoin-core/gui/issues/578

ACKs for top commit:
  laanwj:
    Code review and lightly tested ACK 67364ebe4c
  hebasto:
    ACK 67364ebe4c

Tree-SHA512: 4a17d83e557bc635cbd1a15776856e9edb7162b23a369ccbd2ac59c68b8a1ea663baaa7d5ad98e419dc03b91ef3315c768eeadc01c0b29162de109493161e814
2022-06-22 07:12:10 +02:00
Andrew Chow
174b821e64
Merge bitcoin/bitcoin#25427: wallet: remove extra wtx lookup in AddToSpends
32e5edc0f4 wallet: avoid extra wtx lookup in AddToSpends (furszy)

Pull request description:

  As `AddToSpends` is only called from `AddToWallet` and `LoadToWallet`, places where we insert the wtx into the wallet map, we can directly feed `AddToSpends` with the `wtx` and remove another extra lookup.

ACKs for top commit:
  laanwj:
    Code review ACK 32e5edc0f4
  achow101:
    ACK 32e5edc0f4
  theStack:
    Code-review ACK 32e5edc0f4
  w0xlt:
    Code Review ACK 32e5edc0f4
  brunoerg:
    crACK 32e5edc0f4

Tree-SHA512: e9fb8df44c3e3fa26c107d261bf78e45014b4755890a64817f2be62ee6b7751f5dd2813a18dcb103a21ddba1422f9d2d59c4bf186f08314e634365d36b01be8f
2022-06-21 20:56:24 -04:00
w0xlt
67364ebe4c test, qt: Add tests for GUIUtil::extractFirstSuffixFromFilter 2022-06-21 19:19:31 -03:00
w0xlt
ace9af5688 qt: Replace QRegExp with QRegularExpression
Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
Co-authored-by: Jarol Rodriguez <jarolrod@tutanota.com>
2022-06-21 19:19:18 -03:00
w0xlt
c378535e28 qt: Add a function that extracts the suffix from a filter
Extract the 'Extract first suffix from filter pattern...'
functionality into a testable utility function
2022-06-21 19:16:39 -03:00
laanwj
c3a41ad980
Merge bitcoin/bitcoin#25314: p2p: always set nTime for self-advertisements
99b9e5f3a9 p2p: always set nTime for self-advertisements (Martin Zumsande)

Pull request description:

  This logic was recently changed in 0cfc0cd322 to overwrite `addrLocal` with the address they gave us when self-advertising to an inbound peer. But if we don't also change `nTime` again from the default `TIME_INIT`, our peer will not relay our advertised address any further.

ACKs for top commit:
  naumenkogs:
    ACK 99b9e5f3a9
  laanwj:
    Code review ACK 99b9e5f3a9
  vasild:
    ACK 99b9e5f3a9

Tree-SHA512: 4c7ea51cc77ddaa4b3537962ad2ad085f7ef5322982d3b1f5baecb852719eb99dd578436ca63432cb6b0a4fbd8b59fca793caf326c4663a4d6f34301e8146aa2
2022-06-22 00:00:43 +02:00
MacroFake
fafee78188
rpc: Return incrementalrelayfee in getmempoolinfo 2022-06-21 18:03:29 +02:00
Igor Bubelov
c01ae8f5ea Use consistent wording in log 2022-06-21 22:54:55 +07:00
Sebastian Falbesoner
fb38c6e21f refactor: remove unused methods {CDBIterator,CCoinsViewDBCursor}::GetValueSize()
These methods haven't been used since the chainstate db cache has been
switched from per-tx to per-txout model years ago (PR #10195, commit
d342424301).
2022-06-21 16:19:10 +02:00
furszy
83e42c4b94
refactor: use 'ForEachAddrBookEntry' in RPC 'getaddressesbylabel' 2022-06-21 10:23:20 -03:00
furszy
2b48642499
refactor: use ForEachAddrBookEntry in interfaces::getAddresses 2022-06-21 10:23:20 -03:00
furszy
032842ae41
wallet: implement ForEachAddrBookEntry method 2022-06-21 10:23:20 -03:00
furszy
09649bc95d
refactor: implement general 'ListAddrBookAddresses' for addressbook destinations lookup 2022-06-21 10:23:20 -03:00
Hennadii Stepanov
d8d99d041a
qt6: Do not use deprecated high DPI attributes in Qt 6
In Qt 6, high DPI pixmaps and scaling are always enabled.

https://doc.qt.io/qt-6/highdpi.html
2022-06-21 13:50:48 +02:00
Hennadii Stepanov
8927bb8f06
refactor: Fix style in initTranslations() function 2022-06-21 13:40:45 +02:00
Hennadii Stepanov
ad73447dc2
qt6: Do not use deprecated QLibraryInfo::path in Qt 6
See https://doc.qt.io/qt-6/qtcore-changes-qt6.html#other-classes
2022-06-21 13:39:26 +02:00
Hennadii Stepanov
3f51d0b8b2
qt6: Fix type registration
In Qt 6, registration of `QDataStream` streaming operators is done
automatically. Consequently, `qRegisterMetaTypeStreamOperators()` does
no longer exist. Calls to this method have to be removed when porting
to Qt 6.

See https://doc.qt.io/qt-6/qtcore-changes-qt6.html#the-qmetatype-class
2022-06-21 13:14:21 +02:00
laanwj
5884a47c36
Merge bitcoin/bitcoin#25422: build: globally define NOMINMAX when building with mingw-w64
58a9601dff build: globally define NOMINMAX (fanquake)

Pull request description:

  Define (and document) `NOMINMAX` once, rather than across multiple
  source files.

  Defining this prevents the definition of min/max macros when using
  mingw-w64, which may conflict with unprefixed std::min/max usage. While
  that might not be the case for us, we'd always prefer to use the standard
  library in any case.

  For example:
  73cadc06c6/mingw-w64-headers/include/ntdef.h (L289-L300)

  Note that we already define NOMINMAX globally when building with MSVC.

  Guix Build (arm64):
  ```bash
  d3a3b7045dc1677f6a0a2a73a484f156c81ae764058003d9e870b346912b744a  guix-build-58a9601dffa6/output/arm-linux-gnueabihf/SHA256SUMS.part
  3e66540a3f8c8a10864ab2fed69581241fa41af86bbb028e5f7c3dd4ba859c64  guix-build-58a9601dffa6/output/arm-linux-gnueabihf/bitcoin-58a9601dffa6-arm-linux-gnueabihf-debug.tar.gz
  78756e20d45e327cfd7f9e65858bf6d3814bcbe08f9f825fd6dfc9dff999ea6d  guix-build-58a9601dffa6/output/arm-linux-gnueabihf/bitcoin-58a9601dffa6-arm-linux-gnueabihf.tar.gz
  11073e88d4fd0411c5119a3dca3a90788693fa9aa5134339c84be98ae893cd77  guix-build-58a9601dffa6/output/arm64-apple-darwin/SHA256SUMS.part
  deffd5f8c6286be34bc35e71ec70300bacb37e1b1a83e67c0833cb57d7a45529  guix-build-58a9601dffa6/output/arm64-apple-darwin/bitcoin-58a9601dffa6-arm64-apple-darwin-unsigned.dmg
  acee7e98c5ec41f67e86c78dc5b45fa8bc82de86a04b8c43dbf9c59e7aff36a9  guix-build-58a9601dffa6/output/arm64-apple-darwin/bitcoin-58a9601dffa6-arm64-apple-darwin-unsigned.tar.gz
  83f7cbaf6680fe8981db9260b97ca87d609a76c0857a744c7d406645d2484e1b  guix-build-58a9601dffa6/output/arm64-apple-darwin/bitcoin-58a9601dffa6-arm64-apple-darwin.tar.gz
  b8c73b40a5e307e9e7e482ce92164990d442f3f105a5240ec6eb96a775cb35d5  guix-build-58a9601dffa6/output/dist-archive/bitcoin-58a9601dffa6.tar.gz
  cc435cd925771af7e261d0121047339ea8fddb0d1548b699c12108a62988cd32  guix-build-58a9601dffa6/output/powerpc64-linux-gnu/SHA256SUMS.part
  7a68bd3181a054056b0a5eb6e830b90ac4ba8435114127d5f1720643011aa78f  guix-build-58a9601dffa6/output/powerpc64-linux-gnu/bitcoin-58a9601dffa6-powerpc64-linux-gnu-debug.tar.gz
  bc55b95e263c455a964d9463a3ee60dabee1d10cefc6641ed29a3b1b317d61e0  guix-build-58a9601dffa6/output/powerpc64-linux-gnu/bitcoin-58a9601dffa6-powerpc64-linux-gnu.tar.gz
  49df78009d80af02262806c6c395e2c884a979b1ea13d01aa27d8188403e29d1  guix-build-58a9601dffa6/output/powerpc64le-linux-gnu/SHA256SUMS.part
  29dc7a0e10707b3511fa2afb6977df7ebbb67f796d8be5a042abc14eba764aef  guix-build-58a9601dffa6/output/powerpc64le-linux-gnu/bitcoin-58a9601dffa6-powerpc64le-linux-gnu-debug.tar.gz
  51b7f8e1bccff1e2ce1860bbc382eefe648b90cc3374cdfa3a95a7454386e77d  guix-build-58a9601dffa6/output/powerpc64le-linux-gnu/bitcoin-58a9601dffa6-powerpc64le-linux-gnu.tar.gz
  e62e46d8cebbbfc0f587e930acb648fcae99cfe8b2f63aeba98e46e3338fe1e3  guix-build-58a9601dffa6/output/riscv64-linux-gnu/SHA256SUMS.part
  fa5d0a074ca586583bf08dbf748909b3ff5e0a54a2e5aaa88abec666e17b4e72  guix-build-58a9601dffa6/output/riscv64-linux-gnu/bitcoin-58a9601dffa6-riscv64-linux-gnu-debug.tar.gz
  684b2917fd27a41f884bb6870f7fac847d52b6f8b40df5779d1c674409f7cd14  guix-build-58a9601dffa6/output/riscv64-linux-gnu/bitcoin-58a9601dffa6-riscv64-linux-gnu.tar.gz
  7d7cfd0212b49eec48c7f8dc0d97add53096685dfd646feac466c27a45d20c97  guix-build-58a9601dffa6/output/x86_64-apple-darwin/SHA256SUMS.part
  d70ae6d060b7832f8741dc5d1958cc0d32702605c863254303107246deec0aa6  guix-build-58a9601dffa6/output/x86_64-apple-darwin/bitcoin-58a9601dffa6-x86_64-apple-darwin-unsigned.dmg
  930f3ec43896404208ebdb582c9175e3a5a2470d778722e0001addde84dad99a  guix-build-58a9601dffa6/output/x86_64-apple-darwin/bitcoin-58a9601dffa6-x86_64-apple-darwin-unsigned.tar.gz
  2d8a9d12aadcf60634db953fcb8bd496a002608e9a64eb7d60bb7ffe1f94489f  guix-build-58a9601dffa6/output/x86_64-apple-darwin/bitcoin-58a9601dffa6-x86_64-apple-darwin.tar.gz
  10363729ece6e1c2cbdf435483006191bf17d1def2d318ff8357197d91c06ded  guix-build-58a9601dffa6/output/x86_64-linux-gnu/SHA256SUMS.part
  d50ec8e4f72e8b064b196eb0ece212f7b0b126f4b8b644c4451084cbf0416072  guix-build-58a9601dffa6/output/x86_64-linux-gnu/bitcoin-58a9601dffa6-x86_64-linux-gnu-debug.tar.gz
  471e12b8715ecff4d99121c4bb3288ef4b005ca468810a714c67ea3e7c6669e9  guix-build-58a9601dffa6/output/x86_64-linux-gnu/bitcoin-58a9601dffa6-x86_64-linux-gnu.tar.gz
  d63946401952d131fdf5df9442c52151d86e53f019234b5ad16fdef0d2976356  guix-build-58a9601dffa6/output/x86_64-w64-mingw32/SHA256SUMS.part
  5359782e1eb6f449338f18e053ad82f25382d968690208ae5739d9338eb7bdc7  guix-build-58a9601dffa6/output/x86_64-w64-mingw32/bitcoin-58a9601dffa6-win64-debug.zip
  0d387d5a4cb1d712556a3fe5b4bd1e928bb5fbbe57a85ee06c746f132a6b1ec5  guix-build-58a9601dffa6/output/x86_64-w64-mingw32/bitcoin-58a9601dffa6-win64-setup-unsigned.exe
  dbfd7419d1d764e853a9dc041e276669b488aea4a80e21e4a175b6c3e512e70c  guix-build-58a9601dffa6/output/x86_64-w64-mingw32/bitcoin-58a9601dffa6-win64-unsigned.tar.gz
  0ba07504d9d5a12af9144e8b386b2640b48dba067d47c694a44ecffe56b0c0fc  guix-build-58a9601dffa6/output/x86_64-w64-mingw32/bitcoin-58a9601dffa6-win64.zip
  ```

ACKs for top commit:
  laanwj:
    Code review ACK 58a9601dff

Tree-SHA512: d1c22b3d0d21ef8f9f605ef6ca06353e3f48536d84f3531f93d613a6ccbbe62f12fae0ed09e8b9a8940b0ef33f9d41d9991eb56fbe7c4ab48f0ce7fcf44e08b1
2022-06-21 12:42:05 +02:00
Hennadii Stepanov
18d9189cc9
Merge bitcoin-core/gui#612: refactor: Drop unused QFrames in SendCoinsEntry
7ab72b9d2a qt: Fix `BitcoinAmountField`'s base widget (Hennadii Stepanov)
3262542104 qt, refactor: Fix `sendcoinsentry.ui` indentation (Hennadii Stepanov)
f3c7603329 qt, refactor: Convert `SendCoinsEntry` to a sub-`QWidget` (Hennadii Stepanov)
6420fb2005 qt, refactor: Drop unused `QFrame`s in `SendCoinsEntry` (Hennadii Stepanov)

Pull request description:

  The `SendCoins_UnauthenticatedPaymentRequest` and `SendCoins_AuthenticatedPaymentRequest` sub-`QFrame`'s of the `SendCoinsEntry` widget have been unused since bitcoin/bitcoin#17165.

  Removed all dead code. The resulted `SendCoinsEntry` widget has been simplified.

ACKs for top commit:
  w0xlt:
    Tested ACK 7ab72b9d2a
  shaavan:
    reACK 7ab72b9d2a

Tree-SHA512: a46db90d60fae584b52cc7edae910c295351cb3627e04d225708c50c04f7fdd81d2755e055115612a12a3c841e78c31bdcd57bed9feb1d3909f7a2f6e76bd356
2022-06-21 12:17:30 +02:00
Hennadii Stepanov
09a76e43fd
Merge bitcoin-core/gui#615: If -prune=0 is set, Uncheck Prune on Intro page
40566e21c0 If -prune=0 is set, Uncheck Prune on Intro page (Jadi)

Pull request description:

  If the bitcoin-qt is started with -prune=0 arg, On the Intro page,
  the Prune Checkbox will be unchecked too, to prevent confusions.

  refs: https://github.com/bitcoin/bitcoin/issues/25052

ACKs for top commit:
  hebasto:
    re-ACK 40566e21c0

Tree-SHA512: d5e0b76a7d20ae806e61a416fd907650f15a744a5823d0f8b57a634cb099bb135199e69a787bd54ecde2cf84e95633f40ff407a722350f337b27de395a6e0f78
2022-06-21 01:22:33 +02:00
laanwj
bc28ca3afb
Merge bitcoin/bitcoin#25118: wallet: unify “allow/block other inputs“ concept
d338712886 scripted-diff: rename fAllowOtherInputs -> m_allow_other_inputs (furszy)
8dea74a8ff refactor: use GetWalletTx in SelectCoins instead of access mapWallet (furszy)
b4e2d4d4ee wallet: move "use-only coinControl inputs" below the selected inputs lookup (furszy)
25749f1df7 wallet: unify “allow/block other inputs“ concept (furszy)

Pull request description:

  Seeking to make the `CoinControl` options less confusing/redundant.
  It should have no functional changes.

  The too long to read technical description; remove `m_add_inputs`, we can use the already existent `fAllowOtherInputs` flag.

  In #16377 the `CoinControl` flag ‘m_add_inputs’ was added to tell the coin filtering and selection process two things:
  - Coin Filtering: Only use the provided inputs. Skip the Rest.
  - Coin Selection: Search the wtxs-outputs and append all the `CoinControl` internal and external selected outpoints to the selection result (skipping all the available output checks). Nothing else.

  Meanwhile, in `CoinControl` we already have a flag ‘fAllowOtherInputs’ which is already saying:
  - Coin Filtering: Only use the provided inputs. Skip the Rest.
  - Coin Selection: If false, no selection process -> append all the `CoinControl` selected outpoints to the selection result (while they passed all the `AvailableCoins` checks and are available in the 'vCoins' vector).

  ### Changes

  As can notice, the first point in the coin filtering process is duplicated in the two option flags. And the second one, is slightly different merely because it takes into account whether the coin is on the `AvailableCoins` vector or not.
  So it makes sense to merge ‘m_add_inputs’ and ‘fAllowOtherInputs’ into a single field for the coin filtering process while introduce other changes to add the missing/skipped internal and external coins into 'vCoins' vector if they were manually selected by the user.

  ——————————————————————————————————

  Just as an extra note:
  On top of this, I’m working on unifying/untangling further the coin filtering and selection processes so we have less duplicate functionality in both processes.

ACKs for top commit:
  laanwj:
    Code review ACK d338712886

Tree-SHA512: 98920b80dd787cfe737dacd4c59575dfa8393c799b55f2aaef9aed2b15c61470715a88663557b49c7400938220f99af7690be01980a8684f4f71947407f21750
2022-06-20 21:37:55 +02:00
furszy
32e5edc0f4
wallet: avoid extra wtx lookup in AddToSpends
This method is only called from AddToWallet and LoadToWallet,
places where we already have the wtx.
2022-06-20 14:21:57 -03:00
Vasil Dimov
e8ff3f0c52
net: remove CloseSocket()
Do the closing in `Sock::Reset()` and remove the standalone
`CloseSocket()`.

This reduces the exposure of low-level sockets (i.e. integer file
descriptors) outside of the `Sock` class.
2022-06-20 16:38:31 +02:00
Vasil Dimov
175fb2670a
net: remove now unused Sock::Release() 2022-06-20 15:01:28 +02:00
Vasil Dimov
a8d6abba5e
net: change GetBindAddress() to take Sock argument
This avoids the direct call to `getsockname()` and allows mocking.
2022-06-20 14:51:48 +02:00
Vasil Dimov
748dbcd9f2
net: add new method Sock::GetSockName() that wraps getsockname()
This will help to increase `Sock` usage and make more code mockable.
2022-06-20 14:51:18 +02:00
fanquake
58a9601dff
build: globally define NOMINMAX
Define (and document) `NOMINMAX` once, rather than across multiple
source files.

Defining this prevents the definition of min/max macros when using
mingw-w64, which may conflict with unprefixed std::min/max usage. While
that might not be the case for us, we'd always prefer to use the standard
library in any case.

For example:
73cadc06c6/mingw-w64-headers/include/ntdef.h (L289-L300)
2022-06-20 12:22:05 +01:00
fanquake
0d8e68d705
refactor: move DEFAULT_*_LIMIT assertions from validation to policy 2022-06-20 10:24:15 +01:00
fanquake
9c94f3b3a7
refactor: move EXTRA_DESCENDANT_TX_SIZE_LIMIT to policy/policy.h 2022-06-20 10:02:59 +01:00
fanquake
39c6036253
refactor: use braced initialization in policy/policy.h 2022-06-20 10:02:59 +01:00
fanquake
01ccfbe3aa
scripted-diff: use static constexpr in policy/policy.h
-BEGIN VERIFY SCRIPT-

sed -i -e "s/static const /static constexpr /" src/policy/policy.h

-END VERIFY SCRIPT-
2022-06-20 10:02:59 +01:00
fanquake
62d56bb714
refactor: Move DEFAULT_DESCENDANT_SIZE_LIMIT to policy/policy.h 2022-06-20 10:02:58 +01:00
fanquake
a34aa4c187
refactor: Move DEFAULT_DESCENDANT_LIMIT to policy/policy.h 2022-06-20 10:02:58 +01:00
fanquake
05fc5fdc13
refactor: Move DEFAULT_ANCESTOR_SIZE_LIMIT to policy/policy.h 2022-06-20 10:02:58 +01:00
CAnon
da8d304960
refactor: Move DEFAULT_ANCESTOR_LIMIT to policy/policy.h 2022-06-20 10:02:58 +01:00
furszy
d338712886
scripted-diff: rename fAllowOtherInputs -> m_allow_other_inputs
-BEGIN VERIFY SCRIPT-
sed -i 's/fAllowOtherInputs/m_allow_other_inputs/g' -- $(git grep --files-with-matches 'fAllowOtherInputs')
-END VERIFY SCRIPT-
2022-06-19 20:32:51 -03:00
furszy
8dea74a8ff
refactor: use GetWalletTx in SelectCoins instead of access mapWallet 2022-06-19 20:32:51 -03:00
furszy
b4e2d4d4ee
wallet: move "use-only coinControl inputs" below the selected inputs lookup
Otherwise, RPC commands such as `walletcreatefundedpsbt` will not support the manual selection of locked, spent and externally added coins.

Full explanation is inside #25118 comments but brief summary is:

`vCoins` at `SelectCoins` time could not be containing the manually selected input because, even when they were selected by the user, the current `AvailableCoins` flow skips locked and spent coins.

Extra note: this is an intermediate step to unify the `fAllowOtherInputs`/`m_add_inputs` concepts. It will not be a problem anymore in the future when we finally decouple the wtx-outputs lookup process from `SelectCoins` and don't skip the user's manually selected coins in `AvailableCoins`.
2022-06-19 20:32:51 -03:00
furszy
25749f1df7
wallet: unify “allow/block other inputs“ concept
Seeking to make the `CoinControl` option less confusing/redundant.

In #16377 the `CoinControl` flag ‘m_add_inputs’ was added to tell the coin filtering and selection process two things:
	- Coin Filtering: Only use the provided inputs. Skip the Rest.
	- Coin Selection: Search the wtxs-outputs and append all the `CoinControl` selected outpoints to the selection result (skipping all the available output checks). Nothing else.

Meanwhile, in `CoinControl` we already have a flag ‘fAllowOtherInputs’ which is already saying:
	- Coin Filtering: Only use the provided inputs. Skip the Rest.
	- Coin Selection: If false, no selection process -> append all the `CoinControl` selected outpoints to the selection result (while they passed all the `AvailableCoins` checks and are available in the 'vCoins' vector).

As can notice, the first point in the coin filtering process is duplicated in the two option flags. And the second one, is slightly different merely because it takes into account whether the coin is on the `AvailableCoins` vector or not.
So it makes sense to merge ‘m_add_inputs’ and ‘fAllowOtherInputs’ into a single field for the coin filtering process while introduce other changes to add the missing/skipped coins into 'vCoins' vector if they were manually selected by the user (follow-up commits).
2022-06-19 20:02:35 -03:00
furszy
7ca8726f63
wallet: fix warning: "argument name 'feerate' in comment does not match parameter name"
Happened because the "feerate=" comment was after the comma.
2022-06-18 12:45:27 -03:00
Andrew Chow
8be652e439
Merge bitcoin/bitcoin#25005: wallet: remove extra wtx lookup in 'AvailableCoins' + several code cleanups.
fd5c996d16 wallet: GetAvailableBalance, remove double walk-through every available coin (furszy)
162d4ad10f wallet: add 'only_spendable' filter to AvailableCoins (furszy)
cdf185ccfb wallet: remove unused IsSpentKey(hash, index) method (furszy)
4b83bf8dbc wallet: avoid extra IsSpentKey -> GetWalletTx lookups (furszy)
3d8a282257 wallet: decouple IsSpentKey(scriptPubKey) from IsSpentKey(hash, n) (furszy)
a06fa94ff8 wallet: IsSpent, 'COutPoint' arg instead of (hash, index) (furszy)
91902b7720 wallet: IsLockedCoin, 'COutPoint' arg instead of (hash, index) (furszy)
9472ca0a65 wallet: AvailableCoins, don't call 'wtx.tx->vout[i]' multiple times (furszy)
4ce235ef8f wallet: return 'CoinsResult' struct in `AvailableCoins` (furszy)

Pull request description:

  This started in #24845 but grew out of scope of it.

  So, points tackled:

  1) Avoid extra `GetWalletTx` lookups inside `AvailableCoins -> IsSpentKey`.
      `IsSpentKey` was receiving the tx hash and index to internally lookup the tx inside the wallet's map. As all the `IsSpentKey` function callers already have the wtx available, them can provide the `scriptPubKey` directly.

  2) Most of the time, we call `Wallet::AvailableCoins`, and later on the process, skip the non-spendable coins from the result in subsequent for-loops. So to speedup the process: introduced the ability to filter by "only_spendable" coins inside `Wallet::AvailableCoins` directly.
  (the non-spendable coins skip examples are inside `AttemptSelection->GroupOutputs` and `GetAvailableBalance`).

  4) Refactored `AvailableCoins` in several ways:

     a) Now it will return a new struct `CoinsResult` instead of receiving the vCoins vector reference (which was being cleared at the beginning of the method anyway). --> this is coming from #24845 but cherry-picked it here too to make the following commits look nicer.

     b) Unified all the 'wtx.tx->vout[I]' calls into a single call (coming from this comment https://github.com/bitcoin/bitcoin/pull/24699#discussion_r854163032).

  5) The wallet `IsLockedCoin` and `IsSpent` methods now accept an `OutPoint` instead of a hash:index. Which let me cleanup a bunch of extra code.

  6) Speeded up the wallet 'GetAvailableBalance': filtering `AvailableCoins` by spendable outputs only and using the 'AvailableCoins' retrieved `total_amount` instead of looping over all the retrieved coins once more.

  -------------------------------------------------------

  Side topic, all this process will look even nicer with #25218

ACKs for top commit:
  achow101:
    ACK fd5c996d16
  brunoerg:
    crACK fd5c996d16
  w0xlt:
    Code Review ACK fd5c996d16

Tree-SHA512: 376a85476f907f4f7d1fc3de74b3dbe159b8cc24687374d8739711ad202ea07a33e86f4e66dece836da3ae6985147119fe584f6e672f11d0450ba6bd165b3220
2022-06-17 18:02:33 -04:00
Martin Zumsande
e357c89538 p2p, doc: Use MAX_BLOCKS_TO_ANNOUNCE consistently
It is an inclusive upper bound according to its definition.
2022-06-17 16:16:31 -04:00
laanwj
1b0469199b
Merge bitcoin/bitcoin#25281: build: Remove unused LIBBITCOIN_KERNEL variable
ce1c8104aa build: Remove unused `LIBBITCOIN_KERNEL` variable (Hennadii Stepanov)

Pull request description:

  Noticed that while working on moving the build system to CMake. But I [am not the first](https://github.com/bitcoin/bitcoin/pull/24322/files#r860472867) one :)

ACKs for top commit:
  laanwj:
    ACK ce1c8104aa

Tree-SHA512: 877b9f0d64c4c72f403335d7a8462e551f6f8cd5648a211f980d6da5ed7683521d6549f6acf15ac8e55f67915c556201a1980228c975a22135507746e2f392ce
2022-06-17 22:04:38 +02:00
laanwj
015717e2b8
Merge bitcoin/bitcoin#25299: doc: Correct comments re. units of constants
241c4d047e doc: Correct comment describing value of MAX_FILE_SIZE_PSBT as in MiB (Ben Woosley)
64f81a38b9 doc: Correct nPruneTarget misidentifying units of variable (darosior)

Pull request description:

  In https://github.com/bitcoin/bitcoin/pull/15848, darosior fixed up a comment which mis-identified the units of a constant.

  Another comment misidentified a value as in MiB rather than MB.

ACKs for top commit:
  laanwj:
    Code review ACK 241c4d047e
  darosior:
    ACK 241c4d047e, with or without https://github.com/bitcoin/bitcoin/pull/25299#discussion_r892705277

Tree-SHA512: 96c03a35140e5c53759f387bd292a8f8f621ba74c3cf6621939fad40f48892d23141c747ad3ab4fd71108e3b737670175abc2eb3990a1bd1660366c55d61ddf8
2022-06-17 21:47:33 +02:00
furszy
c318211ddd
walletdb: fix last client version update
The value was only being updated launching releases with higher version numbers
and not if the user launched a previous release.

Co-authored-by: MacroFake <falke.marco@gmail.com>
2022-06-16 15:33:30 -03:00
Andrew Chow
b0c8306349
Merge bitcoin/bitcoin#24649: wallet: do not count wallet utxos as external
7832e9438f test: fundrawtransaction preset input weight calculation (S3RK)
c3981e379f wallet: do not count wallet utxos as external (S3RK)

Pull request description:

  Correctly differentiating between external vs non-external utxos in coin control produces more accurate weight and fee estimations.

  Weight for external utxos is estimated based on the maximum signature size, while for the wallet utxos we expect minimal signature due to signature grinding.

ACKs for top commit:
  achow101:
    re-ACK 7832e9438f
  Xekyo:
    re-ACK 7832e9438f
  furszy:
    ACK 7832e943

Tree-SHA512: bb5635b0bd85fa9a76922a53ad3fa062286424c06a695a0e87407c665713e80a33555b644fbb13bcc1ab503dcd7f53aacbdc368d69ac0ecff8005603623ac94f
2022-06-16 14:11:19 -04:00
laanwj
0ea92cad52
Merge bitcoin/bitcoin#24356: refactor: replace CConnman::SocketEvents() with mockable Sock::WaitMany()
6e68ccbefe net: use Sock::WaitMany() instead of CConnman::SocketEvents() (Vasil Dimov)
ae263460ba net: introduce Sock::WaitMany() (Vasil Dimov)
cc74459768 net: also wait for exceptional events in Sock::Wait() (Vasil Dimov)

Pull request description:

  _This is a piece of #21878, chopped off to ease review._

  `Sock::Wait()` waits for IO events on one socket. Introduce a similar `virtual` method `WaitMany()` that waits simultaneously for IO events on more than one socket.

  Use `WaitMany()` instead of `CConnman::SocketEvents()` (and ditch the latter). Given that the former is a `virtual` method, it can be mocked by unit and fuzz tests. This will help to make bigger parts of `CConnman` testable (unit and fuzz).

ACKs for top commit:
  laanwj:
    Code review ACK 6e68ccbefe
  jonatack:
    re-ACK 6e68ccbefe per `git range-diff e18fd47 6747729 6e68ccb`, and verified rebase to master and debug build

Tree-SHA512: 917fb6ad880d64d3af1ebb301c06fbd01afd8ff043f49e4055a088ebed6affb7ffe1dcf59292d822f10de5f323b6d52d557cb081dd7434634995f9148efcf08f
2022-06-16 20:05:03 +02:00
laanwj
489b587669
Merge bitcoin/bitcoin#25215: [kernel 2d/n] Reduce CTxMemPool constructor call sites
d273e53b6e bench/rpc_mempool: Create ChainTestingSetup, use its CTxMemPool (Carl Dong)
020caba3df bench: Use existing CTxMemPool in TestingSetup (Carl Dong)
86e732def3 scripted-diff: test: Use CTxMemPool in TestingSetup (Carl Dong)
213457e170 test/policyestimator: Use ChainTestingSetup's CTxMemPool (Carl Dong)
319f0ceeeb rest/getutxos: Don't construct empty mempool (Carl Dong)
03574b956a tree-wide: clang-format CTxMemPool references (Carl Dong)

Pull request description:

  This is part of the `libbitcoinkernel` project: #24303, https://github.com/bitcoin/bitcoin/projects/18

  This PR reduces the number of call sites where we explicitly construct CTxMemPool. This is done in preparation for later PRs which decouple the mempool module from `ArgsManager`, eventually all of libbitcoinkernel will be decoupled from `ArgsManager`.

  The changes in this PR:

  - Allows us to have less code churn as we modify `CTxMemPool`'s constructor in later PRs
  - In many cases, we can make use of existing `CTxMemPool` instances, getting rid of extraneous constructions
  - In other cases, we construct a `ChainTestingSetup` and use the `CTxMemPool` there, so that we can rely on the logic in `setup_common` to set things up correctly

  ## Notes for Reviewers

  ### A note on using existing mempools

  When evaluating whether or not it's appropriate to use an existing mempool in a `*TestingSetup` struct, the key is to make sure that the mempool has the same lifetime as the `*TestingSetup` struct.

  Example 1: In [`src/fuzz/tx_pool.cpp`](b4f686952a/src/test/fuzz/tx_pool.cpp), the `TestingSetup` is initialized in `initialize_tx_pool` and lives as a static global, while the `CTxMemPool` is in the `tx_pool_standard` fuzz target, meaning that each time the `tx_pool_standard` fuzz target gets run, a new `CTxMemPool` is created. If we were to use the static global `TestingSetup`'s CTxMemPool we might run into problems since its `CTxMemPool` will carry state between subsequent runs. This is why we don't modify `src/fuzz/tx_pool.cpp` in this PR.

  Example 2: In [`src/bench/mempool_eviction.cpp`](b4f686952a/src/bench/mempool_eviction.cpp), we see that the `TestingSetup` is in the same scope as the constructed `CTxMemPool`, so it is safe to use its `CTxMemPool`.

  ### A note on checking `CTxMemPool` ctor call sites

  After the "tree-wide: clang-format CTxMemPool references" commit, you can find all `CTxMemPool` ctor call sites with the following command:

  ```sh
  git grep -E -e 'make_unique<CTxMemPool>' \
              -e '\bCTxMemPool\s+[^({;]+[({]' \
              -e '\bCTxMemPool\s+[^;]+;' \
              -e '\bnew\s+CTxMemPool\b'
  ```

  At the end of the PR, you will find that there are still quite a few call sites that we can seemingly get rid of:

  ```sh
  $ git grep -E -e 'make_unique<CTxMemPool>' -e '\bCTxMemPool\s+[^({;]+[({]' -e '\bCTxMemPool\s+[^;]+;' -e '\bnew\s+CTxMemPool\b'
  # rearranged for easier explication
  src/init.cpp:        node.mempool = std::make_unique<CTxMemPool>(node.fee_estimator.get(), mempool_check_ratio);
  src/test/util/setup_common.cpp:    m_node.mempool = std::make_unique<CTxMemPool>(m_node.fee_estimator.get(), 1);
  src/rpc/mining.cpp:        CTxMemPool empty_mempool;
  src/test/util/setup_common.cpp:    CTxMemPool empty_pool;
  src/bench/mempool_stress.cpp:    CTxMemPool pool;
  src/bench/mempool_stress.cpp:    CTxMemPool pool;
  src/test/fuzz/rbf.cpp:    CTxMemPool pool;
  src/test/fuzz/tx_pool.cpp:    CTxMemPool tx_pool_{/*estimator=*/nullptr, /*check_ratio=*/1};
  src/test/fuzz/tx_pool.cpp:    CTxMemPool tx_pool_{/*estimator=*/nullptr, /*check_ratio=*/1};
  src/test/fuzz/validation_load_mempool.cpp:    CTxMemPool pool{};
  src/txmempool.h:    /** Create a new CTxMemPool.
  ```
  Let's break them down one by one:

  ```
  src/init.cpp:        node.mempool = std::make_unique<CTxMemPool>(node.fee_estimator.get(), mempool_check_ratio);
  src/test/util/setup_common.cpp:    m_node.mempool = std::make_unique<CTxMemPool>(m_node.fee_estimator.get(), 1);
  ```

  Necessary

  -----

  ```
  src/rpc/mining.cpp:        CTxMemPool empty_mempool;
  src/test/util/setup_common.cpp:    CTxMemPool empty_pool;
  ```

  These are fixed in #25223 where we stop requiring the `BlockAssembler` to have a `CTxMemPool` if it's not going to consult it anyway (as is the case in these two call sites)

  -----

  ```
  src/bench/mempool_stress.cpp:    CTxMemPool pool;
  src/bench/mempool_stress.cpp:    CTxMemPool pool;
  ```

  Fixed in #24927.

  -----

  ```
  src/test/fuzz/rbf.cpp:    CTxMemPool pool;
  src/test/fuzz/tx_pool.cpp:    CTxMemPool tx_pool_{/*estimator=*/nullptr, /*check_ratio=*/1};
  src/test/fuzz/tx_pool.cpp:    CTxMemPool tx_pool_{/*estimator=*/nullptr, /*check_ratio=*/1};
  src/test/fuzz/validation_load_mempool.cpp:    CTxMemPool pool{};
  ```

  These are all cases where we don't want the `CTxMemPool` state to persist between runs, see the previous section "A note on using existing mempools"

  -----

  ```
  src/txmempool.h:    /** Create a new CTxMemPool.
  ```

  It's a comment (someone link me to a grep that understands syntax plz thx)

ACKs for top commit:
  laanwj:
    Code review ACK d273e53b6e

Tree-SHA512: c4ff3d23217a7cc4a7145defc7b901725073ef73bcac3a252ed75f672c87e98ca0368d1d8c3f606b5b49f641e7d8387d26ef802141b650b215876f191fb6d5f9
2022-06-16 19:49:34 +02:00
furszy
bda8ebe608
wallet: don't read db every time that a new WalletBatch is created
Better to perform the action only one time (during 'LoadWallet').
Where the value is being used.
2022-06-16 12:18:58 -03:00
MacroFake
8035b5c80d
Merge bitcoin/bitcoin#25369: Unsubtree Univalue
d873ff96e5 refactor: cleanups post unsubtree'ing univalue (fanquake)
e2aa7047f9 refactor: un-subtree univalue (fanquake)

Pull request description:

  At this point, maintaining Univalue as a subtree doesn’t serve much purpose, other than being an inconvenience for making changes to the code (along with polluting our repo with a number of files we don’t use). Our [Univalue fork](https://github.com/bitcoin-core/univalue-subtree) currently deviates from the [upstream API](https://github.com/jgarzik/univalue), and for some time has been marked as not-maintained for use by other projects (I'm not aware of any that use it). The upstream Univalue is not maintained, and has not been for some time. There are no new releases, bugs remain unfixed, and PR's we've upstreamed, https://github.com/jgarzik/univalue/pulls, are not being commented on/merged.

  Another substantial benefit of no-longer maintaining a subtree is removing the rather awkward work-flow currently required to make changes to the Univalue code, particularly breaking changes / introducing new features, e.g. https://github.com/bitcoin-core/univalue-subtree/pull/27. We need to dance around and merge changes to our fork, with a flag, then pull them down here, then switch to using the new code, then go back to our Univalue repo, and remove the old code / flag, then pull the repo down here again, and remove our usage of the flag. Quite the overcomplicated mess.

  With this PR I'm proposing we stop treating Univalue like a subtree, or upstream project/fork, and going forward, treat it as part of this codebase, which we can refactor directly (with pulls to this repo. Ideally, after this is merged, our univalue subtree repo could be marked as "archived". In this repo, I think there is a good chance that the Univalue code will ultimately be refactored away into "modern" C++, i.e using `std::variant` (at least one person has played around with doing this).

  Univalue history:
  - Subtree first introduced: https://github.com/bitcoin/bitcoin/pull/6637
  - `--system-univalue` option introduced: https://github.com/bitcoin/bitcoin/pull/7349
    Suggestion was to use system Univalue by default.
    This was pushed back on by contributors, as well as the [upstream Univalue](https://github.com/jgarzik/univalue) maintainer (jgarzik).
  - Our fork's README was updated to say `It is not maintained for usage by other projects. Notably, the API may break in non-backward-compatible ways.` : https://github.com/bitcoin-core/univalue-subtree/pull/17
  - Our fork README additionally updated to say `the API is broken in non-backward-compatible ways.` : https://github.com/bitcoin-core/univalue-subtree/pull/30
  - `--system-univalue` option removed: https://github.com/bitcoin/bitcoin/pull/22646
  - Univalue "subtree" removed: This PR.

  Guix Build (x86_64):
  ```bash
  06748985a9a386457d10a411b5afe1d59536e5653ec9c5bc8ac8410cd715d073  guix-build-d873ff96e51a/output/aarch64-linux-gnu/SHA256SUMS.part
  57d81891f6d4ae417dd3bcbfc90839600e103da9c7d7b09dbebb82f0119241f3  guix-build-d873ff96e51a/output/aarch64-linux-gnu/bitcoin-d873ff96e51a-aarch64-linux-gnu-debug.tar.gz
  7bb70d3b67253f5e8e5af8158bbf1b4b3e25e782f951d3defb7976534ae67d62  guix-build-d873ff96e51a/output/aarch64-linux-gnu/bitcoin-d873ff96e51a-aarch64-linux-gnu.tar.gz
  b1acb90877d6e3b8d4bd2d57103889e0474263e4153f302eba8cb304fd1aecd7  guix-build-d873ff96e51a/output/arm-linux-gnueabihf/SHA256SUMS.part
  91f9f65aebc131522cae5b523359c62e402a2c929670e1cca19d6a2760d29e04  guix-build-d873ff96e51a/output/arm-linux-gnueabihf/bitcoin-d873ff96e51a-arm-linux-gnueabihf-debug.tar.gz
  1fc3ed39bfc95592503b8dd11f468240deca4fb757f9adb08a0f07f5c0690837  guix-build-d873ff96e51a/output/arm-linux-gnueabihf/bitcoin-d873ff96e51a-arm-linux-gnueabihf.tar.gz
  a5cf5bd0ee0de92fb03f6bca91cfa6667ed77885112e71dd92a82bbd8670141e  guix-build-d873ff96e51a/output/arm64-apple-darwin/SHA256SUMS.part
  f6715399cebb5ac0a09f190fe805146c13d1e8eba57401541d0628da3badc588  guix-build-d873ff96e51a/output/arm64-apple-darwin/bitcoin-d873ff96e51a-arm64-apple-darwin-unsigned.dmg
  07cf82cab4e459ed4e862fc3a2903e49ac750adc6b6fe0534ec165f00e666230  guix-build-d873ff96e51a/output/arm64-apple-darwin/bitcoin-d873ff96e51a-arm64-apple-darwin-unsigned.tar.gz
  81bc076aa415183109e2848fa3cc0265b34f6af3e75b76bcbc6cff524db76a0f  guix-build-d873ff96e51a/output/arm64-apple-darwin/bitcoin-d873ff96e51a-arm64-apple-darwin.tar.gz
  8751b05a3395d668e31217c92cbce9c131aa3566b3784a7e3544adf34fc89fe8  guix-build-d873ff96e51a/output/dist-archive/bitcoin-d873ff96e51a.tar.gz
  526b7780a16a3de3c6006606d3d7a8c2ca565ef28669e2f6f303349a252e4977  guix-build-d873ff96e51a/output/powerpc64-linux-gnu/SHA256SUMS.part
  ff917a50d2b20d41a5954e1ba1e8fb39498a9c8867828483af3f501573148ede  guix-build-d873ff96e51a/output/powerpc64-linux-gnu/bitcoin-d873ff96e51a-powerpc64-linux-gnu-debug.tar.gz
  0311455c821ad392013fc3999a2b2d027fdb5c28e7eb6c3fea9cec29f3730d2d  guix-build-d873ff96e51a/output/powerpc64-linux-gnu/bitcoin-d873ff96e51a-powerpc64-linux-gnu.tar.gz
  983c2553990eb7cebb26e1a0a3e5a9308259dea60d0b64ab6782892d02a7abc1  guix-build-d873ff96e51a/output/powerpc64le-linux-gnu/SHA256SUMS.part
  aba604827d969348671ec3f36dbf37469292715d3f756a7f44a0a5243dbe02f3  guix-build-d873ff96e51a/output/powerpc64le-linux-gnu/bitcoin-d873ff96e51a-powerpc64le-linux-gnu-debug.tar.gz
  e450bd82020d5086f3bb0a23181263315cc05eaf6e5809d0a2115bff4e7ddb2e  guix-build-d873ff96e51a/output/powerpc64le-linux-gnu/bitcoin-d873ff96e51a-powerpc64le-linux-gnu.tar.gz
  476e8e2c80498b241af154abd9112bd2767110c0d6d7e9fa11761de716cb760f  guix-build-d873ff96e51a/output/riscv64-linux-gnu/SHA256SUMS.part
  a76435b3492efcd9af47ad652170605fad50691fd5aff2b46bce0bd08014879e  guix-build-d873ff96e51a/output/riscv64-linux-gnu/bitcoin-d873ff96e51a-riscv64-linux-gnu-debug.tar.gz
  83985d409cd90bf7120cf7902ee442595d28a1469b7c600b666ef901981e5190  guix-build-d873ff96e51a/output/riscv64-linux-gnu/bitcoin-d873ff96e51a-riscv64-linux-gnu.tar.gz
  61c89850244ddf5813ff80c242eff89925d30bccadfa5cb63e968c3af49eb964  guix-build-d873ff96e51a/output/x86_64-apple-darwin/SHA256SUMS.part
  cd219fab8918b061a342357d298aca0c044feb34c6d50a7851d5d3bf18cec267  guix-build-d873ff96e51a/output/x86_64-apple-darwin/bitcoin-d873ff96e51a-x86_64-apple-darwin-unsigned.dmg
  1170d3fdb199fbfca2c20b2a77cc81a6fe24b7e4973543a4461e887f14ac68e9  guix-build-d873ff96e51a/output/x86_64-apple-darwin/bitcoin-d873ff96e51a-x86_64-apple-darwin-unsigned.tar.gz
  71e93297ed8c581a7ed32a6948ef7b1ea2e7c43cb054181de3b5f604f7a2c28b  guix-build-d873ff96e51a/output/x86_64-apple-darwin/bitcoin-d873ff96e51a-x86_64-apple-darwin.tar.gz
  fc8b7b670de9d175775e73df47dc855581c873a9be4adf1d81a4dbb2831d5348  guix-build-d873ff96e51a/output/x86_64-linux-gnu/SHA256SUMS.part
  5703b02c2647f9997aa5ca12514d6a54b1eb2e29046223ca062383326b95894f  guix-build-d873ff96e51a/output/x86_64-linux-gnu/bitcoin-d873ff96e51a-x86_64-linux-gnu-debug.tar.gz
  bab4b932b83476cf6fc2e0b5bf0d2203287f7fd0d1a968e325f2edd5b1d8415b  guix-build-d873ff96e51a/output/x86_64-linux-gnu/bitcoin-d873ff96e51a-x86_64-linux-gnu.tar.gz
  5d180b0415fa8e825d46928c168cb1ae6e27016841b2ff8e190bf13879a5545c  guix-build-d873ff96e51a/output/x86_64-w64-mingw32/SHA256SUMS.part
  d469695a32f6414b25fef7b5fdfda4d854071450ba25148a1dce468114fa9057  guix-build-d873ff96e51a/output/x86_64-w64-mingw32/bitcoin-d873ff96e51a-win64-debug.zip
  2e7d4e533a5998863c115c586c61b75b4039cd329e12ed24cff78b7f16b6ea57  guix-build-d873ff96e51a/output/x86_64-w64-mingw32/bitcoin-d873ff96e51a-win64-setup-unsigned.exe
  3dabbd627b532beef57c3d4b5bd30c93c5ea74c492918484cf24685aca8d7bc4  guix-build-d873ff96e51a/output/x86_64-w64-mingw32/bitcoin-d873ff96e51a-win64-unsigned.tar.gz
  3a40660fba08f7632efd1f73c198f8298db33eab6ef5eaca88b997d95fc31f29  guix-build-d873ff96e51a/output/x86_64-w64-mingw32/bitcoin-d873ff96e51a-win64.zip
  ```

  Guix Build (arm64):
  ```bash
  0e764679199358fc321dcfcb58c6302e6518f55b3fd27bdd47f2da2a826ba16a  guix-build-d873ff96e51a/output/arm-linux-gnueabihf/SHA256SUMS.part
  5955d28e6d56e5a3297dab723b8478f1b0bb7f5b86476c581339122f34cc7f14  guix-build-d873ff96e51a/output/arm-linux-gnueabihf/bitcoin-d873ff96e51a-arm-linux-gnueabihf-debug.tar.gz
  49c68bc0066f709be68f1e5731425d51fb3cb8062a24aa9fa599987165759cad  guix-build-d873ff96e51a/output/arm-linux-gnueabihf/bitcoin-d873ff96e51a-arm-linux-gnueabihf.tar.gz
  ca678d4eb27c9fa3c527211c0ccb145322a15f327545b5c82f1d1b8d3c310e5a  guix-build-d873ff96e51a/output/arm64-apple-darwin/SHA256SUMS.part
  38366d7fbd769b426f1097e966abe39f01a7ce743f6af1cd0f228b1801d3c87f  guix-build-d873ff96e51a/output/arm64-apple-darwin/bitcoin-d873ff96e51a-arm64-apple-darwin-unsigned.dmg
  0c05dc9c17f5d8237b3e003c2e4c715455c3868bd4cd014e2a15ceb152b27b9c  guix-build-d873ff96e51a/output/arm64-apple-darwin/bitcoin-d873ff96e51a-arm64-apple-darwin-unsigned.tar.gz
  32676e1f9f07f3f77143f8b6038c943da6ba93b081232ec52c2ff940f9f7cc88  guix-build-d873ff96e51a/output/arm64-apple-darwin/bitcoin-d873ff96e51a-arm64-apple-darwin.tar.gz
  8751b05a3395d668e31217c92cbce9c131aa3566b3784a7e3544adf34fc89fe8  guix-build-d873ff96e51a/output/dist-archive/bitcoin-d873ff96e51a.tar.gz
  bdae66515060cab0b362784f0b2019b77da0435f1732d3c91fabcfb5e8c675f6  guix-build-d873ff96e51a/output/powerpc64-linux-gnu/SHA256SUMS.part
  8d837391310b4cdec2296a6e78a9f9b3ea2b3da7870881a5cedf86a3429c08c6  guix-build-d873ff96e51a/output/powerpc64-linux-gnu/bitcoin-d873ff96e51a-powerpc64-linux-gnu-debug.tar.gz
  efe825d6f36338bd4c0b427901b72d666f819858fb241a4211f03bbb738f6961  guix-build-d873ff96e51a/output/powerpc64-linux-gnu/bitcoin-d873ff96e51a-powerpc64-linux-gnu.tar.gz
  7494cf8c5f384ca3205b3ed44dd4c0edebcb9e0a6bf9c8e649fc6d99cc5a10b2  guix-build-d873ff96e51a/output/powerpc64le-linux-gnu/SHA256SUMS.part
  8ceeb21d7fce9e164dbb47b35d0551b59819075fc44dcea39603132340f80c41  guix-build-d873ff96e51a/output/powerpc64le-linux-gnu/bitcoin-d873ff96e51a-powerpc64le-linux-gnu-debug.tar.gz
  bfbbb20dc4e7b30444a52f5f57b5789b5d1edee80abdc8066129b48c59ee65c9  guix-build-d873ff96e51a/output/powerpc64le-linux-gnu/bitcoin-d873ff96e51a-powerpc64le-linux-gnu.tar.gz
  65d578b81b00a1032039362dc6be1a71368f390188e0f948829afd03b8858ed2  guix-build-d873ff96e51a/output/riscv64-linux-gnu/SHA256SUMS.part
  e5233d7e7a8832893ff414c78eb3d4bca3ae30d1a1f789a23419c6739b203022  guix-build-d873ff96e51a/output/riscv64-linux-gnu/bitcoin-d873ff96e51a-riscv64-linux-gnu-debug.tar.gz
  fb6d9f5a063dc7752fcc2acc95a0052322d7c8c86d2c6373e0ceb949dcf22f49  guix-build-d873ff96e51a/output/riscv64-linux-gnu/bitcoin-d873ff96e51a-riscv64-linux-gnu.tar.gz
  61c89850244ddf5813ff80c242eff89925d30bccadfa5cb63e968c3af49eb964  guix-build-d873ff96e51a/output/x86_64-apple-darwin/SHA256SUMS.part
  cd219fab8918b061a342357d298aca0c044feb34c6d50a7851d5d3bf18cec267  guix-build-d873ff96e51a/output/x86_64-apple-darwin/bitcoin-d873ff96e51a-x86_64-apple-darwin-unsigned.dmg
  1170d3fdb199fbfca2c20b2a77cc81a6fe24b7e4973543a4461e887f14ac68e9  guix-build-d873ff96e51a/output/x86_64-apple-darwin/bitcoin-d873ff96e51a-x86_64-apple-darwin-unsigned.tar.gz
  71e93297ed8c581a7ed32a6948ef7b1ea2e7c43cb054181de3b5f604f7a2c28b  guix-build-d873ff96e51a/output/x86_64-apple-darwin/bitcoin-d873ff96e51a-x86_64-apple-darwin.tar.gz
  46e9b067ec385ee14642aebc5ec09d7d2382e0204eeb17dc64587013eddd5dff  guix-build-d873ff96e51a/output/x86_64-linux-gnu/SHA256SUMS.part
  23278b19daac51e7df65b817b79fc93562d0f4eb193ef87472456f4bed1464d7  guix-build-d873ff96e51a/output/x86_64-linux-gnu/bitcoin-d873ff96e51a-x86_64-linux-gnu-debug.tar.gz
  4d5e5e23f089a59185f62faf367d8ca86476e406e6b7bbc9e8950cd89d94534d  guix-build-d873ff96e51a/output/x86_64-linux-gnu/bitcoin-d873ff96e51a-x86_64-linux-gnu.tar.gz
  eec8ab97ee9aceef8cb4e7cb5026225ffc5c7b8e8a6d376e8348020000e5af88  guix-build-d873ff96e51a/output/x86_64-w64-mingw32/SHA256SUMS.part
  a31819e67c373f30eafce8dbcb3d6d0c61d1dcf59c51023aa79321934f8a7d2a  guix-build-d873ff96e51a/output/x86_64-w64-mingw32/bitcoin-d873ff96e51a-win64-debug.zip
  2e7d4e533a5998863c115c586c61b75b4039cd329e12ed24cff78b7f16b6ea57  guix-build-d873ff96e51a/output/x86_64-w64-mingw32/bitcoin-d873ff96e51a-win64-setup-unsigned.exe
  3dabbd627b532beef57c3d4b5bd30c93c5ea74c492918484cf24685aca8d7bc4  guix-build-d873ff96e51a/output/x86_64-w64-mingw32/bitcoin-d873ff96e51a-win64-unsigned.tar.gz
  ec438531b4694913dbbf7c91920dcbd957354b164f807867c16a001898edf669  guix-build-d873ff96e51a/output/x86_64-w64-mingw32/bitcoin-d873ff96e51a-win64.zip
  ```

ACKs for top commit:
  laanwj:
    Code review ACK d873ff96e5
  MarcoFalke:
    re-ACK d873ff96e5 only changes: 📼

Tree-SHA512: fc7d781e8cc0fc0a0080eb4b5019e91c55275e087149ed3b5abc6b691170b0ab76f1dd3ce9bb8846eef023897a89123e14751ce8facf2a170829858199904bff
2022-06-16 13:47:01 +02:00
Carl Dong
d273e53b6e bench/rpc_mempool: Create ChainTestingSetup, use its CTxMemPool
This is correct because:

- The ChainTestingSetup is constructed before the call to bench.run(...)
- All the runs are performed on the same mempool
2022-06-15 17:28:55 -04:00
Carl Dong
020caba3df bench: Use existing CTxMemPool in TestingSetup 2022-06-15 17:28:55 -04:00
Carl Dong
86e732def3 scripted-diff: test: Use CTxMemPool in TestingSetup
After this commit, there should be no explicit instantiation of
CTxMemPool in src/test other than those in fuzz/ and setup_common

-BEGIN VERIFY SCRIPT-
find_regex="CTxMemPool\s+([^;({]+)(|\(\)|\{\});" \
    && git grep -l -E "$find_regex" -- src/test \
        | grep -v -e "^src/test/util/setup_common.cpp$" \
                  -e "^src/test/fuzz/" \
        | xargs sed -i -E "s@$find_regex@CTxMemPool\& \1 = *Assert(m_node.mempool);@g"
-END VERIFY SCRIPT-
2022-06-15 17:28:55 -04:00
Carl Dong
213457e170 test/policyestimator: Use ChainTestingSetup's CTxMemPool 2022-06-15 17:28:55 -04:00
Carl Dong
319f0ceeeb rest/getutxos: Don't construct empty mempool
...just don't try to consult it at all when fCheckMemPool is false
2022-06-15 17:28:55 -04:00
Andrew Chow
51eebe082d
Merge bitcoin/bitcoin#25368: doc: Update importaddress mention incompatibility with descriptor wallet
e3609cdc01 doc: Update importaddress mention incompatibility with descriptor wallet (BrokenProgrammer)

Pull request description:

  This is related to #25363 and offers a small update to the error messages from `EnsureLegacyScriptPubKeyMan` and `EnsureConstLegacyScriptPubKeyMan` to mention that they only are compatible with legacy wallets.

  The RPC documentation for `importaddress` is also updated to mention this as well as guide the user to the alternative `importdescriptors` for cases when using descriptor wallets.

  I'm thinking that we can introduce a "porting guide" document mentioned in #25363 in a separate PR since I would have to make myself more familiar with the subject before being able to tackle that.

ACKs for top commit:
  laanwj:
    Code review ACK e3609cdc01
  achow101:
    ACK e3609cdc01

Tree-SHA512: c7a924a7283fe59dc4e04c8c8fa034c15601f0b25eff09d975e98e2e8db5268ff470336b2d978d6916af9f782f9257b840d64bd15485b1742b4a8b8bfd0bb50f
2022-06-15 13:40:32 -04:00
Jadi
40566e21c0 If -prune=0 is set, Uncheck Prune on Intro page
If the bitcoin-qt is started with -prune=0 arg, On the Intro page,
the Prune Checkbox will be unchecked too, to prevent confusions.

refs: https://github.com/bitcoin/bitcoin/issues/25052

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2022-06-15 12:24:08 -04:00
Hennadii Stepanov
26ec2f2d6b
Merge bitcoin-core/gui#618: refactor: Add transactionoverviewwidget.cpp source file
a50e0b1bcb qt, refactor: Add `transactionoverviewwidget.cpp` source file (Hennadii Stepanov)

Pull request description:

  The `TransactionOverviewWidget` class was added in bitcoin-core/gui#176 as a header-only one.

  Apparently, in upcoming [CMake project](https://github.com/hebasto/bitcoin/pull/3), CMake [AUTOMOC](https://cmake.org/cmake/help/latest/prop_tgt/AUTOMOC.html) could be integrated better/simpler, if `QObject`-derived class implementation been placed into a source file.

  From our [Developer Notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#source-code-organization):
  > Implementation code should go into the `.cpp` file and not the `.h`, unless necessary due to template usage or when performance due to inlining is critical.

ACKs for top commit:
  Sjors:
    tACK a50e0b1bcb
  shaavan:
    ACK a50e0b1bcb

Tree-SHA512: 4707b6be1c5e794c4014475f826ac45ec833e472db11f12d29995f9c5a599ee98622ad54f0af72734b192144b626411c69acdafa0e6d1a390bdebfd7e570f377
2022-06-15 18:08:51 +02:00
fanquake
a7a36590f5
Merge bitcoin/bitcoin#25223: [kernel 2e/n] miner: Make mempool optional, stop constructing temporary empty mempools
0f1a259657 miner: Make mempool optional for BlockAssembler (Carl Dong)
cc5739b27d miner: Make UpdatePackagesForAdded static (Carl Dong)
f024578b3a miner: Absorb SkipMapTxEntry into addPackageTxs (Carl Dong)

Pull request description:

  This is part of the libbitcoinkernel project: #24303, https://github.com/bitcoin/bitcoin/projects/18

  This is **_NOT_** dependent on, but is a "companion-PR" to #25215.

  ### Abstract

  This PR removes the need to construct `BlockAssembler` with temporary, empty mempools in cases where we don't want to source transactions from the mempool (e.g. in `TestChain100Setup::CreateBlock` and `generateblock`). After this PR, `BlockAssembler` will accept a `CTxMemPool` pointer and handle the `nullptr` case instead of requiring a `CTxMemPool` reference.

  An overview of the changes is best seen in the changes in the header file:

  ```diff
  diff --git a/src/node/miner.h b/src/node/miner.h
  index 7cf8e3fb9e..7e9f503602 100644
  --- a/src/node/miner.h
  +++ b/src/node/miner.h
  @@ -147,7 +147,7 @@ private:
       int64_t m_lock_time_cutoff;

       const CChainParams& chainparams;
  -    const CTxMemPool& m_mempool;
  +    const CTxMemPool* m_mempool;
       CChainState& m_chainstate;

   public:
  @@ -157,8 +157,8 @@ public:
           CFeeRate blockMinFeeRate;
       };

  -    explicit BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool);
  -    explicit BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool, const Options& options);
  +    explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool);
  +    explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options);

       /** Construct a new block template with coinbase to scriptPubKeyIn */
       std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn);
  @@ -177,7 +177,7 @@ private:
       /** Add transactions based on feerate including unconfirmed ancestors
         * Increments nPackagesSelected / nDescendantsUpdated with corresponding
         * statistics from the package selection (for logging statistics). */
  -    void addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
  +    void addPackageTxs(const CTxMemPool& mempool, int& nPackagesSelected, int& nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs);

       // helper functions for addPackageTxs()
       /** Remove confirmed (inBlock) entries from given set */
  @@ -189,15 +189,8 @@ private:
         * These checks should always succeed, and they're here
         * only as an extra check in case of suboptimal node configuration */
       bool TestPackageTransactions(const CTxMemPool::setEntries& package) const;
  -    /** Return true if given transaction from mapTx has already been evaluated,
  -      * or if the transaction's cached data in mapTx is incorrect. */
  -    bool SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
       /** Sort the package in an order that is valid to appear in a block */
       void SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries);
  -    /** Add descendants of given transactions to mapModifiedTx with ancestor
  -      * state updated assuming given transactions are inBlock. Returns number
  -      * of updated descendants. */
  -    int UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded, indexed_modified_transaction_set& mapModifiedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
   };

   int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
  ```

  ### Alternatives

  Aside from approach in this current PR, we can also take the approach of moving the `CTxMemPool*` argument from the `BlockAssembler` constructor to `BlockAssembler::CreateNewBlock`, since that's where it's needed anyway. I did not push this approach because it requires quite a lot of call sites to be changed. However, I do have it coded up and can do that if people express a strong preference. This would look something like:

  ```
  BlockAssembler::BlockAssembler(CChainState& chainstate, const Options& options);
  BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, const CTxMemPool* maybe_mempool);
  ```

  ### Future work

  Although wholly out of scope for this PR, we could potentially refine the `BlockAssembler` interface further, so that we have:

  ```
  BlockAssembler::BlockAssembler(CChainState& chainstate, const Options& options);
  BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, std::vector<CTransaction>& txs);
  BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, const CTxMemPool& mempool);
  ```

  Whereby `TestChain100Setup::CreateBlock` and `generateblock` would call the `BlockAssembler::CreateNewBlock` that takes in `CTransaction`s and we can potentially remove `RegenerateCommitments` altogether. All other callers can use the `CTxMemPool` version.

ACKs for top commit:
  glozow:
    ACK 0f1a259657
  laanwj:
    Code review ACK 0f1a259657
  MarcoFalke:
    ACK 0f1a259657 🐊

Tree-SHA512: 2b4b1dbb43d85719f241ad1f19ceb7fc50cf764721da425a3d1ff71bd16328c4f86acff22e565bc9abee770d3ac8827a6676b66daa93dbf42dd817ad929e9448
2022-06-15 16:40:48 +01:00
fanquake
d873ff96e5
refactor: cleanups post unsubtree'ing univalue
Mostly changes to remove src/univalue exceptions from the various linters,
and the required code changes to make them happy. As well as minor doc
changes.
2022-06-15 12:56:44 +01:00
fanquake
e2aa7047f9
refactor: un-subtree univalue
Remove all the files we don't use.
This should not change behavior, or anything at all, as none of these
files are currently used in our build system.
2022-06-15 09:32:41 +01:00
MacroFake
fa07ee165e
Merge bitcoin/bitcoin#25339: RPC/blockchain: Elaborate on scantxoutset documentation
7862c4ac4e RPC/blockchain: Reorder result documentation for scantxoutset (Luke Dashjr)
98718d03be scripted-diff: RPC/blockchain: Lowercase "when" in scantxoutset documentation (Luke Dashjr)
b283e4d823 RPC/blockchain: Elaborate on scantxoutset documentation (Luke Dashjr)

Pull request description:

  Minor doc improvements

ACKs for top commit:
  achow101:
    ACK 7862c4ac4e

Tree-SHA512: a8b16a9b77c3ca216ce2556c26d6a049b12f73500bdb35c172432409b3b9321cc24a08daca1210926e0f75674b2e680e850637700c516c195fb75ce6555c17c4
2022-06-15 08:58:58 +02:00
MacroFake
ede9089096
Merge bitcoin/bitcoin#25156: refactor: Introduce PeerManagerImpl::RejectIncomingTxs
fafddafc2c refactor: Introduce PeerManagerImpl::RejectIncomingTxs (MacroFake)

Pull request description:

  Currently there are some confusions in net_processing:

  * There is confusion between `-blocksonly mode` and `block-relay-only`, so adjust all comments to use the same nomenclature.
  * Whether to disconnect peers for providing invs/txs is implemented differently. For example, it seems a bit confusing to disconnect `block-relay-only` peers with `relay` permission when they send a tx message, but not when they send an inv message. Also, keeping track of their inv announcements seems both wasteful and confusing, as it does nothing. This isn't possible in practice, as outbound connections do not have permissions assigned, but sees fragile to rely on. Especially in light of proposed changes to make that possible: https://github.com/bitcoin/bitcoin/pull/17167

ACKs for top commit:
  MarcoFalke:
    Should be trivial to re-ACK with `git range-diff bitcoin-core/master  fa2b5fe0c1 fafddafc2c`.
  jnewbery:
    Code review ACK fafddafc2c
  mzumsande:
    ACK fafddafc2c

Tree-SHA512: 73bf91afe93be619169cfbf3bf80cb08a5e6f73df4e0318b86817bd4d45f67408ea85998855992281d2decc9d24f7d75cffb83a0518d670090907309df8a3490
2022-06-15 08:14:02 +02:00
MacroFake
38c63e3683
Merge bitcoin/bitcoin#25338: scripted-diff: Avoid incompatibility with CMake AUTOUIC feature
018d70b587 scripted-diff: Avoid incompatibility with CMake AUTOUIC feature (Hennadii Stepanov)

Pull request description:

  Working on [migration](https://github.com/hebasto/bitcoin/pull/3) from Autotools to CMake build system, I found that our current code base needs to be adjusted.

  CMake [allows](https://cmake.org/cmake/help/latest/prop_tgt/AUTOUIC.html) to
  > handle the Qt `uic` code generator automatically

  When using this feature, statements like `#include "ui_<ui_base>.h"` are processed in a special way.

  The `node/ui_interface.h` unintentionally breaks this feature. Of course, it is possible to provide a list of source files to be excluded from `AUTOUIC`. But, unfortunately, this approach does not work for the `qt/sendcoinsdialog.cpp` source file, where there are both b71d37da2c/src/qt/sendcoinsdialog.cpp (L10) and b71d37da2c/src/qt/sendcoinsdialog.cpp (L24)

ACKs for top commit:
  MarcoFalke:
    cr ACK 018d70b587
  ryanofsky:
    Code review ACK 018d70b587
  furszy:
    Code review ACK 018d70b5

Tree-SHA512: 4fc83f2e5a82c8ab15c3c3d68f48b9863c47b96c0a66b6276b9b4dfc6063abffd73a16382acfe116553487b3ac697dbde2d9ada1b92010c5d8f8c6aa06f56428
2022-06-15 08:10:38 +02:00
BrokenProgrammer
e3609cdc01 doc: Update importaddress mention incompatibility with descriptor wallet 2022-06-14 20:54:45 +02:00
Hennadii Stepanov
a50e0b1bcb
qt, refactor: Add transactionoverviewwidget.cpp source file
Required for better/simpler interaction with CMake AUTOMOC.
2022-06-14 16:55:22 +02:00
furszy
192eb1e61c
refactor: getAddress don't access m_address_book, use FindAddressEntry function 2022-06-14 11:51:37 -03:00
laanwj
9e4fbebcc8
Merge bitcoin/bitcoin#25306: logging: add LogPrintfCategory to log unconditionally with category
ecff20db28 logging: use LogPrintfCategory rather than a manual category (Jon Atack)
eb8aab759f logging: add LogPrintfCategory to log unconditionally with category (Jon Atack)

Pull request description:

  These are the next two commits from #25203.

  - Add `LogPrintfCategory` to log unconditionally while prefixing the output with the passed category name. Add documentation and a unit test, and update the `lint-logs.py` and `lint-format-strings.py` scripts.

  - Replace the log messages that manually print a category, with `LogPrintfCategory`. In upcoming commits, it will likely be used in many other cases, such as to replace `LogPrintf` where it makes sense.

ACKs for top commit:
  klementtan:
    Code Review ACK ecff20db28
  laanwj:
    Code review ACK ecff20db28
  brunoerg:
    ACK ecff20db28

Tree-SHA512: ad3a82835254f7606efcd14b88f3d9072f1eb9b25db1321ed38ef6a4ec60efd555d78f5e19d93736f2f8500251d06f8beee9d694a153f24bf5cce3590a2a45a5
2022-06-14 11:46:32 +02:00
laanwj
1557014378
Merge bitcoin/bitcoin#25332: build: test for timingsafe_bcmp
491bb14c0c build: test for timingsafe_bcmp (fanquake)

Pull request description:

  Code introduced in #15649 added usage of [`timingsafe_bcmp()`](https://man.openbsd.org/timingsafe_bcmp.3), if
  available, otherwise falling back to our own implementation. However
  the relevant build system check was never added, so currently, we'll
  always just use our implementation, as `HAVE_TIMINGSAFE_BCMP` will never
  be defined.

  Add the check for `timingsafe_bcmp`. Note that as far as I'm aware, it's
  only available on OpenBSD.

  c3daa321f9/src/crypto/chacha_poly_aead.cpp (L16-L28)

  Guix Build (x86_64):
  ```bash
  0a890839e3de040e084d4df6aeabd924f6c6b04e724d7d2a87ef366d5493ac94  guix-build-491bb14c0c9c/output/aarch64-linux-gnu/SHA256SUMS.part
  fd5e1c4531f1739d63e8d552495c24c044ce9ddd34a424d6da1317830e625527  guix-build-491bb14c0c9c/output/aarch64-linux-gnu/bitcoin-491bb14c0c9c-aarch64-linux-gnu-debug.tar.gz
  551f58234ba5acf5c5125df85fccb49f8536399d2a1b7126848e4709b7edb61e  guix-build-491bb14c0c9c/output/aarch64-linux-gnu/bitcoin-491bb14c0c9c-aarch64-linux-gnu.tar.gz
  5a6f7630d36af7e4317f660232c52a5c8c983b1999f57e176a628d83a5eb7b4a  guix-build-491bb14c0c9c/output/arm-linux-gnueabihf/SHA256SUMS.part
  d1eba598d69498e899663cfcba295747ac5808218157adaca79d45459aac8ecf  guix-build-491bb14c0c9c/output/arm-linux-gnueabihf/bitcoin-491bb14c0c9c-arm-linux-gnueabihf-debug.tar.gz
  1e2559a99b89770501308416edc6cfeec94bfea9e9cadb6b64a4df7a487350d1  guix-build-491bb14c0c9c/output/arm-linux-gnueabihf/bitcoin-491bb14c0c9c-arm-linux-gnueabihf.tar.gz
  bc961b8b930df8123a6cad1c55f250658ea600d4a617ec4fceec2bfc28ec779f  guix-build-491bb14c0c9c/output/arm64-apple-darwin/SHA256SUMS.part
  f65118d324a8c1a3d80190dc0a80a2175b116a5ef5b0d977e8ffeaa7a8114851  guix-build-491bb14c0c9c/output/arm64-apple-darwin/bitcoin-491bb14c0c9c-arm64-apple-darwin-unsigned.dmg
  d27cd6193b1b5ecdab50d1fe2b4c3d0bfba04813506ecf63e27a6e9edb32913e  guix-build-491bb14c0c9c/output/arm64-apple-darwin/bitcoin-491bb14c0c9c-arm64-apple-darwin-unsigned.tar.gz
  76fc93a9c11909a826c9bd310ae4a70dc2083b96540c875d9cfb3b31bb86dd3e  guix-build-491bb14c0c9c/output/arm64-apple-darwin/bitcoin-491bb14c0c9c-arm64-apple-darwin.tar.gz
  43f157994432c16cfd481de2ce4894f7c241a0b87ce3797ffc492e219ed00c19  guix-build-491bb14c0c9c/output/dist-archive/bitcoin-491bb14c0c9c.tar.gz
  d04bc01a7b207e2d9e833ef4399d5daa789f5d7476df3915f426ea1c71578cb5  guix-build-491bb14c0c9c/output/powerpc64-linux-gnu/SHA256SUMS.part
  d815ab7157ca87a51c0c08907ba76f6bcec11cf9c0db77c2fd2885bf78796f97  guix-build-491bb14c0c9c/output/powerpc64-linux-gnu/bitcoin-491bb14c0c9c-powerpc64-linux-gnu-debug.tar.gz
  9f912bedf53d6921cf10f48569fb74ef4f42c8571fb976b50e67a64f6754833c  guix-build-491bb14c0c9c/output/powerpc64-linux-gnu/bitcoin-491bb14c0c9c-powerpc64-linux-gnu.tar.gz
  0651ed89f9a7cd4a4a196a48b330aec82f6ca1df5d842e6da863a87ae69f57f4  guix-build-491bb14c0c9c/output/powerpc64le-linux-gnu/SHA256SUMS.part
  4c5f1ea788580a99318dc91cb3ac51f11829163a5821a01d90459911b0ff791d  guix-build-491bb14c0c9c/output/powerpc64le-linux-gnu/bitcoin-491bb14c0c9c-powerpc64le-linux-gnu-debug.tar.gz
  61c91db6b7f34d43292b6e0c0a1e4bd5f6e2d532df835410daca337cf94c66af  guix-build-491bb14c0c9c/output/powerpc64le-linux-gnu/bitcoin-491bb14c0c9c-powerpc64le-linux-gnu.tar.gz
  be4d94e812c02a3955343d7a92a26deff9ced37aada049fd328118e01a8e3c53  guix-build-491bb14c0c9c/output/riscv64-linux-gnu/SHA256SUMS.part
  d73589e28311c8b442bb873d233181988f79d728965ccef395b19683b78203e9  guix-build-491bb14c0c9c/output/riscv64-linux-gnu/bitcoin-491bb14c0c9c-riscv64-linux-gnu-debug.tar.gz
  a1b15c96fcc936928aa183e7b06552c68a2dd5d178122394c3ed2cbd3f07ab2f  guix-build-491bb14c0c9c/output/riscv64-linux-gnu/bitcoin-491bb14c0c9c-riscv64-linux-gnu.tar.gz
  2d608c6b79be12cdc179e5e6414ea21d06d8b2816e098fbdb4e929b8f9338fa5  guix-build-491bb14c0c9c/output/x86_64-apple-darwin/SHA256SUMS.part
  ce11298ab92f388bd43ff2c6cb8c07c777dab44f0f6ea93b909805552bafd20d  guix-build-491bb14c0c9c/output/x86_64-apple-darwin/bitcoin-491bb14c0c9c-x86_64-apple-darwin-unsigned.dmg
  5d0626fc72d473157376efe0736f4d2b5836a5394a4869368bc65bf9d264d238  guix-build-491bb14c0c9c/output/x86_64-apple-darwin/bitcoin-491bb14c0c9c-x86_64-apple-darwin-unsigned.tar.gz
  d9f250bb45c4663f8160b7d22c1ccde8f1abad62dc6667e01fe71d577f00e9f9  guix-build-491bb14c0c9c/output/x86_64-apple-darwin/bitcoin-491bb14c0c9c-x86_64-apple-darwin.tar.gz
  72b3afe2d6124598eddbeed8d0799a8bd23536b4a3e4611162094601c75b923e  guix-build-491bb14c0c9c/output/x86_64-linux-gnu/SHA256SUMS.part
  eef6c0928762c77a23b485b55c350660b111ffdf3446825648d7da05e5e681eb  guix-build-491bb14c0c9c/output/x86_64-linux-gnu/bitcoin-491bb14c0c9c-x86_64-linux-gnu-debug.tar.gz
  a130d87e851f0192bf89dd5ecbe52d63231ce5dbbf584d1e4fb33a36ebb8bf7a  guix-build-491bb14c0c9c/output/x86_64-linux-gnu/bitcoin-491bb14c0c9c-x86_64-linux-gnu.tar.gz
  0f00372e30ea12ca9d16d70c4905b6b8492464987bb6b272ed4f9a945941d6b9  guix-build-491bb14c0c9c/output/x86_64-w64-mingw32/SHA256SUMS.part
  2852dff8d38ef6eee759bf9fe717a4288db46c300f061acb3212cd1499607d8d  guix-build-491bb14c0c9c/output/x86_64-w64-mingw32/bitcoin-491bb14c0c9c-win64-debug.zip
  ef087e9d6160e183f6ef6d64f9141b499e893d88705be5d1426ced6c49531c18  guix-build-491bb14c0c9c/output/x86_64-w64-mingw32/bitcoin-491bb14c0c9c-win64-setup-unsigned.exe
  79392686b9f5781275e346badf8d7166baa0b4f2c0037ddd6df0b4bc23eaedf6  guix-build-491bb14c0c9c/output/x86_64-w64-mingw32/bitcoin-491bb14c0c9c-win64-unsigned.tar.gz
  da8c9f6922bdab660dfbd757ec89ce7a2493bf1d02e32172b77c1a21b09daaa9  guix-build-491bb14c0c9c/output/x86_64-w64-mingw32/bitcoin-491bb14c0c9c-win64.zip
  ```

  Guix Build (arm64):
  ```bash
  ff7afe1f43ac18df89cf1932568b0713f6f22fd2b449a4a87f9aebf404449897  guix-build-491bb14c0c9c/output/arm-linux-gnueabihf/SHA256SUMS.part
  5e727cc3273615e6f75c6e15bc004946ab7494ee169ecf830f23290cf6f5c3de  guix-build-491bb14c0c9c/output/arm-linux-gnueabihf/bitcoin-491bb14c0c9c-arm-linux-gnueabihf-debug.tar.gz
  4aff5487b129dc483780646994246890a5917c8956980ec52682accfe5a0d02e  guix-build-491bb14c0c9c/output/arm-linux-gnueabihf/bitcoin-491bb14c0c9c-arm-linux-gnueabihf.tar.gz
  cabfeb29771017dfde35a1c8f08c7066255ad84a05d6d565cfcf852a5d869d16  guix-build-491bb14c0c9c/output/arm64-apple-darwin/SHA256SUMS.part
  99360c7135967e1d9709830abcc8f5b6ebc7bc37c5be0eac1ddebe0ce5dbe344  guix-build-491bb14c0c9c/output/arm64-apple-darwin/bitcoin-491bb14c0c9c-arm64-apple-darwin-unsigned.dmg
  9caa58d1efe18c7ad68fec2a71455ade61939f32ae2da0b0457b459204227046  guix-build-491bb14c0c9c/output/arm64-apple-darwin/bitcoin-491bb14c0c9c-arm64-apple-darwin-unsigned.tar.gz
  d9b0ad26346869aa6a4229aa77796535f68880fc50f8b7b7a4297f2e14d2e3ad  guix-build-491bb14c0c9c/output/arm64-apple-darwin/bitcoin-491bb14c0c9c-arm64-apple-darwin.tar.gz
  43f157994432c16cfd481de2ce4894f7c241a0b87ce3797ffc492e219ed00c19  guix-build-491bb14c0c9c/output/dist-archive/bitcoin-491bb14c0c9c.tar.gz
  e2f95f50ae973cef815731485be6b917f39eea92ef4e93fa63aa1ad6cb52a3c9  guix-build-491bb14c0c9c/output/powerpc64-linux-gnu/SHA256SUMS.part
  452f3091a1e841920e958f14f1650e94b3a61cb430cb99930fb5941d8a8aad3d  guix-build-491bb14c0c9c/output/powerpc64-linux-gnu/bitcoin-491bb14c0c9c-powerpc64-linux-gnu-debug.tar.gz
  a371cee3dae3d5cf5ca792b58a1bb492a6a6147e0b515e69869d3543edbeaea5  guix-build-491bb14c0c9c/output/powerpc64-linux-gnu/bitcoin-491bb14c0c9c-powerpc64-linux-gnu.tar.gz
  89153f4b6a3bc6d47787c4d63b57e1dade8116822abb547fc1759c84e6ff6fa2  guix-build-491bb14c0c9c/output/powerpc64le-linux-gnu/SHA256SUMS.part
  9f51353abe7b6154a48da5db3fce29d2dac1dbe9a6c78aade1b9e1b6b12370fa  guix-build-491bb14c0c9c/output/powerpc64le-linux-gnu/bitcoin-491bb14c0c9c-powerpc64le-linux-gnu-debug.tar.gz
  25b21eb2d8e3982dac5e1510b78339b7c4bddf164b986c929036369e403ddadd  guix-build-491bb14c0c9c/output/powerpc64le-linux-gnu/bitcoin-491bb14c0c9c-powerpc64le-linux-gnu.tar.gz
  92c4c404f7355897bca4ba7e38a908828da73617cac7b0fbd89952ce20859d83  guix-build-491bb14c0c9c/output/riscv64-linux-gnu/SHA256SUMS.part
  230361b5a493b3ac17780b3d5496cc10a37d3345b96874b04092c06aab36cb0d  guix-build-491bb14c0c9c/output/riscv64-linux-gnu/bitcoin-491bb14c0c9c-riscv64-linux-gnu-debug.tar.gz
  d8110e6d738a40ccd076cbd286557931b2a433e27c8defcc496ac56f60fe5327  guix-build-491bb14c0c9c/output/riscv64-linux-gnu/bitcoin-491bb14c0c9c-riscv64-linux-gnu.tar.gz
  2d608c6b79be12cdc179e5e6414ea21d06d8b2816e098fbdb4e929b8f9338fa5  guix-build-491bb14c0c9c/output/x86_64-apple-darwin/SHA256SUMS.part
  ce11298ab92f388bd43ff2c6cb8c07c777dab44f0f6ea93b909805552bafd20d  guix-build-491bb14c0c9c/output/x86_64-apple-darwin/bitcoin-491bb14c0c9c-x86_64-apple-darwin-unsigned.dmg
  5d0626fc72d473157376efe0736f4d2b5836a5394a4869368bc65bf9d264d238  guix-build-491bb14c0c9c/output/x86_64-apple-darwin/bitcoin-491bb14c0c9c-x86_64-apple-darwin-unsigned.tar.gz
  d9f250bb45c4663f8160b7d22c1ccde8f1abad62dc6667e01fe71d577f00e9f9  guix-build-491bb14c0c9c/output/x86_64-apple-darwin/bitcoin-491bb14c0c9c-x86_64-apple-darwin.tar.gz
  de7a52a67f243b6db1086c2ab2cc3f01784d38b43b7aaf795b7713c33799ab62  guix-build-491bb14c0c9c/output/x86_64-linux-gnu/SHA256SUMS.part
  88228ef3007e81ade481d0c3fa757ac3ae86bda50aeef2631335c5d54fb4194c  guix-build-491bb14c0c9c/output/x86_64-linux-gnu/bitcoin-491bb14c0c9c-x86_64-linux-gnu-debug.tar.gz
  b1f2ddf50658f4d1bd0667cc16502f9a45d9e0eef4c1d103cd7780cebfc2766d  guix-build-491bb14c0c9c/output/x86_64-linux-gnu/bitcoin-491bb14c0c9c-x86_64-linux-gnu.tar.gz
  f0cc08231ed964fcb4f2c5a697c52160dad8ed374f8d9537eb7f2ca9f47e7b2c  guix-build-491bb14c0c9c/output/x86_64-w64-mingw32/SHA256SUMS.part
  d9c49c031bde4f80e63955fdeb14a7fb8f74a27d09bcf01881648917df10a836  guix-build-491bb14c0c9c/output/x86_64-w64-mingw32/bitcoin-491bb14c0c9c-win64-debug.zip
  ef087e9d6160e183f6ef6d64f9141b499e893d88705be5d1426ced6c49531c18  guix-build-491bb14c0c9c/output/x86_64-w64-mingw32/bitcoin-491bb14c0c9c-win64-setup-unsigned.exe
  79392686b9f5781275e346badf8d7166baa0b4f2c0037ddd6df0b4bc23eaedf6  guix-build-491bb14c0c9c/output/x86_64-w64-mingw32/bitcoin-491bb14c0c9c-win64-unsigned.tar.gz
  1d76ceae8c3feef573d4e60fe6c7be5f3bea4afd3994ddc16759d8b381767015  guix-build-491bb14c0c9c/output/x86_64-w64-mingw32/bitcoin-491bb14c0c9c-win64.zip
  ```

ACKs for top commit:
  laanwj:
    Code review ACK 491bb14c0c
  theStack:
    ACK 491bb14c0c

Tree-SHA512: 50d273706e92016783f6a9d552f56b703c3c26ec2f0fafb9a0d1c1047456eee7c08e76ebc57077d2ecf95aaf5a3804c88a629a2e02a48c8be91b87ffa44cdb3e
2022-06-14 10:39:31 +02:00
Hennadii Stepanov
018d70b587
scripted-diff: Avoid incompatibility with CMake AUTOUIC feature
-BEGIN VERIFY SCRIPT-
sed -i "s|node/ui_interface|node/interface_ui|g" $(git grep -l "node/ui_interface" ./src)
git mv src/node/ui_interface.cpp src/node/interface_ui.cpp
git mv src/node/ui_interface.h src/node/interface_ui.h
sed -i "s|BITCOIN_NODE_UI_INTERFACE_H|BITCOIN_NODE_INTERFACE_UI_H|g" src/node/interface_ui.h
-END VERIFY SCRIPT-
2022-06-14 10:38:51 +02:00
laanwj
c5fbcf5f8d
Merge bitcoin/bitcoin#25320: util: modify Win32LockedPageAllocator to query windows for limit.
1cb42aeda3 util: modify Win32LockedPageAllocator to query windows for limit (Oskar Mendel)

Pull request description:

  This PR resolves a todo within the Win32LockedPageAllocator: `// TODO is there a limit on Windows, how to get it?`.
  The idea is to use the Windows API to get the limits like the posix based allocator does with `getrlimit`.

  I use [GetProcessWorkingSetSize](https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-getprocessworkingsetsize) to perform this task and fallback to `return std::numeric_limits<size_t>::max();` just like the posix implementation does.

ACKs for top commit:
  sipsorcery:
    tACK 1cb42aeda3.

Tree-SHA512: 7bdd8a57a4e64ee59d752417a519656e03526878462060753be4dce481eff4889fb5edc1bdbd575b707d9b2dfe255c87da9ef67baac97de9ac5e70a04c852081
2022-06-14 09:46:28 +02:00
MacroFake
fafddafc2c
refactor: Introduce PeerManagerImpl::RejectIncomingTxs
Currently there are some confusions in net_processing:

* There is confusion between `-blocksonly mode` and `block-relay-only`,
  so adjust all comments to use the same nomenclature.
* Whether to disconnect peers for providing invs/txs is implemented
  differently. For example, it seems a bit confusing to disconnect
  `block-relay-only` peers with `relay` permission when they send a tx
  message, but not when they send an inv message. Also, keeping track of
  their inv announcements seems both wasteful and confusing, as it does
  nothing. This isn't possible in practice, as outbound connections do
  not have permissions assigned, but sees fragile to rely on. Especially
  in light of proposed changes to make that possible:
  https://github.com/bitcoin/bitcoin/pull/17167
2022-06-14 08:39:55 +02:00
MacroFake
b91055ea55
Merge bitcoin/bitcoin#25251: Consolidate Windows ASLR workarounds for upstream secp256k1 changes
c41bfd1070 Squashed 'src/secp256k1/' changes from 8746600ee..44c2452fd (fanquake)
fbae8c59a2 compat: Consolidate mingw-w64 ASLR workaround for upstream libsecp changes (fanquake)

Pull request description:

  #18702 added a work around for `bitcoin-cli.exe`, to fix ASLR on Windows. ASLR was functioning for the rest of our binaries, mostly by accident, because:
  > [All other Windows binaries that we distribute (bitcoind, bitcoin-qt,
  bitcoin-wallet, bitcoin-tx and test_bitcoin) do not suffer this issue,
  and currently having working ASLR. This is due to them exporting
  (inadvertent or not) libsecp256k1 symbols, and, as a result, the .reloc
  section is not stripped by ld.](https://github.com/bitcoin/bitcoin/pull/18702)

  Upstream, libsecp256k1 has recently made a change to [no-longer export symbols in static libraries](https://github.com/bitcoin-core/secp256k1/pull/1105) (see related discussion in #25008). This would mean that on the next subtree update, anyone building using an older binutils (< 2.36) would be (silently) producing Windows binaries with non-functioning ASLR. Our release binaries would not be affected, as in our Guix environment we currently use binutils 2.37.

  To prevent users building with older binutils from silently losing ASLR on Windows, this PR applies our work around (export `main`) to the rest of our binaries, and updates the associated documentation to mention the affected binutils versions, so we know when it can be dropped.

  I've included both the libsecp256k1 subtree update, and the ASLR related changes in this PR. Happy to split the changes up if reviewers would prefer.

  Guix Build (x86_64):
  ```bash
  24fa1053fa3d310c4274f0700ac36f3c6e5b4486dc7f1aa7b2a5ded6937cf2b6  guix-build-913b1f2a5eb2/output/aarch64-linux-gnu/SHA256SUMS.part
  96c4150f93c1356dc02f3d383699bcd856da7f769344606324fdc111fbfa8031  guix-build-913b1f2a5eb2/output/aarch64-linux-gnu/bitcoin-913b1f2a5eb2-aarch64-linux-gnu-debug.tar.gz
  5e4adcaddf20a33cd4803e5a10f9a0653bcd40b1dfc7b680a741a17047103948  guix-build-913b1f2a5eb2/output/aarch64-linux-gnu/bitcoin-913b1f2a5eb2-aarch64-linux-gnu.tar.gz
  adfdac8fef797b13d845c13ab682611d0cc49a9772c2bd40f7aa6dbb1b4f11a8  guix-build-913b1f2a5eb2/output/arm-linux-gnueabihf/SHA256SUMS.part
  d51849bf907eecb168066a208b702314779fc12ae6fcaa8b5c2c3497e91820b9  guix-build-913b1f2a5eb2/output/arm-linux-gnueabihf/bitcoin-913b1f2a5eb2-arm-linux-gnueabihf-debug.tar.gz
  ca33ebed13316410d6d79e2db06f9bce8839fbc7216a5bc01a06745b2e470c2e  guix-build-913b1f2a5eb2/output/arm-linux-gnueabihf/bitcoin-913b1f2a5eb2-arm-linux-gnueabihf.tar.gz
  799fd15fa1e53d773a5ce391b7059920b54680591ee76bdc56bc7485a12d2af6  guix-build-913b1f2a5eb2/output/arm64-apple-darwin/SHA256SUMS.part
  0122eb5fdd4cce7077ee1a2bba8c5bd3557c1d3f12f2f2aad7216de33bea213e  guix-build-913b1f2a5eb2/output/arm64-apple-darwin/bitcoin-913b1f2a5eb2-arm64-apple-darwin-unsigned.dmg
  3a630cc96bf9a43cbb89976aabdddb7a9069f74320277a499f3bbb96526d9c5d  guix-build-913b1f2a5eb2/output/arm64-apple-darwin/bitcoin-913b1f2a5eb2-arm64-apple-darwin-unsigned.tar.gz
  e2530bab501750fd3d60776ba077bc4a8b145cc95e3a77105d86b388a1d961e1  guix-build-913b1f2a5eb2/output/arm64-apple-darwin/bitcoin-913b1f2a5eb2-arm64-apple-darwin.tar.gz
  f8fbc07221bd21f996dc29c65725740e9c2bfc9365367c806601f12b8e2d2691  guix-build-913b1f2a5eb2/output/dist-archive/bitcoin-913b1f2a5eb2.tar.gz
  fdbc8224d774f2428f037e65d9ac5728613cddee4ddcf6f1d144421cb1f37b3b  guix-build-913b1f2a5eb2/output/powerpc64-linux-gnu/SHA256SUMS.part
  c1098cba38aee264ee7de82be3d5f8c1ec2c915c30763292fa9b6dc37aba8de8  guix-build-913b1f2a5eb2/output/powerpc64-linux-gnu/bitcoin-913b1f2a5eb2-powerpc64-linux-gnu-debug.tar.gz
  567b8bf896a79e2f1b4961ec4f6c3501e414822f84f6fb40c9e3546e67ab08ff  guix-build-913b1f2a5eb2/output/powerpc64-linux-gnu/bitcoin-913b1f2a5eb2-powerpc64-linux-gnu.tar.gz
  cbd7713550c5922ee28e0915b0425dc702bb299ad6809ff60e389604f4da3a31  guix-build-913b1f2a5eb2/output/powerpc64le-linux-gnu/SHA256SUMS.part
  e50fa6e370602a956942703ab349808c01e7365a00faead941d9e6be3800c65c  guix-build-913b1f2a5eb2/output/powerpc64le-linux-gnu/bitcoin-913b1f2a5eb2-powerpc64le-linux-gnu-debug.tar.gz
  2380fbdf6916769783a0e6c7848fb8d3b3cb5c44c26817009a8481e815098e3a  guix-build-913b1f2a5eb2/output/powerpc64le-linux-gnu/bitcoin-913b1f2a5eb2-powerpc64le-linux-gnu.tar.gz
  a0fecb7b0d0a93aa15825572a0e1284f4776a5808f9f5eda7b2ddddaf2457fb2  guix-build-913b1f2a5eb2/output/riscv64-linux-gnu/SHA256SUMS.part
  14fe505f06de009b50c2b4ce0e0430ba09fa66385ff50aa90f9ed0b03a321e61  guix-build-913b1f2a5eb2/output/riscv64-linux-gnu/bitcoin-913b1f2a5eb2-riscv64-linux-gnu-debug.tar.gz
  98a70df9a6851d5221d8f8404f9656048ecf7cac2c9dffd2b6a55107783a60ad  guix-build-913b1f2a5eb2/output/riscv64-linux-gnu/bitcoin-913b1f2a5eb2-riscv64-linux-gnu.tar.gz
  decb20f8de61e3eeda7e8f6fefcbaf56593c37d989672c6e7e2cd5c8e982c342  guix-build-913b1f2a5eb2/output/x86_64-apple-darwin/SHA256SUMS.part
  e14275e1bbbe54179fb68b50ed7c72de4c7ebc5b442c7793daf9974be523e8da  guix-build-913b1f2a5eb2/output/x86_64-apple-darwin/bitcoin-913b1f2a5eb2-x86_64-apple-darwin-unsigned.dmg
  6bb2d9f6c8123156b0e11b73f67f4e4e780e6bccb739e600f4e9b06b29aa3832  guix-build-913b1f2a5eb2/output/x86_64-apple-darwin/bitcoin-913b1f2a5eb2-x86_64-apple-darwin-unsigned.tar.gz
  1f0fab16e32e4c9892b272edf43beb8e5de60bf8a04f41744809dc2a31b4f1b9  guix-build-913b1f2a5eb2/output/x86_64-apple-darwin/bitcoin-913b1f2a5eb2-x86_64-apple-darwin.tar.gz
  3d7e45c7189a8855ea8a0d498dcd4d3189aa01c528eac194300cdb59f79471f2  guix-build-913b1f2a5eb2/output/x86_64-linux-gnu/SHA256SUMS.part
  87b75a47a620dbd8ccf20768a3d82adf0b797ad86b7384cca62a7cf489b7a74c  guix-build-913b1f2a5eb2/output/x86_64-linux-gnu/bitcoin-913b1f2a5eb2-x86_64-linux-gnu-debug.tar.gz
  7e06af11bcef3ba6fd48501a09fbac86746537bad063f36caf39cd6bb857d3a8  guix-build-913b1f2a5eb2/output/x86_64-linux-gnu/bitcoin-913b1f2a5eb2-x86_64-linux-gnu.tar.gz
  c9ca794f7307df6f891008d92997719be95794f4670d018d0275f2a6c580d160  guix-build-913b1f2a5eb2/output/x86_64-w64-mingw32/SHA256SUMS.part
  7eb1551cdafc0a44e5b5fcea703c6eeb6fc0bca601b57ab52d1e5e62db3ccffc  guix-build-913b1f2a5eb2/output/x86_64-w64-mingw32/bitcoin-913b1f2a5eb2-win64-debug.zip
  8ef87c85c520aef150f4c11a9082e8a0b1ac74c5b6f4fcdceb9e734eb8106bca  guix-build-913b1f2a5eb2/output/x86_64-w64-mingw32/bitcoin-913b1f2a5eb2-win64-setup-unsigned.exe
  c5886ab3d6303bf8c946e4aafcfdfb5ee7dc9fbb50c34dfc5224db2f1f3b2a44  guix-build-913b1f2a5eb2/output/x86_64-w64-mingw32/bitcoin-913b1f2a5eb2-win64-unsigned.tar.gz
  f473902cea9e763b98ad69c5dcfaa990430f9b0f777112af5f1d289492d8cefe  guix-build-913b1f2a5eb2/output/x86_64-w64-mingw32/bitcoin-913b1f2a5eb2-win64.zip
  ```

  Guix Build (arm64):
  ```bash
  a175ce0055b206fe7b2752fa5ae33eed0f31236f7b37bbb530425532d88007c2  guix-build-913b1f2a5eb2/output/arm-linux-gnueabihf/SHA256SUMS.part
  1ab5d59685593eedbb59b5284d81cce568a6c9c900303f97c69e8194cb5bb7f5  guix-build-913b1f2a5eb2/output/arm-linux-gnueabihf/bitcoin-913b1f2a5eb2-arm-linux-gnueabihf-debug.tar.gz
  8d1b48d38b8af696b929ac077ba7e3dabb7c565862409b2f35db2217ab9bdb06  guix-build-913b1f2a5eb2/output/arm-linux-gnueabihf/bitcoin-913b1f2a5eb2-arm-linux-gnueabihf.tar.gz
  90230652cb39e2707ac79569899183dc1ff5d08c059e7a01d0c65144251679b5  guix-build-913b1f2a5eb2/output/arm64-apple-darwin/SHA256SUMS.part
  2b86da5e1ccebf348478ca69463d1be09c0f563ffa370ee5170c82ba706a7577  guix-build-913b1f2a5eb2/output/arm64-apple-darwin/bitcoin-913b1f2a5eb2-arm64-apple-darwin-unsigned.dmg
  648e968dbf3af3bf8a79d714f4395091058e2ff4294b202a0dc9b5e0092b4732  guix-build-913b1f2a5eb2/output/arm64-apple-darwin/bitcoin-913b1f2a5eb2-arm64-apple-darwin-unsigned.tar.gz
  bebe7ed21e4f74866ca99be31839beff01eac57afbaa2878f5c6637f0239c631  guix-build-913b1f2a5eb2/output/arm64-apple-darwin/bitcoin-913b1f2a5eb2-arm64-apple-darwin.tar.gz
  f8fbc07221bd21f996dc29c65725740e9c2bfc9365367c806601f12b8e2d2691  guix-build-913b1f2a5eb2/output/dist-archive/bitcoin-913b1f2a5eb2.tar.gz
  87156fe1fb397eaa1d1f15c36f2677b6aeb32eefac02202b2735f7d3165fceb1  guix-build-913b1f2a5eb2/output/powerpc64-linux-gnu/SHA256SUMS.part
  5f06e885564780d7dce78cc8cbb21b8dd5addba8b90bb2b8a7f03e946b6ed633  guix-build-913b1f2a5eb2/output/powerpc64-linux-gnu/bitcoin-913b1f2a5eb2-powerpc64-linux-gnu-debug.tar.gz
  95b9c0a7d82e7055c99d013fa183abf654caf14539c5ec9cfe785838f45747fc  guix-build-913b1f2a5eb2/output/powerpc64-linux-gnu/bitcoin-913b1f2a5eb2-powerpc64-linux-gnu.tar.gz
  8da6f0fb2bdc492f96ee70ca323787521e7fce7ebe2b9adb43b7b6ae56ff1916  guix-build-913b1f2a5eb2/output/powerpc64le-linux-gnu/SHA256SUMS.part
  a60623ac5bb76b3eae3129b4f32fe7287e526e043bd2e58f80ce5fccf91ef20c  guix-build-913b1f2a5eb2/output/powerpc64le-linux-gnu/bitcoin-913b1f2a5eb2-powerpc64le-linux-gnu-debug.tar.gz
  c9bbdca3c41c3783d57734e0fda875a6353bbf8fec8c8e61f037259acaad28cd  guix-build-913b1f2a5eb2/output/powerpc64le-linux-gnu/bitcoin-913b1f2a5eb2-powerpc64le-linux-gnu.tar.gz
  5f76aef2eed312153b60712450b4376b4965c2b0c86d2ddfc0b7f3d23fb31eee  guix-build-913b1f2a5eb2/output/riscv64-linux-gnu/SHA256SUMS.part
  40ad7ca605bb75e153a481a455b344f27d9c0b713f1312fc2a7703116508a127  guix-build-913b1f2a5eb2/output/riscv64-linux-gnu/bitcoin-913b1f2a5eb2-riscv64-linux-gnu-debug.tar.gz
  6031d28d6405f03b685884fdee6c2cc2126afffdc867ab743ca0c9cfcad81ac2  guix-build-913b1f2a5eb2/output/riscv64-linux-gnu/bitcoin-913b1f2a5eb2-riscv64-linux-gnu.tar.gz
  decb20f8de61e3eeda7e8f6fefcbaf56593c37d989672c6e7e2cd5c8e982c342  guix-build-913b1f2a5eb2/output/x86_64-apple-darwin/SHA256SUMS.part
  e14275e1bbbe54179fb68b50ed7c72de4c7ebc5b442c7793daf9974be523e8da  guix-build-913b1f2a5eb2/output/x86_64-apple-darwin/bitcoin-913b1f2a5eb2-x86_64-apple-darwin-unsigned.dmg
  6bb2d9f6c8123156b0e11b73f67f4e4e780e6bccb739e600f4e9b06b29aa3832  guix-build-913b1f2a5eb2/output/x86_64-apple-darwin/bitcoin-913b1f2a5eb2-x86_64-apple-darwin-unsigned.tar.gz
  1f0fab16e32e4c9892b272edf43beb8e5de60bf8a04f41744809dc2a31b4f1b9  guix-build-913b1f2a5eb2/output/x86_64-apple-darwin/bitcoin-913b1f2a5eb2-x86_64-apple-darwin.tar.gz
  b90d8c7252fd42809ac9bf8c7e5cf9c9207f7412314e9e6904ee2e51222bc8c5  guix-build-913b1f2a5eb2/output/x86_64-linux-gnu/SHA256SUMS.part
  b6cbcd305a9b6b8dcc6be71703745835c9e3e7652a3f3b18e7018f5ddb0fc26d  guix-build-913b1f2a5eb2/output/x86_64-linux-gnu/bitcoin-913b1f2a5eb2-x86_64-linux-gnu-debug.tar.gz
  6da0cf8fedd9c285926c132102d1e8f9d6fde7e0ecdac3ba159a3464fc2e98c0  guix-build-913b1f2a5eb2/output/x86_64-linux-gnu/bitcoin-913b1f2a5eb2-x86_64-linux-gnu.tar.gz
  30d2b25cdfce03edc2bfb8d39dcdcc6636ed3637cc0176f43f715dc795ab929e  guix-build-913b1f2a5eb2/output/x86_64-w64-mingw32/SHA256SUMS.part
  6028017fabcddac50857667d63da979b04a6dc331a26715f875e2db96b8935d7  guix-build-913b1f2a5eb2/output/x86_64-w64-mingw32/bitcoin-913b1f2a5eb2-win64-debug.zip
  8ef87c85c520aef150f4c11a9082e8a0b1ac74c5b6f4fcdceb9e734eb8106bca  guix-build-913b1f2a5eb2/output/x86_64-w64-mingw32/bitcoin-913b1f2a5eb2-win64-setup-unsigned.exe
  c5886ab3d6303bf8c946e4aafcfdfb5ee7dc9fbb50c34dfc5224db2f1f3b2a44  guix-build-913b1f2a5eb2/output/x86_64-w64-mingw32/bitcoin-913b1f2a5eb2-win64-unsigned.tar.gz
  4af0477e156b9a0c6fa1754ba7446b8c6c021075531aa4051980e47fa586e196  guix-build-913b1f2a5eb2/output/x86_64-w64-mingw32/bitcoin-913b1f2a5eb2-win64.zip
  ```

  Symbol exporting as of this PR (`bitcoind.exe`):
  ```bash
  Export Table:
   DLL name: bitcoind.exe
   Ordinal base: 1
   Ordinal      RVA  Name
         1 0xa09670  main
  ```

  Symbol exporting in the 23.0 bins (`bitcoind.exe`):
  ```bash
  Export Table:
   DLL name: bitcoind.exe
   Ordinal base: 1
   Ordinal      RVA  Name
         1 0x5569f0  secp256k1_context_clone
         2 0x556890  secp256k1_context_create
         3 0x556bd0  secp256k1_context_destroy
         4 0xa12710  secp256k1_context_no_precomp
         5 0x556900  secp256k1_context_preallocated_clone
         6 0x556740  secp256k1_context_preallocated_clone_size
         7 0x556750  secp256k1_context_preallocated_create
         8 0x556ae0  secp256k1_context_preallocated_destroy
         9 0x556710  secp256k1_context_preallocated_size
        10 0x5589c0  secp256k1_context_randomize
        11 0x556c80  secp256k1_context_set_error_callback
        12 0x556c20  secp256k1_context_set_illegal_callback
        13 0x558260  secp256k1_ec_privkey_negate
        14 0x5584e0  secp256k1_ec_privkey_tweak_add
        15 0x558730  secp256k1_ec_privkey_tweak_mul
        16 0x5572a0  secp256k1_ec_pubkey_cmp
        17 0x5589f0  secp256k1_ec_pubkey_combine
        18 0x557f40  secp256k1_ec_pubkey_create
        19 0x558270  secp256k1_ec_pubkey_negate
        20 0x556dc0  secp256k1_ec_pubkey_parse
        21 0x5570d0  secp256k1_ec_pubkey_serialize
        22 0x5584f0  secp256k1_ec_pubkey_tweak_add
        23 0x558740  secp256k1_ec_pubkey_tweak_mul
        24 0x558100  secp256k1_ec_seckey_negate
        25 0x5583a0  secp256k1_ec_seckey_tweak_add
        26 0x5585f0  secp256k1_ec_seckey_tweak_mul
        27 0x557ed0  secp256k1_ec_seckey_verify
        28 0x559120  secp256k1_ecdsa_recover
        29 0x558f50  secp256k1_ecdsa_recoverable_signature_convert
        30 0x558d00  secp256k1_ecdsa_recoverable_signature_parse_compact
        31 0x558e70  secp256k1_ecdsa_recoverable_signature_serialize_compact
        32 0x557da0  secp256k1_ecdsa_sign
        33 0x558fe0  secp256k1_ecdsa_sign_recoverable
        34 0x557ab0  secp256k1_ecdsa_signature_normalize
        35 0x557540  secp256k1_ecdsa_signature_parse_compact
        36 0x5573b0  secp256k1_ecdsa_signature_parse_der
        37 0x557a10  secp256k1_ecdsa_signature_serialize_compact
        38 0x557660  secp256k1_ecdsa_signature_serialize_der
        39 0x557bf0  secp256k1_ecdsa_verify
        40 0x5598a0  secp256k1_keypair_create
        41 0x559af0  secp256k1_keypair_pub
        42 0x559a60  secp256k1_keypair_sec
        43 0x559bc0  secp256k1_keypair_xonly_pub
        44 0x559d20  secp256k1_keypair_xonly_tweak_add
        45 0xa9e0c0  secp256k1_nonce_function_bip340
        46 0xa9e0e0  secp256k1_nonce_function_default
        47 0xa9e0e8  secp256k1_nonce_function_rfc6979
        48 0x559f00  secp256k1_schnorrsig_sign
        49 0x559f30  secp256k1_schnorrsig_sign_custom
        50 0x559fd0  secp256k1_schnorrsig_verify
        51 0x556ce0  secp256k1_scratch_space_create
        52 0x556d50  secp256k1_scratch_space_destroy
        53 0x558c20  secp256k1_tagged_sha256
        54 0x559470  secp256k1_xonly_pubkey_cmp
        55 0x559530  secp256k1_xonly_pubkey_from_pubkey
        56 0x559290  secp256k1_xonly_pubkey_parse
        57 0x5593a0  secp256k1_xonly_pubkey_serialize
        58 0x559650  secp256k1_xonly_pubkey_tweak_add
        59 0x559780  secp256k1_xonly_pubkey_tweak_add_check
  ```

ACKs for top commit:
  laanwj:
    Code review ACK 913b1f2a5e
  theuni:
    ACK 913b1f2a5e

Tree-SHA512: d3811c5731fab05bb68af72b7af231de8505b026bd1b2cd710e3e60386e793c2743412529142aa9893893f9d24c6e94dbac48ea59451bf55ae637d2e75e2b0a9
2022-06-13 21:43:39 +02:00
Luke Dashjr
7862c4ac4e RPC/blockchain: Reorder result documentation for scantxoutset
start, abort, status (with result), and status (no result) makes more logical sense
2022-06-13 14:09:48 +00:00
Luke Dashjr
98718d03be scripted-diff: RPC/blockchain: Lowercase "when" in scantxoutset documentation
-BEGIN VERIFY SCRIPT-
sed -i -e 's/"When /"when /' $(git grep -l 'RPCResult{"When ')
-END VERIFY SCRIPT-
2022-06-13 14:08:30 +00:00
Luke Dashjr
b283e4d823 RPC/blockchain: Elaborate on scantxoutset documentation 2022-06-13 14:05:06 +00:00
Hennadii Stepanov
37633d2f61
Merge bitcoin-core/gui#602: Unify bitcoin-qt and bitcoind persistent settings
e47c6c7656 Reset settings.json when GUI options are reset (Ryan Ofsky)
99ccc02b65 Add release notes about unified bitcoin-qt and bitcoind persistent settings (Ryan Ofsky)
504b06b1de Migrate -lang setting from QSettings to settings.json (Ryan Ofsky)
9a016a3c07 Migrate -prune setting from QSettings to settings.json (Ryan Ofsky)
f067e19433 Migrate -proxy and -onion settings from QSettings to settings.json (Ryan Ofsky)
a09e3b7cf2 Migrate -listen and -server settings from QSettings to settings.json (Ryan Ofsky)
d2ada6e635 Migrate -upnp and -natpmp settings from QSettings to settings.json (Ryan Ofsky)
1dc4fc29c1 Migrate -spendzeroconfchange and -signer settings from QSettings to settings.json (Ryan Ofsky)
a7ef6d5975 Migrate -par setting from QSettings to settings.json (Ryan Ofsky)
284f339de6 Migrate -dbcache setting from QSettings to settings.json (Ryan Ofsky)

Pull request description:

  If a setting like pruning, port mapping, or a network proxy is enabled in the GUI, it will now be stored in the bitcoin persistent setting file in the datadir and shared with bitcoind, instead of being stored as Qt settings which end up in the the windows registry or platform specific config files and are ignored by bitcoind.

  This PR has been split off from bitcoin/bitcoin#15936 so some review of these commits previously took place in that PR.

ACKs for top commit:
  furszy:
    Code review ACK e47c6c76
  hebasto:
    ACK e47c6c7656

Tree-SHA512: 076ea7c7efe67805b4a357113bfe1643dce364d0032774106de59566a0ed5771d57a5923920085e03d686beb34b98114bd278555dfdf8bb7af0b778b0f35b7d2
2022-06-12 14:59:14 +02:00
Hennadii Stepanov
7ab72b9d2a
qt: Fix BitcoinAmountField's base widget 2022-06-12 13:40:48 +02:00
Hennadii Stepanov
3262542104
qt, refactor: Fix sendcoinsentry.ui indentation 2022-06-12 13:40:48 +02:00
Hennadii Stepanov
f3c7603329
qt, refactor: Convert SendCoinsEntry to a sub-QWidget
It is no longer needed to derive the `SendCoinsEntry` class from the
`QStackedWidget` one.
2022-06-12 13:40:46 +02:00
Hennadii Stepanov
9ef180a0ab
Merge bitcoin-core/gui#608: wallet, refactor: Make WalletModel::sendCoins() return void
1f653dc262 qt, wallet, refactor: Make `WalletModel::sendCoins()` return `void` (Hennadii Stepanov)

Pull request description:

  Currently, the `WalletModel::sendCoins()` function always returns the same value.

  Also dead and noop (calling `processSendCoinsReturn(OK)`) code has been removed.

  The other `return` statements have been removed from the `WalletModel::sendCoins()` function in bitcoin/bitcoin#17154 and bitcoin/bitcoin#17165.

ACKs for top commit:
  kristapsk:
    cr ACK 1f653dc262
  furszy:
    Code review ACK 1f653dc2
  shaavan:
    Code Review ACK 1f653dc262
  w0xlt:
    Code Review ACK 1f653dc262

Tree-SHA512: 2b59495a7fc10b4de30fcc63fc3af92d50406e16031112eb72494736dce193ac1fbac0802623496cf81edcd16766e1647d9c4f3a607b3eb84cc50e273b999c04
2022-06-12 13:33:55 +02:00
fanquake
913b1f2a5e
Update secp256k1 subtree to latest upstream master 2022-06-11 14:55:18 +01:00
fanquake
c41bfd1070 Squashed 'src/secp256k1/' changes from 8746600ee..44c2452fd
44c2452fd Merge bitcoin-core/secp256k1#1105: Don't export symbols in static libraries
6f6cab998 abi: Don't export symbols in static Windows libraries
485f608fa Merge bitcoin-core/secp256k1#1104: Fix the false positive of `SECP_64BIT_ASM_CHECK`
8b013fce5 Merge bitcoin-core/secp256k1#1056: Save negations in var-time group addition
7efc9835a Fix the false positive of `SECP_64BIT_ASM_CHECK`
2f984ffc4 Save negations in var-time group addition

git-subtree-dir: src/secp256k1
git-subtree-split: 44c2452fd387f7ca604ab42d73746e7d3a44d8a2
2022-06-11 14:55:18 +01:00
fanquake
fbae8c59a2
compat: Consolidate mingw-w64 ASLR workaround for upstream libsecp changes
Achieve this by adding a MAIN_FUNCTION macro, consolidating the docs, and
introducing the macro across our distributed binaries.

Also update the docs to explain that anyone using binutils < 2.36 is
effected by this issue. Release builds are not, because they use binutils
2.37. Currently LTS Linux distros, like Ubuntu Focal, ship with 2.34.

https://packages.ubuntu.com/focal/binutils
2022-06-11 14:55:13 +01:00
Martin Zumsande
99b9e5f3a9 p2p: always set nTime for self-advertisements
If we self-advertised to an inbound peer with the address they gave us,
nTime was left default-initialized, so that our peer wouldn't relay it
any further along.
2022-06-10 10:50:07 -04:00
MacroFake
8f3ab9a1b1
Merge bitcoin/bitcoin#24931: Strengthen thread safety assertions
ce893c0497 doc: Update developer notes (Anthony Towns)
d2852917ee sync.h: Imply negative assertions when calling LOCK (Anthony Towns)
bba87c0553 scripted-diff: Convert global Mutexes to GlobalMutexes (Anthony Towns)
a559509a0b sync.h: Add GlobalMutex type (Anthony Towns)
be6aa72f9f qt/clientmodel: thread safety annotation for m_cached_tip_mutex (Anthony Towns)
f24bd45b37 net_processing: thread safety annotation for m_tx_relay_mutex (Anthony Towns)

Pull request description:

  This changes `LOCK(mutex)` for non-global, non-recursive mutexes to be annotated with the negative capability for the mutex it refers to, to prevent . clang applies negative capabilities recursively, so this helps avoid forgetting to annotate functions.

  This can't reasonably be used for globals, because clang would require every function to be annotated with `EXCLUSIVE_LOCKS_REQUIRED(!g_mutex)` for each global mutex; so this introduces a trivial `GlobalMutex` subclass of `Mutex`, and reduces the annotations for both `GlobalMutex`  to `LOCKS_EXCLUDED` which only catches trivial errors (eg (`LOCK(x); LOCK(x);`).

ACKs for top commit:
  MarcoFalke:
    review ACK ce893c0497 🐦
  hebasto:
    ACK ce893c0497

Tree-SHA512: 5c35e8c7677ce3d994a7e3774f4344adad496223a51b3a1d1d3b5f20684b2e1d5cff688eb3fbc8d33e1b9940dfa76e515f9434e21de6f3ce3c935e29a319f529
2022-06-10 16:42:53 +02:00
Oskar Mendel
1cb42aeda3
util: modify Win32LockedPageAllocator to query windows for limit 2022-06-10 14:44:23 +02:00
fanquake
491bb14c0c
build: test for timingsafe_bcmp
Code introduced in #15649 added usage of `timingsafe_bcmp()`, if
available, otherwise falling back to our own implementation. However
the relevant build system check was never added, so currently, we'll
always just use our implementation, as HAVE_TIMINGSAFE_BCMP will never
be defined.

Add the check for timingsafe_bcmp. Note that as far as I'm aware, it's
only available on OpenBSD.
2022-06-10 12:39:08 +01:00
Vasil Dimov
6e68ccbefe
net: use Sock::WaitMany() instead of CConnman::SocketEvents()
Rename `GenerateSelectSet()` to `GenerateWaitSockets()` and adapt it to
generate a wait data suitable for `Sock::WaitMany()`. Then call it from
`CConnman::SocketHandler()` and feed the generated data to
`Sock::WaitMany()`.

This way `CConnman::SocketHandler()` can be unit tested because
`Sock::WaitMany()` is mockable, so the usage of real sockets can be
avoided.

Resolves https://github.com/bitcoin/bitcoin/issues/21744
2022-06-09 16:20:24 +02:00
fanquake
e3c08eb620
Merge bitcoin/bitcoin#25307: doc: fix typo in kernel/context.h and add desig to ignore-words
d575413fb8 doc: add `desig` to ignore-words (brunoerg)
c06cc41ddb doc: fix typo in kernel/context.h (brunoerg)

Pull request description:

  This PR fixes a typo in `kernel/context.h` (libary => library) and add `desig` to ignore-words since it's a valid word, see:
  b9416c3847/src/net.cpp (L1105-L1117)

ACKs for top commit:
  fanquake:
    ACK d575413fb8

Tree-SHA512: 2d548c737b8184d0243445c7503f3f68256ecb0970bd834d52de099de3cd8c8b9c140e2b77d55e2542fbd45b1d21cbdee639f5b2ef8138c37b8b72e5211029c3
2022-06-09 13:24:00 +01:00
Vasil Dimov
ae263460ba
net: introduce Sock::WaitMany()
It allows waiting concurrently on more than one socket. Being a
`virtual` `Sock` method it can be overriden by tests.

Will be used to replace `CConnman::SocketEvents()`.
2022-06-09 14:20:18 +02:00
Vasil Dimov
cc74459768
net: also wait for exceptional events in Sock::Wait()
This mimics closely `CConnman::SocketEvents()` and the underlying
`poll(2)`.
2022-06-09 13:34:27 +02:00
fanquake
9edc5133d4
Merge bitcoin/bitcoin#25303: refactor: Remove redundant addrman time checks
8888bd43c1 Remove redundant nLastTry check (MarcoFalke)
00001e57fe Remove redundant nTime checks (MarcoFalke)

Pull request description:

  Split out from https://github.com/bitcoin/bitcoin/pull/24697 because it makes sense on its own.

ACKs for top commit:
  dergoegge:
    re-ACK 8888bd43c1
  naumenkogs:
    utACK 8888bd43c1

Tree-SHA512: 32c6cde1c71e943c76b7991c2c24caf29ae467ab4ea2d758483a0cee64625190d1a833b468e8eab1f834beeb2c365af96552c14b05270f08cf63790e0707581d
2022-06-09 12:28:25 +01:00
furszy
fd5c996d16
wallet: GetAvailableBalance, remove double walk-through every available coin
Filtering `AvailableCoins` by spendable outputs only and using the retrieved total_amount.
2022-06-08 11:30:26 -03:00
furszy
162d4ad10f
wallet: add 'only_spendable' filter to AvailableCoins
We are skipping the non-spendable coins that appear in vCoins ('AvailableCoins' result) later, in several parts of the CreateTransaction and GetBalance flows:

GetAvailableBalance (1) gets all the available coins calling AvailableCoins and, right away, walk through the entire vector, skipping the non-spendable coins, to calculate the total balance.

Inside CreateTransactionInternal —> SelectCoins(vCoins,...), we have several calls to AttemptSelection which, on each of them internally, we call twice to GroupOutputs which internally has two for-loops over the entire vCoins vector that skip the non-spendable coins.

So, Purpose is not add the non-spendable coins into the AvailableCoins result (vCoins) in the first place for the processes that aren’t using them at all, so we don’t waste resources skipping them later so many times.

Note: this speedup is for all the processes that call to CreateTransaction and GetBalance* internally.
2022-06-08 11:30:25 -03:00
furszy
cdf185ccfb
wallet: remove unused IsSpentKey(hash, index) method 2022-06-08 11:22:40 -03:00
furszy
4b83bf8dbc
wallet: avoid extra IsSpentKey -> GetWalletTx lookups 2022-06-08 11:22:40 -03:00
furszy
3d8a282257
wallet: decouple IsSpentKey(scriptPubKey) from IsSpentKey(hash, n)
This will be used in a follow-up commit to prevent extra 'GetWalletTx' lookups if the function caller already have the wtx and can just provide the scriptPubKey directly.
2022-06-08 11:22:39 -03:00
furszy
a06fa94ff8
wallet: IsSpent, 'COutPoint' arg instead of (hash, index) 2022-06-08 11:22:39 -03:00
furszy
91902b7720
wallet: IsLockedCoin, 'COutPoint' arg instead of (hash, index) 2022-06-08 10:26:48 -03:00
furszy
9472ca0a65
wallet: AvailableCoins, don't call 'wtx.tx->vout[i]' multiple times 2022-06-08 10:25:51 -03:00
furszy
4ce235ef8f
wallet: return 'CoinsResult' struct in AvailableCoins
Instead of accepting a `vCoins` reference that is cleared at the beginning of the method.

Note:
This new struct, down the commits line, will contain other `AvailableCoins` useful results.
2022-06-08 10:25:16 -03:00
brunoerg
c06cc41ddb doc: fix typo in kernel/context.h 2022-06-08 10:03:43 -03:00
Jon Atack
ecff20db28 logging: use LogPrintfCategory rather than a manual category
Here we update only the log messages that manually print a category.

In upcoming commits, LogPrintCategory will likely be used in many
other cases, such as to replace `LogPrintf` where it makes sense.
2022-06-08 14:02:54 +02:00
Jon Atack
eb8aab759f logging: add LogPrintfCategory to log unconditionally with category
prefixing the output with the passed category name.

- add documentation
- add a unit test
- update lint-logs.py
- update lint-format-strings.py
2022-06-08 14:02:54 +02:00
MarcoFalke
8888bd43c1
Remove redundant nLastTry check
All other places calculate "now - nLastTry", which is safe and correct
to do when nLastTry is 0. So do the same here.
2022-06-08 13:35:32 +02:00
fanquake
b9416c3847
Merge bitcoin/bitcoin#25096: [net] Minor improvements to addr caching
292828cd77 [test] Test addr cache for multiple onion binds (dergoegge)
3382905bef [net] Seed addr cache randomizer with port from binding address (dergoegge)
f10e80b6e4 [net] Use ConnectedThroughNetwork() instead of GetNetwork() to seed addr cache randomizer (dergoegge)

Pull request description:

  The addr cache id randomizer is currently supposed to be seeded with the network of the inbound connection and the local socket (only the address is used not the port):  a8098f2cef/src/net.cpp (L2800-L2804)

  For inbound onion connections `CNode::addr.GetNetwork()` returns `NET_UNROUTABLE` and `CNode::addrBind` is set to `127.0.0.1:<onion bind port>`. This results in the same addr cache for all inbound connections on 127.0.0.1 binds.

  To avoid the same addr cache across all onion and other 127.0.0.1 binds, we should seed the addr cache randomizer with the correct network for inbound onion connections (using `CNode::ConnectedThroughNetwork()`) as well as the port of `CNode::addrBind`.

ACKs for top commit:
  sipa:
    utACK 292828cd77
  mzumsande:
    Code Review ACK 292828cd77
  naumenkogs:
    utACK 292828cd77

Tree-SHA512: d0be13bab6bc121c2926d4b168687f6c2ed4ce0c9dd19be71eb4886adeba8afc3daacdc4e232a0ba3b03a89d69b618abc5595b69abd1ad0c476d825bc6ea1f9f
2022-06-08 11:21:38 +01:00
MarcoFalke
00001e57fe
Remove redundant nTime checks
nTime is always initialized on deserialization or default-initialized
with TIME_INIT, so special casing 0 does not make sense.
2022-06-08 09:17:39 +02:00
Ben Woosley
241c4d047e
doc: Correct comment describing value of MAX_FILE_SIZE_PSBT as in MiB
100 MiB is 100 * (10224 ** 2), or 107,374,182,400 bytes.
2022-06-07 15:49:07 -05:00
darosior
64f81a38b9
doc: Correct nPruneTarget misidentifying units of variable 2022-06-07 15:30:16 -05:00
Andrew Chow
79cabe3a5b
Merge bitcoin/bitcoin#25239: wallet: 'CommitTransaction', remove extra wtx lookup and add exception for db write error
57fb37c275 wallet: CommitTransaction, remove extra wtx lookup and add exception for a possible db write error. (furszy)

Pull request description:

  Two points for `CWallet::CommitTransaction`:

  1) The extra wtx lookup:
      As we are calling to `AddToWallet` first, which returns the recently added/updated wtx pointer, there is no need to look up the wtx again few lines later. We can just use it.

  2) The db write error:
      `AddToWallet` can only return a nullptr if the db write fails, which inside `CommitTransaction` translates to an exception throw cause. We expect everywhere that `CommitTransaction` always succeed.

  ------------------------------------------------

  Extra note:
  This finding generated another working path for me :)
   It starts with the following question: why are we returning a nullptr from `AddToWallet` if the db write failed without removing the recently added transaction from the wallet's map?..
   Can led to a wallet invalid state where the inputs of this new transaction are not marked dirty, while the transaction that spends them still exist on the in-memory wallet tx map.
  -- I'm writing it here to gather some feedback first and not forget it, will create a follow-up PR in the coming days 🚜 --

ACKs for top commit:
  achow101:
    ACK 57fb37c275
  jonatack:
    ACK 57fb37c
  ryanofsky:
    Code review ACK 57fb37c275. Seems like a clear improvement. Better to fail earlier with a better error message if the failure is going to happen anyway

Tree-SHA512: 80e59c01852cfbbc70a5de1a1c2c59b5e572f9eaa08c2175112cb515256e63fa04c7942f92a513b620d6b06e66392029ebe8902287c456efdbee58a7a5ae42da
2022-06-07 15:02:53 -04:00
laanwj
d8ae504448
Merge bitcoin/bitcoin#25245: refactor: Remove no-op TIME_INIT on deser
fa243e9313 Remove no-op TIME_INIT on deser (MarcoFalke)

Pull request description:

  Split out from https://github.com/bitcoin/bitcoin/pull/24697

ACKs for top commit:
  laanwj:
    ACK fa243e9313
  fanquake:
    ACK fa243e9313

Tree-SHA512: 3b92578a291279d04ac1b274807a6e4ee7a342e3527cc03d90223a1dbc4961668ddb572e40aff85171600a5a3cb2572188c0d75f757a3db8a441c1103eb66e84
2022-06-07 19:42:13 +02:00
MacroFake
45d8b1e94a
Merge bitcoin/bitcoin#25286: scripted-diff: remove duplicate categories from LogPrint output
d40550d725 scripted-diff: remove duplicate categories from LogPrint output (Jon Atack)

Pull request description:

  This is the first commit from #25203.

  - Scripted-diff: de-duplicate logging category output for the tor, i2p, net, zmq, and prune messages (e.g. where I found duplicates), as these category prefixes are now printed automatically since #24464

  examples before
  ```
  [tor] tor: Successfully connected!
  [i2p] I2P: Creating SAM session with 127.0.0.1:7656
  [zmq] zmq: Initialize notification interface
  [net] net: enabling extra block-relay-only peers
  ```
  after
  ```
  [tor] Successfully connected!
  [i2p] Creating SAM session with 127.0.0.1:7656
  [zmq] Initialize notification interface
  [net] enabling extra block-relay-only peers
  ```

ACKs for top commit:
  klementtan:
    crACK d40550d725
  MarcoFalke:
    cr ACK d40550d725

Tree-SHA512: 63b799f2f899f0597981dd1acb91ef4439cd00b257a9eb19d67c4ce2c4dc72a95ac5761cb78f2a19090a10be74f23ea1db6929ed942ba0d008b4be563f0d5e7e
2022-06-07 11:33:58 +02:00
MacroFake
2ab4a80480
Merge bitcoin/bitcoin#25254: Move minRelayTxFee to policy/settings
fa4068b4e2 Move minRelayTxFee to policy/settings (MacroFake)

Pull request description:

  Seems a bit confusing to put policy stuff into validation, so fix that.

  Also fix includes via `iwyu`.

ACKs for top commit:
  ariard:
    ACK fa4068b, the includes move compiles well locally.
  ryanofsky:
    Code review ACK fa4068b4e2. Make sense to move the global variable to policy/settings and the default constant to policy/policy. Ariard points out other constants that could be moved, which seems fine, but it seems like moving the global variable to be with other related global variables is more significant.

Tree-SHA512: adf9619002610d1877f3aef0a9e6115fc4c2ad64135a3e5100824c650b560c47f47ac28894c6214a50a7888355252a9f6f7cec98c23a771a1964160ef1ca77de
2022-06-07 11:31:10 +02:00
MacroFake
581e2bdbac
Merge bitcoin/bitcoin#24629: Bugfix: RPC/blockchain: pruneblockchain: Return the height of the actual last pruned block
e593ae07c4 Bugfix: RPC/blockchain: pruneblockchain: Return the height of the actual last pruned block (Luke Dashjr)

Pull request description:

  From 0.14 (2017 Mar) until before 0.19 (2019 Nov), the height of the last block pruned was returned, subject to a bug if there were blocks left unpruned due to sharing files with later blocks.

  In #15991, this was "fixed" to the current implementation, introducing a new bug: now, it returns the first *unpruned* block.

  Since the user provides the parameter as a block to include in pruning, it makes more sense to fix the behaviour to match the documentation.

  ~~(Additionally, the description of "pruneheight" in getblockchaininfo is fixed to be technically correct)~~

ACKs for top commit:
  fjahr:
    utACK e593ae07c4
  ryanofsky:
    Code review ACK e593ae07c4. Just rebased since last review. Maybe some of the original reviewers of #15991 will want to take a look at this to correct the mistake that was introduced there!

Tree-SHA512: c2d511df80682d57260aae8af1665f9d7eaed16448f185f4c9f23c78fa9b8289a02053da7a0b83643fef57610d601ea63b59ff39661a51f4827f1eb27cc30594
2022-06-07 08:04:51 +02:00
Carl Dong
0f1a259657 miner: Make mempool optional for BlockAssembler
...also adjust callers

Changes:

- In BlockAssembler::CreateNewBlock, we now only lock m_mempool->cs and
  call addPackageTxs if m_mempool is not nullptr
- BlockAssembler::addPackageTxs now takes in a mempool reference, and is
  annotated to require that mempool's lock.
- In TestChain100Setup::CreateBlock and generateblock, don't construct
  an empty mempool, just pass in a nullptr for mempool
2022-06-06 15:38:09 -04:00
laanwj
06ea2783a2
Merge bitcoin/bitcoin#25220: rpc: fix incorrect warning for address type p2sh-segwit in createmultisig
3a9b9bb38e test: ensure createmultisig and addmultisigaddress are not returning any warning for expected cases (brunoerg)
eaf6f630c0 rpc: fix inappropriate warning for address type p2sh-segwit in createmultisig and addmultisigaddress (brunoerg)

Pull request description:

  Fixes #25127

  If there are any uncompressed keys when calling `AddAndGetMultisigDestination`, it will just default to a legacy address regardless of the chosen `address_type`. So, #23113 added a warnings field which will warn the user why their address format is different.

  However, when creating a multisig (p2sh-segwit), it is returning an inappropriate warning, because when getting the output type from destination (`OutputTypeFromDestination`), it returns `ScriptHash` for both legacy and `P2SH_SEGWIT`. So, since `P2SH_SEGWIT` is different from `ScriptHash`, it returns the warning:
  192d639a6b/src/rpc/output_script.cpp (L166-L169)

  So, to avoid this mistake I changed `OutputTypeFromDestination` to `descriptor->GetOutputType()` to get the appropriate output type.

ACKs for top commit:
  jonatack:
    ACK 3a9b9bb38e
  laanwj:
    Code review ACK 3a9b9bb38e

Tree-SHA512: 49f717479c2b8906277e7591ddd4747f7961c2d5c77494b5124045de9036a4277d46b9ad99279d51f0c4484284c445f1e1d3c55c49bbf0716741bad426a89369
2022-06-06 17:13:22 +02:00
MacroFake
e82d8069bc
Merge bitcoin/bitcoin#25276: doc: Fix typo in importdescriptors
210cd592cd doc: Fix typo in importdescriptors (Kolby Moroz Liebl)

Pull request description:

ACKs for top commit:
  1440000bytes:
    ACK 210cd592cd
  LarryRuane:
    ACK 210cd592cd
  brunoerg:
    crACK 210cd592cd

Tree-SHA512: 39ff9777b05abc1a68c8c3e646e00b0672838696c567c582d0492baa753863231447fd8439bd41cd8a8b8ba752299b032e839c8862c02faa2bdc207a9a7a8540
2022-06-06 15:54:30 +02:00
brunoerg
eaf6f630c0 rpc: fix inappropriate warning for address type p2sh-segwit in createmultisig and addmultisigaddress 2022-06-06 09:46:02 -03:00
Jon Atack
d40550d725 scripted-diff: remove duplicate categories from LogPrint output
-BEGIN VERIFY SCRIPT-
s() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; }
s 'BCLog::TOR, "tor: '       'BCLog::TOR, "'
s 'BCLog::I2P, "I2P: '       'BCLog::I2P, "'
s 'BCLog::NET, "net: '       'BCLog::NET, "'
s 'BCLog::ZMQ, "zmq: '       'BCLog::ZMQ, "'
s 'BCLog::PRUNE, "Prune: '   'BCLog::PRUNE, "'
-END VERIFY SCRIPT-
2022-06-06 12:12:03 +02:00
Hennadii Stepanov
ce1c8104aa
build: Remove unused LIBBITCOIN_KERNEL variable 2022-06-05 21:43:13 +02:00
Hennadii Stepanov
1b2e1d179c
Merge bitcoin-core/gui#614: Drop no longer supported Android architecture
d1b7bcbca2 qt: Drop no longer supported Android architecture (Hennadii Stepanov)

Pull request description:

  The `i686-linux-android` arch support has been dropped since bitcoin/bitcoin#23744.

ACKs for top commit:
  katesalazar:
    ACK d1b7bcbca2
  icota:
    utACK d1b7bcbca2
  prusnak:
    Approach ACK d1b7bcbca2

Tree-SHA512: 13689ec8c63c92b9a52a3c25edc35536b8e51ff583f57c45b168515f928d020d6bb85d03db9efd8d5efd57b944dfd313a89f5ff8a52f99982ccc8d9671f6e7a9
2022-06-05 14:29:29 +02:00
Kolby Moroz Liebl
210cd592cd
doc: Fix typo in importdescriptors 2022-06-04 18:48:30 -06:00
fanquake
695ca641a4
Merge bitcoin/bitcoin#24860: Miniscript integration follow-ups
f3a50c9dfe miniscript: rename IsSane and IsSaneSubexpression to prevent misuse (Antoine Poinsot)
c5fe5163dc miniscript: nit: don't return after assert(false) (Antoine Poinsot)
7bbaca9d8d miniscript: explicit the threshold size computation in multi() (Antoine Poinsot)
8323e4249d miniscript: add an OpCode typedef for readability (Antoine Poinsot)
7a549c6c59 miniscript: mark nodes with duplicate keys as insane (Antoine Poinsot)
8c0f8bf7bc fuzz: add a Miniscript target for string representation roundtripping (Antoine Poinsot)
be34d5077b fuzz: rename and improve the Miniscript Script roundtrip target (Antoine Poinsot)
7eb70f0ac0 miniscript: tiny doc fixups (Antoine Poinsot)
5cea85f12c miniscript: split ValidSatisfactions from IsSane (Antoine Poinsot)
a0f064dc14 miniscript: introduce a CheckTimeLocksMix helper (Antoine Poinsot)
ed45ee3882 miniscript: use optional instead of bool/outarg (Antoine Poinsot)
1ab8d89fd1 miniscript: make equality operator non-recursive (Antoine Poinsot)
5922c662c0 scripted-diff: miniscript: rename 'nodetype' variables to 'fragment' (Antoine Poinsot)
c5f65db0f0 miniscript: remove a workaround for a GCC 4.8 bug (Antoine Poinsot)

Pull request description:

  The Miniscript repository and the Miniscript integration PR here have been a moving target for the past months, and some final cleanups were done there that were not included here. I initially intended to add some small followup commits to #24148 but i think there are enough of them to be worth a followup PR on its own.

  Some parts of the code did not change since it was initially written in 2019, and the code could use some modernization. (Use std::optional instead of out args, remove old compiler workarounds).
  We refactored the helpers to be more meaningful, and also did some renaming. A new fuzz target was also added and both were merged in a single file. 2 more will be added in #24149 that will be contained in this file too.

  The only behaviour change in this PR is to rule out Miniscript with duplicate keys from sane Miniscripts. In a P2WSH context, signatures can be rebounded (Miniscript does not use CODESEPARATOR) and it's reasonable to assume that reusing keys across the Script drops the malleability guarantees.
  It was previously assumed such Miniscript would never exist in the first place since a compiler should never create them. We finally agreed that if one were to exist (say, written by hand or from a buggy compiler) it would be very confusing if an imported Miniscript descriptor (after #24148) with duplicate keys was deemed sane (ie, "safe to use") by Bitcoin Core. We now check for duplicate keys in the constructor.

  This is (still) joint work with Pieter Wuille. (Actually he entirely authored the cleanups and code modernization.)

ACKs for top commit:
  sipa:
    utACK f3a50c9dfe (with the caveat that a lot of it is my own code)
  sanket1729:
    code review ACK f3a50c9dfe. Did not review the fuzz tests.

Tree-SHA512: c043325e4936fe25e8ece4266b46119e000c6745f88cea530fed1edf01c80f03ee6f9edc83b6e9d42ca01688d184bad16bfd967c5bb8037744e726993adf3deb
2022-06-04 20:54:20 +01:00
fanquake
aac9c259b0
Merge bitcoin/bitcoin#25065: [kernel 2c/n] Introduce kernel::Context, encapsulate global init/teardown
d87784ac87 kernel: SanityChecks: Return an error struct (Carl Dong)
265d6393bf Move init::SanityCheck to kernel::SanityCheck (Carl Dong)
fed085a1a4 init: Initialize globals with kernel::Context's life (Carl Dong)
7d03feef81 kernel: Introduce empty and unused kernel::Context (Carl Dong)
eeb4fc20c5 test: Use Set/UnsetGlobals in BasicTestingSetup (Carl Dong)

Pull request description:

  The full `init/common.cpp` is dependent on things like ArgsManager (which we wish to remove from libbitcoinkernel in the future) and sanity checks. These aren't necessary for libbitcoinkernel so we only extract the portion that is necessary (namely `init::{Set,Unset}Globals()`.

ACKs for top commit:
  theuni:
    ACK d87784ac87
  vasild:
    ACK d87784ac87

Tree-SHA512: cd6b4923ea1865001b5f0caed9a4ff99c198d22bf74154d935dc09a47fda22ebe585ec912398cea69f722454ed1dbb4898faab5a2d02fb4c5e719c5c8d71a3f9
2022-06-04 20:25:57 +01:00
Hennadii Stepanov
d1b7bcbca2
qt: Drop no longer supported Android architecture 2022-06-04 11:42:26 +02:00
Luke Dashjr
e593ae07c4 Bugfix: RPC/blockchain: pruneblockchain: Return the height of the actual last pruned block
From 0.14 (2017 Mar) until before 0.19 (2019 Nov), the height of the last
block pruned was returned, subject to a bug if there were blocks left unpruned
due to sharing files with later blocks.

In #15991, this was "fixed" to the current implementation, introducing a new
bug: now, it returns the first *unpruned* block.

Since the user provides the parameter as a block to include in pruning, it
makes more sense to fix the behaviour to match the documentation.
2022-06-03 07:20:07 +00:00
MacroFake
2cf8c2caea
Merge bitcoin/bitcoin#25256: logging: fix logging empty thread name
3a171f742c logging: fix logging empty threadname (klementtan)

Pull request description:

  Currently, `leveldb` background thread does not have a thread name and as a result, an empty thread name is logged.

  This PR fixes this by logging thread name as `"unknown"` if the thread name is empty

  On master:
  ```txt
  2022-06-02T14:30:38Z [] [leveldb:debug] Generated table #281@0: 1862 keys, 138303 bytes
  ```

  On this PR:
  ```txt
  2022-06-02T14:30:38Z [unknown] [leveldb:debug] Generated table #281@0: 1862 keys, 138303 bytes
  ```

ACKs for top commit:
  laanwj:
    Code review ACK 3a171f742c
  hebasto:
    ACK 3a171f742c

Tree-SHA512: 0af0fa5c4ddd3640c6dab9595fe9d97f74d0e0f4b41287a6630cf8ac5a21240250e0659ec4ac5a561e888d522f5304bf627104de2aba0fd0a86c1222de0897c2
2022-06-03 08:46:53 +02:00
laanwj
00ce8543f1
Merge bitcoin/bitcoin#24171: p2p: Sync chain more readily from inbound peers during IBD
48262a00f5 Add functional test for block sync from inbound peers (Suhas Daftuar)
0569b5c4bb Sync chain more readily from inbound peers during IBD (Suhas Daftuar)

Pull request description:

  When in IBD, if the honest chain is only known by inbound peers, then we must
  eventually sync from them in order to learn it. This change allows us to
  perform initial headers sync and fetch blocks from inbound peers, if we have no
  blocks in flight.

  The restriction on having no blocks in flight means that we will naturally
  throttle our block downloads to any such inbound peers that we may be
  downloading from, until we leave IBD. This is a tradeoff between preferring
  outbound peers for most of our block download, versus making sure we always
  eventually will get blocks we need that are only known by inbound peers even
  during IBD, as otherwise we may be stuck in IBD indefinitely (which could have
  cascading failure on the network, if a large fraction of the network managed to
  get stuck in IBD).

  Note that the test in the second commit fails on master, without the first commit.

ACKs for top commit:
  ajtowns:
    ACK 48262a00f5
  sipa:
    ACK 48262a00f5

Tree-SHA512: ffad3a05fa9a32a92226843c9128f52c275e8d51930fde7368badc340227f2ed680561c4c9f2937b4e3bd722474464849ec9b624f912f5e380ce98d71b55764d
2022-06-02 22:35:05 +02:00
Hennadii Stepanov
b11ab25afb
Merge bitcoin-core/gui#583: Add translator comments to TransactionDesc::FormatTxStatus
8cfb5627d5 qt, refactor: add translator comments in `TransactionDesc::FormatTxStatus()` (w0xlt)

Pull request description:

  This PR adds translator comments to `TransactionDesc::FormatTxStatus` as suggested in https://github.com/bitcoin-core/gui/pull/552#discussion_r812602741 and https://github.com/bitcoin-core/gui/pull/552#issuecomment-1097294710.

ACKs for top commit:
  hebasto:
    ACK 8cfb5627d5

Tree-SHA512: 2c44b915e6309508f34fc22bb90e3d88ad32ed82fdb3a395f7c6716941edc1b311991140d28e838ad622a7484ed86aedd25e55674857fec8716d9575aed25fa0
2022-06-02 19:36:40 +02:00
Hennadii Stepanov
da6792b2eb
Merge bitcoin-core/gui#613: Remove unnecessary wallet includes from rpcconsole.cpp
0994273649 qt: Remove unnecessary wallet includes from rpcconsole.cpp (laanwj)

Pull request description:

  Fixes bitcoin/bitcoin#25266

ACKs for top commit:
  MarcoFalke:
    cr ACK 0994273649
  hebasto:
    ACK 0994273649.

Tree-SHA512: 02cef4a1f3522c4cd662853eb930dfdf0866a5bd959a00f4c42d8c741b0751df4cf2e14c304b93ca3ce699c0e9730caf3d6fa2053009af312c60e861b0f79179
2022-06-02 19:20:07 +02:00
laanwj
a100c42a13
Merge bitcoin/bitcoin#24927: Add test util to populate mempool with random transactions, fix #24634 bug
d2f8f1b307 use testing setup mempool in ComplexMemPool bench (glozow)
aecc332a71 create and use mempool transactions using real coins in MempoolCheck (glozow)
2118750631 [test util] to populate mempool with random transactions/packages (glozow)
5374dfc4e3 [test util] use -checkmempool for TestingSetup mempool check ratio (glozow)
d7d9c7b266 [test util] add chain name to TestChain100Setup ctor (glozow)

Pull request description:

  Fixes #24634 by using the `testing_setup`'s actual mempool rather than a locally-declared mempool for running `check()`.

  Also creates a test utility for populating the mempool with a bunch of random transactions. I imagine this could be useful in other places as well; it was necessary here because we needed the mempool to contain transactions *spending coins available in the current chainstate*. The existing `CreateOrderedCoins()` is insufficient because it creates coins out of thin air.

  Also implements the separate suggestion to use the `TestingSetup` mempool in `ComplexMemPool` bench.

ACKs for top commit:
  laanwj:
    Code review ACK d2f8f1b307

Tree-SHA512: 44ab5a9e55b126b5a5bc33f05fbad1380b9c43c84736c7cf487be025e0e3f5d75216ccf5a3088b0935da817e3dacfba99d2885f75bcb6e7eaa24cd20a82c24c8
2022-06-02 19:08:43 +02:00
laanwj
636991d0c0
Merge bitcoin/bitcoin#25264: kernel: pass params to BlockManager rather than using a global
a4741bd8d4 kernel: pass params to BlockManager rather than using a global (Cory Fields)

Pull request description:

  In a discussion today, dongcarl and I realized that is the only usage of the global `Params()` left in the kernel code.

  We can use the readily available reference in `ChainstateManager` instead.

  Note: There are still some uses of `BaseParams` in the kernel, so it doesn't make sense to rearrange the definitions quite yet. Once those are gone we can split the globals into new files.

ACKs for top commit:
  MarcoFalke:
    cr ACK a4741bd8d4
  laanwj:
    Code review ACK a4741bd8d4

Tree-SHA512: bfcc0c35e6c23689e968ccc96ceda39dd5a47fe94fbe617902110fe5865c30a40ea614bcfd4b4a2c846d2e84340aa8973e70b0938786af0fecfa3e6016d7fcad
2022-06-02 19:04:53 +02:00
dergoegge
3382905bef [net] Seed addr cache randomizer with port from binding address 2022-06-02 19:03:54 +02:00
w0xlt
8cfb5627d5 qt, refactor: add translator comments in TransactionDesc::FormatTxStatus() 2022-06-02 13:56:36 -03:00
Carl Dong
d87784ac87 kernel: SanityChecks: Return an error struct
This reduces libbitcoinkernel's coupling with ui_interface and
translation.
2022-06-02 12:22:46 -04:00
laanwj
0994273649 qt: Remove unnecessary wallet includes from rpcconsole.cpp 2022-06-02 18:17:33 +02:00
Carl Dong
265d6393bf Move init::SanityCheck to kernel::SanityCheck 2022-06-02 11:42:12 -04:00
Carl Dong
fed085a1a4 init: Initialize globals with kernel::Context's life
...instead of explicitly calling init::{Set,Unset}Globals.

Cool thing about this is that in both the testing and bitcoin-chainstate
codepaths, we no longer need to explicitly unset globals. The
kernel::Context goes out of scope and the globals are unset
"automatically".

Also construct kernel::Context outside of AppInitSanityChecks()
2022-06-02 11:40:03 -04:00
Cory Fields
a4741bd8d4 kernel: pass params to BlockManager rather than using a global 2022-06-02 15:18:09 +00:00
klementtan
3a171f742c
logging: fix logging empty threadname 2022-06-02 22:30:30 +08:00
MacroFake
39ddd522c3
Merge bitcoin/bitcoin#24531: Use designated initializers
fa72e0ba15 Use designated initializers (MarcoFalke)

Pull request description:

  Designated initializers are supported since gcc 4.7 (Our minimum required is 8) and clang 3 (Our minimum required is 7). They work out of the box with C++17, and only msvc requires the C++20 flag to be set. I don't expect any of our msvc users will run into issues due to this. See also https://bitcoin.jonasschnelli.ch/ircmeetings/logs/bitcoin-core-dev/2022/bitcoin-core-dev.2022-03-10-19.00.log.html#l-114

ACKs for top commit:
  kristapsk:
    ACK fa72e0ba15
  hebasto:
    ACK fa72e0ba15

Tree-SHA512: a198e9addd9af69262a7e79ae4377b55697c8dfe768b8b3d444526544b1d1f85df46f0ae81b7541bf2f73e5868fb944b159e5bf234303c7b8b9d778afb0b2840
2022-06-02 13:05:29 +02:00
fanquake
86cc31dab6
Merge bitcoin/bitcoin#25249: Bump univalue subtree
025c6ca509 Squashed 'src/univalue/' changes from 6c19d050a9..de4f73ddca (MacroFake)
9b50a309ff refactor: Replace get_int by getInt<int> alias (MacroFake)
e4e8186ab4 refactor: Explicitly convert atomic<int> to int (João Barbosa)

Pull request description:

  This bumps the univalue subtree and changes two lines of our code. Apart from the get_int -> getInt change, this is mostly a rebase of https://github.com/bitcoin/bitcoin/pull/15975, which was closed back then.

  However, given the numerous UniValue copy bugs and performance regressions in the past years, I think it makes sense to finally go through with the changes and disable potentially expensive implicit UniValue copies, which may cause OOM.

  The changes here are not strictly required for that, but make future changes less verbose and easier to review.

ACKs for top commit:
  laanwj:
    Code review ACK fa0cc61b7f
  fanquake:
    ACK fa0cc61b7f

Tree-SHA512: 9ab9e371e6a745a80c441e99fb9cd407602a8066df883135e0ea7eced7b0c6ef0e9bc88f1d99a2b4804128d636727229f44d72b5615dbf2d70da4af63fa6adec
2022-06-01 19:13:43 +01:00
MarcoFalke
fa72e0ba15
Use designated initializers 2022-06-01 20:06:01 +02:00
fanquake
b752dade04
Merge bitcoin/bitcoin#25244: build: pass bdb cppflags only where needed
46a890960e build: pass bdb cppflags only where needed (fanquake)

Pull request description:

  Move bdb cppflags out of the catch-all `BITCOIN_INCLUDES`, and pass them
  only where they are needed, which is in libbitcoin_node/wallet and the tests.

ACKs for top commit:
  hebasto:
    ACK 46a890960e

Tree-SHA512: ac639bf88be1c21c5205bb14c983330c72c37f17ec4c15a746a86c54dd83853e3d75802eff48c4647484b07c1bae943ca2c3d61d2a8b0bed07d9c5b4a71dcec4
2022-06-01 15:57:52 +01:00
Carl Dong
7d03feef81 kernel: Introduce empty and unused kernel::Context
[META] In the next commit, we will move the init::{Set,Unset}Globals
       logic into this struct.

Co-Authored-By: Ryan Ofsky <ryan@ofsky.org>
2022-05-31 14:18:31 -04:00
Carl Dong
eeb4fc20c5 test: Use Set/UnsetGlobals in BasicTestingSetup
...instead of calling initialization functions directly and having to
keep around a ECCVerifyHandle member variable.

This makes the initialization codepath of our tests more closely
resemble those of AppInitMain and potentially eases the review of
subsequent commit removing init::{Set,Unset}Globals.

[META] In a future commit, we will introduce a kernel::Context which
       calls init::{Set,Unset}Globals in its ctor and dtor. It will be
       owned by node::NodeContext, so in the end, this patchset won't
       have made the previously local ECCVerifyHandle global.
2022-05-31 14:18:31 -04:00
MacroFake
d4d9daff7a
Merge bitcoin/bitcoin#25200: doc: Fix spelling errors identified by codespell in comments
f565b2836d Fixup option name in bench message (Ben Woosley)
bf209ac7a7 doc: Fix spelling errors identified by codespell in coments (Ben Woosley)

Pull request description:

  From the output [here](https://cirrus-ci.com/task/5275612980969472?logs=lint#L849):
  ```
  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
  ```

  ~~I left the 'nd' in miniscript_tests as-is, as it's valid miniscript,
  and I'm wary of whitelisting it.~~

ACKs for top commit:
  dunxen:
    ACK f565b28

Tree-SHA512: 501a426c5f6f9761e2c8f980d5d955611428a827321888f53e0ae9526b0fecd43f9d1fa845fc70ae2489d77be6dc0b5b371dff55c5146f4b39ed874f4a1ea917
2022-05-31 15:19:59 +02:00
MacroFake
fa4068b4e2
Move minRelayTxFee to policy/settings
Also fix includes using iwyu
2022-05-31 15:05:57 +02:00
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
fanquake
46a890960e
build: pass bdb cppflags only where needed
Move bdb cppflags out of the catch-all BITCOIN_INCLUDES, and pass them
only where they are needed, which is in libbitcoin_node/wallet and the
tests.
2022-05-31 06:37:43 +01:00
glozow
d2f8f1b307 use testing setup mempool in ComplexMemPool bench 2022-05-30 16:00:41 -07:00
glozow
aecc332a71 create and use mempool transactions using real coins in MempoolCheck 2022-05-30 16:00:41 -07:00
glozow
2118750631 [test util] to populate mempool with random transactions/packages 2022-05-30 16:00:41 -07:00
glozow
5374dfc4e3 [test util] use -checkmempool for TestingSetup mempool check ratio 2022-05-30 16:00:41 -07:00
glozow
d7d9c7b266 [test util] add chain name to TestChain100Setup ctor
This allows calling MakeNoLogFileContext<TestChain100Setup>
2022-05-30 16:00:41 -07:00
Hennadii Stepanov
b9ef5a10e2
Merge bitcoin-core/gui#609: wallet, refactor: Drop unused WalletModel::PaymentRequestExpired
151009cf76 qt, wallet, refactor: Drop unused `WalletModel::PaymentRequestExpired` (Hennadii Stepanov)

Pull request description:

  The `PaymentRequestExpired` value in the `WalletModel::StatusCode` enumeration has been unused since bitcoin/bitcoin#17165.

ACKs for top commit:
  furszy:
    ACK 151009cf, no usage for it.
  kristapsk:
    cr ACK 151009cf76, checked that `PaymentRequestExpired` is not referenced anywhere else.

Tree-SHA512: c2ea3443af5d369ca294d79559869f688aaa806b91ffe0090f3b34638a8377ec2f11d6f5c09cc2d11ab55035850237e60e992acba671097a6642c6bb9e709273
2022-05-30 21:33:56 +02:00
Hennadii Stepanov
6420fb2005
qt, refactor: Drop unused QFrames in SendCoinsEntry 2022-05-30 18:05:09 +02:00
MacroFake
fa0cc61b7f
Bump univalue subtree 2022-05-30 16:42:13 +02:00
MacroFake
9b50a309ff refactor: Replace get_int by getInt<int> alias 2022-05-30 16:39:46 +02:00
João Barbosa
e4e8186ab4 refactor: Explicitly convert atomic<int> to int 2022-05-30 16:38:29 +02:00
Antoine Poinsot
f3a50c9dfe
miniscript: rename IsSane and IsSaneSubexpression to prevent misuse 2022-05-30 15:16:46 +02:00
Antoine Poinsot
c5fe5163dc
miniscript: nit: don't return after assert(false) 2022-05-30 15:16:45 +02:00
Antoine Poinsot
7bbaca9d8d
miniscript: explicit the threshold size computation in multi() 2022-05-30 15:16:45 +02:00
Antoine Poinsot
8323e4249d
miniscript: add an OpCode typedef for readability
Suggested-by: Vincenzo Palazzo
2022-05-30 15:16:44 +02:00
Antoine Poinsot
7a549c6c59
miniscript: mark nodes with duplicate keys as insane
As stated on the website, duplicate keys make it hard to reason about
malleability as a single signature may unlock multiple paths.

We use a custom KeyCompare function instead of operator< to be explicit
about the requirement.
2022-05-30 15:16:43 +02:00
MarcoFalke
fa243e9313
Remove no-op TIME_INIT on deser
Assigning TIME_INIT to nTime was needed to fully re-initialize a dirty
object where the deserialization might skip nTime.
See https://github.com/bitcoin/bitcoin/pull/19020/files#r427620111

Now that the without-nTime logic is removed in commit
dbcb5742c4 and commit
e08770bed1, the logic here can be removed
as well.

Also, remove confusing and redundant preprocessor code.

Also, remove no longer needed version.h include, which was needed for
INIT_PROTO_VERSION.
2022-05-30 13:55:39 +02:00
MacroFake
8779adbdda
Merge bitcoin/bitcoin#25233: compat: remove glibcxx sanity checks
cc61bc2e19 compat: remove glibcxx sanity checks (fanquake)

Pull request description:

  These checks were added in #4339, (see also #4081), to test
  our back-compat stubs, however, those stubs no-longer exist (#22930),
  meaning that these checks are now just testing some specific standard
  library behaviour, without a particular rationale, or reason, compared
  to any other standard library functionlity we use.

  There has also been some discussion about our sanity checks in the
  context of the libbitcoinkernel refactoring, see https://github.com/bitcoin/bitcoin/pull/25065#discussion_r880668218.
  Removing the checks removes the need to worry about atleast the
  glibcxx checks.

  Also remove the list of checks from the doc in `init.h`, because it is
  incomplete, and anyone who wants to know what checks are included can
  look at the function.

  Guix Build (arm64):
  ```bash
  e18a81e25b4707cbe113fb4d3ba2459013c1178e7cecfe446e4f14ee5ecd2ce8  guix-build-cc61bc2e19b1/output/arm-linux-gnueabihf/SHA256SUMS.part
  9928cc38b79f827018cba0bdde98666b31806afcc79dd95a00acb8e153c36eec  guix-build-cc61bc2e19b1/output/arm-linux-gnueabihf/bitcoin-cc61bc2e19b1-arm-linux-gnueabihf-debug.tar.gz
  ebf4635ba4688899ae62e4bb17ebb2afb25c538c4a8068ef515920fd4e43754e  guix-build-cc61bc2e19b1/output/arm-linux-gnueabihf/bitcoin-cc61bc2e19b1-arm-linux-gnueabihf.tar.gz
  74c7e35b47c6d101fda7205f144d37150329b4c360db09d37b8c1437f3390898  guix-build-cc61bc2e19b1/output/arm64-apple-darwin/SHA256SUMS.part
  6e12643b17be9326f1d873dfe51a52c082671540792877af624b42ca9f6e1791  guix-build-cc61bc2e19b1/output/arm64-apple-darwin/bitcoin-cc61bc2e19b1-arm64-apple-darwin-unsigned.dmg
  1d86d0416c7a50afd7bd8d850f416b7c7277464ccc95e4dae53b5b59415fc83d  guix-build-cc61bc2e19b1/output/arm64-apple-darwin/bitcoin-cc61bc2e19b1-arm64-apple-darwin-unsigned.tar.gz
  84070843f23839e7191ad3a667eb63c45f668eb95afbfb3fcdfb8363320f67d4  guix-build-cc61bc2e19b1/output/arm64-apple-darwin/bitcoin-cc61bc2e19b1-arm64-apple-darwin.tar.gz
  bf6ccd7b8c40476b1dc52b491757313ea3e96c43a01c8aabaf39f94dc1837329  guix-build-cc61bc2e19b1/output/dist-archive/bitcoin-cc61bc2e19b1.tar.gz
  25e7e1ff7d8de38632abf9926343c8ba556209f3d03109c92864ffe72813a05f  guix-build-cc61bc2e19b1/output/powerpc64-linux-gnu/SHA256SUMS.part
  d0398de83841607b1bf921d4553b30ad5e2d70d0570e96a2eaaf2762e1103c79  guix-build-cc61bc2e19b1/output/powerpc64-linux-gnu/bitcoin-cc61bc2e19b1-powerpc64-linux-gnu-debug.tar.gz
  f09cdc2ac2a2bb644f4749f3d74b5210ddb531594c33d127a907f0223e7793e5  guix-build-cc61bc2e19b1/output/powerpc64-linux-gnu/bitcoin-cc61bc2e19b1-powerpc64-linux-gnu.tar.gz
  ef36a68ef4e5ee9b311df40062cd2296f897e7b1550e39e0643601cd7d469010  guix-build-cc61bc2e19b1/output/powerpc64le-linux-gnu/SHA256SUMS.part
  937b600a2b86304ccc5b6c71a7eaf8aa5e2020592724cef6a933a1955995480b  guix-build-cc61bc2e19b1/output/powerpc64le-linux-gnu/bitcoin-cc61bc2e19b1-powerpc64le-linux-gnu-debug.tar.gz
  eca4eec41e71fdf7a7b0fa4065afa49c47d3b9541ed2cb4d083ad4a0de102e37  guix-build-cc61bc2e19b1/output/powerpc64le-linux-gnu/bitcoin-cc61bc2e19b1-powerpc64le-linux-gnu.tar.gz
  981c0968c19905925a599cff357ec259c1e806bdb7691c7b52039be450bdad7c  guix-build-cc61bc2e19b1/output/riscv64-linux-gnu/SHA256SUMS.part
  89c709967f9a157256281fbf682aad246f2eaad9c2f1797c2787253cbabe12f8  guix-build-cc61bc2e19b1/output/riscv64-linux-gnu/bitcoin-cc61bc2e19b1-riscv64-linux-gnu-debug.tar.gz
  454cd830dd382e176f5a23041fc33f93937668245481b0dd29fc04882d9528eb  guix-build-cc61bc2e19b1/output/riscv64-linux-gnu/bitcoin-cc61bc2e19b1-riscv64-linux-gnu.tar.gz
  e0812c2dc492e5c5f06e3685d19da8fb29ed38d3b32821d293ef01cb4fefbd79  guix-build-cc61bc2e19b1/output/x86_64-apple-darwin/SHA256SUMS.part
  0e7d4241d8ac882a8091fa00a7813db87a3e5afec59627e45b6c910cfdd4a7b0  guix-build-cc61bc2e19b1/output/x86_64-apple-darwin/bitcoin-cc61bc2e19b1-x86_64-apple-darwin-unsigned.dmg
  3faaca046cbb2642445a7dd1f389ed7bf94a65de8372441c36d5cb79c030ce31  guix-build-cc61bc2e19b1/output/x86_64-apple-darwin/bitcoin-cc61bc2e19b1-x86_64-apple-darwin-unsigned.tar.gz
  73080f032a42db679baf0d09619671ac5b9d85be84a68bdd6b6709eb0e6465bd  guix-build-cc61bc2e19b1/output/x86_64-apple-darwin/bitcoin-cc61bc2e19b1-x86_64-apple-darwin.tar.gz
  07b6e1b6291404bca1044df4a45b6958b882ffb88c143ba98f1959960a394897  guix-build-cc61bc2e19b1/output/x86_64-linux-gnu/SHA256SUMS.part
  16b455f62398f4aa0d3821abb1cceb8151e31c2664e3f974a764a5b8702b50f3  guix-build-cc61bc2e19b1/output/x86_64-linux-gnu/bitcoin-cc61bc2e19b1-x86_64-linux-gnu-debug.tar.gz
  3c1a3a6a343f17b83f3b3d47e9426eccd2d0bcc7f824cd958fcf2cf06cdc3276  guix-build-cc61bc2e19b1/output/x86_64-linux-gnu/bitcoin-cc61bc2e19b1-x86_64-linux-gnu.tar.gz
  f05afa688ea7211b0049555385fb2acc26986e24d8d00893389160e07037e693  guix-build-cc61bc2e19b1/output/x86_64-w64-mingw32/SHA256SUMS.part
  8bcbae67dd0746c42e1e7c7db67725a69289b08e9aa97b873d443d0aa355615d  guix-build-cc61bc2e19b1/output/x86_64-w64-mingw32/bitcoin-cc61bc2e19b1-win64-debug.zip
  efa45e3b76e5ae08a8392d58e741325df572d92c7dd69b65d876cdcda541d2fc  guix-build-cc61bc2e19b1/output/x86_64-w64-mingw32/bitcoin-cc61bc2e19b1-win64-setup-unsigned.exe
  3a8c2461ca826138c3017d06279a79b4c6bee2a507ad362aa6e424f76678596c  guix-build-cc61bc2e19b1/output/x86_64-w64-mingw32/bitcoin-cc61bc2e19b1-win64-unsigned.tar.gz
  e56ae4f609d4e6a3ca5917a4bb763c91012ece2d236d6b62a666358791e43525  guix-build-cc61bc2e19b1/output/x86_64-w64-mingw32/bitcoin-cc61bc2e19b1-win64.zip
  ```

ACKs for top commit:
  MarcoFalke:
    lgtm ACK cc61bc2e19
  laanwj:
    Concept and code review ACK cc61bc2e19

Tree-SHA512: 3da6aba44eef3f864fcbe897db1faa964923756e68c6a713e444b5d01c6d3542c3d7ca26678760e81a7a9e3cd40bd90622d0a7b697c27166817ba4f1023661ef
2022-05-30 10:39:47 +02:00
fanquake
e3b7f10b10
Merge bitcoin/bitcoin#25237: rpc: Capture UniValue by ref for rpcdoccheck
20ff4991e5 rpc: Capture potentially large UniValue by ref for rpcdoccheck (Martin Zumsande)

Pull request description:

  Capturing it by reference instead of value should save us from making a copy of a potentially large object. Saw this while having a look at #25229 although I couldn't reproduce an actual leak, so this is not a fix for that issue.

ACKs for top commit:
  MarcoFalke:
    review ACK 20ff4991e5
  theStack:
    Code-review ACK 20ff4991e5
  furszy:
    Code ACK 20ff4991

Tree-SHA512: faf7bb14e37f8324b93a39095b07693626329da47c4a1ac8929bf99385e2e0567008e959e7e8540bc7d454d08fa41cccd39f55253c9a839fa88362922058a93b
2022-05-30 09:16:09 +01:00
MacroFake
b6ab45ae5c
Merge bitcoin/bitcoin#25204: rpc: remove deprecated top-level fee fields from mempool entries
885694d794 doc: add release note about removal of `deprecatedrpc=fees` flag (Sebastian Falbesoner)
387ae8bc09 rpc: remove deprecated fee fields from mempool entries (Sebastian Falbesoner)

Pull request description:

  Deprecating the top-level fee fields (`fee`, `modifiedfee`, `ancestorfees` and `descendantfees`) from the mempool entries and introducing `-deprecatedrpc=fees` was done in PR #22689 (released in v23.0). For the next release v24.0, this configuration option can be removed.

ACKs for top commit:
  fanquake:
    ACK 885694d794

Tree-SHA512: fec6b5be5c3f0cd55738a888b390ef9271e70b2dba913a14ce82427dac002e999f93df298bb3b494f3d1b850a23d2b5b3e010e901543b0d18db9be133579e1ec
2022-05-30 08:52:15 +02:00
furszy
57fb37c275
wallet: CommitTransaction, remove extra wtx lookup and add exception for a possible db write error.
1) `Wallet::AddToWallet` is already returning the pointer to the inserted `CWalletTx`, so there is no need to look it up in the map again.

2) `Wallet::AddToWallet` can only return a nullptr if the db `writeTx` call failed. Which should be treated as an error.
2022-05-29 14:02:08 -03:00
Hennadii Stepanov
151009cf76
qt, wallet, refactor: Drop unused WalletModel::PaymentRequestExpired
Also dead code has been removed.
2022-05-29 18:04:44 +02:00
Hennadii Stepanov
1f653dc262
qt, wallet, refactor: Make WalletModel::sendCoins() return void
Currently, the `WalletModel::sendCoins()` function always returns the
same value.

Also dead and noop code has been removed.
2022-05-29 17:49:55 +02:00
Martin Zumsande
20ff4991e5 rpc: Capture potentially large UniValue by ref for rpcdoccheck 2022-05-29 14:36:53 +02:00
fanquake
cc61bc2e19
compat: remove glibcxx sanity checks
These checks were added in #4339, (see also #4081), to test
our back-compat stubs, however, those stubs no-longer exist (#22930),
meaning that these checks are now just testing some specific standard
library behaviour, without a particular rationale, or reason, compared
to any other standard library functions we use.

There has also been some discussion about the sanity checks in the
context of the libbitcoinkernel refactoring, see
https://github.com/bitcoin/bitcoin/pull/25065#discussion_r880668218.
Removing the checks removes the need to worry about atleast the glibcxx
checks.

Also remove the list of check from the doc in init.h, because it is
incomplete, and anyone who wants to know what checks are included can
look at the function.
2022-05-28 09:43:02 +01:00
fanquake
ba48fcf4a4
Merge bitcoin/bitcoin#25224: Get time less often in AddrManImpl::ResolveCollisions_()
fa27ee88ed Get time less often in AddrManImpl::ResolveCollisions_() (MarcoFalke)

Pull request description:

  First commit split out from https://github.com/bitcoin/bitcoin/pull/24697

ACKs for top commit:
  sipa:
    utACK fa27ee88ed
  fanquake:
    ACK fa27ee88ed

Tree-SHA512: 40c8594d2a5ce02a392ac5f9f120c24c6bcd495b0bcc901fd6064dde9f6123cd109504cee7b612a9555b70cfd7759cbd6cd496d007bb374c27610d01b464191c
2022-05-28 09:41:00 +01:00
Carl Dong
cc5739b27d miner: Make UpdatePackagesForAdded static
Since UpdatePackagesForAdded is a helper function that's only used in
addPackageTxs we can make it static and avoid the unnecessary interface
and in-header lock annotation.
2022-05-27 15:34:28 -04:00
Carl Dong
f024578b3a miner: Absorb SkipMapTxEntry into addPackageTxs
SkipMapTxEntry is a short helper function that's only used in
addPackageTxs, we can just inline it, keep the comments, and avoid the
unnecessary interface and lock annotations.
2022-05-27 15:31:07 -04:00
Sebastian Falbesoner
387ae8bc09 rpc: remove deprecated fee fields from mempool entries 2022-05-27 17:29:04 +02:00
MacroFake
fa8aa0aa81
Pass Peer& to Misbehaving()
`Misbehaving` has several coding related issues (ignoring the conceptual
issues here for now):
* It is public, but it is not supposed to be called from outside of
  net_processing. Fix that by making it private and creating a public
  `UnitTestMisbehaving` method for unit testing only.
* It doesn't do anything if a `nullptr` is passed. It would be less
  confusing to just skip the call instead. Fix that by passing `Peer&`
  to `Misbehaving()`.
* It calls `GetPeerRef`, causing `!m_peer_mutex` lock annotations to be
  propagated. This is harmless, but verbose. Fix it by removing the no
  longer needed call to `GetPeerRef` and the no longer needed lock
  annotations.
2022-05-27 16:59:45 +02:00
fanquake
345457b542
Merge bitcoin/bitcoin#25214: multiprocess build fix: ipc/capnp/init.capnp.h: No such file or directory
44904aa632 multiprocess build cleanup: comment on manual dependencies (Ryan Ofsky)
6e1c16c144 multiprocess build fix: ipc/capnp/init.capnp.h: No such file or directory (Ryan Ofsky)

Pull request description:

  Error was reported by SatoriHoshiAiko in https://github.com/bitcoin/bitcoin/issues/25207 and happens unpredictably because make doesn't always build dependencies in the same order.

  The source file `src/ipc/capnp/protocol.cpp` includes some generated headers so needs to have an explicit dependency specified in the makefile so the headers will be generated before the file is compiled. #19160 added the explicit dependency, but it was incorrect because it referred to an old file path from before the source file was renamed (`ipc.cpp` -> `protocol.cpp`)

ACKs for top commit:
  hebasto:
    re-ACK 44904aa632

Tree-SHA512: 578ef4ef35a97e9d8d4e6d4edf39e57a32674234bf145e8159268324cb6ba15b420517afc07f6f42bb11a562954ea74af686c3fb92ce178c1fc378421b352531
2022-05-27 14:43:34 +01: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
MacroFake
57bf12523c
Merge bitcoin/bitcoin#24934: refactor, miner: Delete call to UpdatePackagesForAdded at beginning of addPackageTxs
7036cf52aa Delete UpdatePackagesForAdded at beginning of addPackageTxs. (KevinMusgrave)

Pull request description:

  In `CreateNewBlock` (in miner.cpp), `inBlock` is cleared before `addPackageTxs`, so `inBlock` will be empty in the first call to `UpdatePackagesForAdded`. I saw this brought up in these [PR review club logs](https://bitcoincore.reviews/24538) and there didn't seem to be a definitive answer for why the call is necessary. There's also an [old PR](https://github.com/bitcoin/bitcoin/pull/10200) where this change was going to be applied, but it got closed.

  If `addPackageTxs` can be called when `inBlock` is not empty, then maybe a test should be added for that case. All the tests seem to pass with this deletion.

ACKs for top commit:
  glozow:
    utACK 7036cf52aa

Tree-SHA512: 9e757b71b9035f68a0c6fef229b8cd83f1bdbe23f05bb02cc1bab8c3c177805b388bceb2bb1f0bce354791ccb29f351a6c51979b96ffe4d9fc6c978f83e36afc
2022-05-27 15:11:51 +02:00
laanwj
c5e67be03b
Merge bitcoin/bitcoin#24032: Add defaults to vDeployments to avoid uninitialized variables
c4c5b9ca6e consensus/params: set default values for BIP9Deployment (Anthony Towns)

Pull request description:

  Adds default values for `vDeployments` in `consensus/params.h` so that undefined behaviour is avoided if a deployment is not initialized. Also adds a check in the unit tests to alert if this is happening, since even if it doesn't invoke undefined behaviour it's probably a mistake.

ACKs for top commit:
  laanwj:
    Code review ACK c4c5b9ca6e

Tree-SHA512: 22d7ff86a817d9e9e67c47301fc3b7e9d5821c13565d7706711f113dea220eea29b413a7c8d029691009159cebc85a108d77cb52418734091c196bafb2b12423
2022-05-26 20:06:10 +02:00
Andrew Chow
a0e8aff605
Merge bitcoin/bitcoin#25003: tracing: fix coin_selection:aps_create_tx_internal calling logic
6b636730f4 tracing: fix `coin_selection:aps_create_tx_internal` calling logic (Sebastian Falbesoner)

Pull request description:

  According to the documentation, the tracepoint `coin_selection:aps_create_tx_internal` "Is called when the second `CreateTransactionInternal` with Avoid Partial Spends enabled completes."

  Currently it is only called if the second call to `CreateTransactionInternal` succeeds, i.e. the third parameter is always `true` and we don't get notified in the case that it fails. This PR fixes this by moving the tracepoint call and the `use_aps` boolean variable outside the if body.

ACKs for top commit:
  achow101:
    ACK 6b636730f4
  furszy:
    re-ACK 6b636730

Tree-SHA512: 453825123aa10748642c7dd94324ced2d07df0f4fac478b0947a34820b515ae300f75721679a90a164f3127029739df55c4de035c4567e663893c3c6dbdef216
2022-05-26 13:49:52 -04:00
Ryan Ofsky
e47c6c7656 Reset settings.json when GUI options are reset
Clear settings.json file and save settings.json.bak file when "Reset Options"
GUI button is pressed or -resetguisettings command line option is used.
2022-05-26 11:05:10 -04:00
MacroFake
2642dee136
Merge bitcoin/bitcoin#15936: interfaces: Expose settings.json methods to GUI
f9fdcec7e9 settings: Add resetSettings() method (Ryan Ofsky)
77fabffef4 init: Remove Shutdown() node.args reset (Ryan Ofsky)
0e55bc6e7f settings: Add update/getPersistent/isIgnored methods (Ryan Ofsky)

Pull request description:

  Add `interfaces::Node` `updateSetting`, `forceSetting`, `resetSettings`, `isSettingIgnored`, and `getPersistentSetting` methods so GUI is able to manipulate `settings.json` file and use and modify node settings.

  (Originally this PR also contained GUI changes to unify bitcoin-qt and bitcoind persistent settings and call these methods, but the GUI commits have been dropped from this PR and moved to bitcoin-core/gui/pull/602)

ACKs for top commit:
  vasild:
    ACK f9fdcec7e9
  hebasto:
    re-ACK f9fdcec7e9, only a function renamed since my recent [review](https://github.com/bitcoin/bitcoin/pull/15936#pullrequestreview-979324357).

Tree-SHA512: 4cac853ee29be96d2ff38404165b9dfb7c622b2a9c99a15979596f3484ffde0da3d9c9c372677dff5119ca7cffa6383d81037fd9889a29cc9285882a8dc0c268
2022-05-26 17:05:10 +02:00
Ryan Ofsky
504b06b1de Migrate -lang setting from QSettings to settings.json 2022-05-26 11:05:10 -04:00
Ryan Ofsky
9a016a3c07 Migrate -prune setting from QSettings to settings.json 2022-05-26 11:05:10 -04:00
Ryan Ofsky
f067e19433 Migrate -proxy and -onion settings from QSettings to settings.json 2022-05-26 11:05:10 -04:00
Ryan Ofsky
a09e3b7cf2 Migrate -listen and -server settings from QSettings to settings.json 2022-05-26 11:05:10 -04:00
Ryan Ofsky
d2ada6e635 Migrate -upnp and -natpmp settings from QSettings to settings.json
This also effectively reverts 58e8364dcd from
#18077, applying upnp and natpmp settings from the optionsmodel class instead
of the optionsdialog class. This makes sense because model code, not view code
is responsible for applying all other settings, and because leaving these
settings half-applied in optionsmodel seems error prone and could lead to bugs.
(These things were discussed a little in
https://github.com/bitcoin/bitcoin/pull/18077#discussion_r560381734)
2022-05-26 11:05:10 -04:00
Ryan Ofsky
1dc4fc29c1 Migrate -spendzeroconfchange and -signer settings from QSettings to settings.json 2022-05-26 11:05:10 -04:00
Ryan Ofsky
a7ef6d5975 Migrate -par setting from QSettings to settings.json 2022-05-26 11:05:10 -04:00
Ryan Ofsky
284f339de6 Migrate -dbcache setting from QSettings to settings.json
This is just the first of multiple settings that will be stored in the bitcoin
persistent setting file and shared with bitcoind, instead of being stored as Qt
settings backed by the windows registry or platform specific config files which
are ignored by bitcoind.

Co-Authored-By: furszy <matiasfurszyfer@protonmail.com>
2022-05-26 11:05:10 -04:00
laanwj
c324b07a54
Merge bitcoin/bitcoin#25210: doc: remove misleading AreInputsStandard() comment
be6d4315c1 doc: remove misleading AreInputsStandard() comment (James O'Beirne)

Pull request description:

  This check isn't any longer just about bad pay-to-script-hash inputs; it
  also excludes any kind of nonstandard input, unknown witness versions,
  coinbases, etc.

ACKs for top commit:
  laanwj:
    ACK be6d4315c1
  dunxen:
    ACK be6d431
  jonatack:
    ACK be6d4315c1

Tree-SHA512: 1c4befadff6a7b5789901ca2a2cc39adc35c688f7e3c093ab5292123f9193ce078731016b773b3d05f7004ff01ee62f23f8362ae8d05134d41dc097ba094a42b
2022-05-26 15:13:35 +02:00
laanwj
4901631dac
Merge bitcoin/bitcoin#25202: log: Use severity-based logging for leveldb/libevent messages, reverse LogPrintLevel order
c4e7717727 refactor: Change LogPrintLevel order to category, severity (laanwj)
ce920713bf leveldb: Log messages from leveldb with category and debug level (laanwj)
18ec120bb9 http: Use severity-based logging for messages from libevent (laanwj)
bd971bffb0 logging: Unconditionally log levels >= WARN (laanwj)

Pull request description:

  Log messages from leveldb and libevent libraries in the severity+level based log format introduced in bitcoin/bitcoin#24464.

  Example of messages before:
  ```
  2022-05-24T18:11:57Z [libevent] libevent: event_add: event: 0x55da963fcc10 (fd 10), EV_READ    call 0x7f1c7a254620
  2022-05-24T18:11:57Z [libevent] libevent: Epoll ADD(1) on fd 10 okay. Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none)
  2022-05-24T18:12:08Z leveldb: Generated table #609127@1: 6445 keys, 312916 bytes
  2022-05-24T18:12:08Z leveldb: Generated table #609128@1: 5607 keys, 268548 bytes
  2022-05-24T18:12:08Z leveldb: Generated table #609129@1: 189 keys, 9384 bytes
  2022-05-24T18:12:08Z leveldb: Generated table #609130@1: 293 keys, 13818 bytes
  ```

  Example of messages after:
  ```
  2022-05-24T17:59:52Z [libevent:debug] event_add: event: 0x5652f44dac10 (fd 10), EV_READ    call 0x7f210f2e6620
  2022-05-24T17:59:52Z [libevent:debug] Epoll ADD(1) on fd 10 okay. Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none)
  2022-05-24T17:59:53Z [leveldb:debug] Recovering log #1072
  2022-05-24T17:59:53Z [leveldb:debug] Level-0 table #1082: started
  2022-05-24T17:59:53Z [leveldb:debug] Level-0 table #1082: 193 bytes OK
  2022-05-24T17:59:53Z [leveldb:debug] Delete type=3 #1070
  2022-05-24T17:59:53Z [leveldb:debug] Delete type=0 #1072
  ```

  The first commit changes it so that messages with level Warning and Error are always logged independent of the `-debug` setting. I think this is useful to make sure warnings and errors, which tend to be important, are not lost. In the future this should be made more configurable.

  Last commit changes LogPrintLevel argument order to category, severity: This is more consistent with the other functions, as well as with the logging output itself. If we want to make this change, we should do it before it's all over the place.

ACKs for top commit:
  jonatack:
    Tested ACK c4e7717727

Tree-SHA512: ea48a1517f8c1b23760e59933bbd64ebf09c32eb947e31b8c2696b4630ac1f4303b126720183e2de052bcede3a17e475bbf3fbb6378a12b0fa8f3582d610930d
2022-05-26 15:04:07 +02:00
laanwj
cacbdbaa95
Merge bitcoin/bitcoin#25132: consensus: Add BIP-341 specified constraints in ComputeTaprootMerkleRoot
bd7c5e2f0a Add BIP-341 specified constraints to `ComputeTaprootMerkleRoot` (David Bakin)

Pull request description:

  [**N.B.:** This PR **_does not change the consensus_**.  It only adds `assert` statements according to the current consensus in consensus-sensitive code (`interpreter.cpp`). So that's why the bot added the "consensus" tag and I prefixed the PR title with "consensus".]

  BIP 341 specifies [constraints on the size of the control block _c_ used to compute the taproot merkle root](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#script-validation-rules).

  > The last stack element is called the control block _c_, and must have length _33 + 32m_, for a value of _m_ that is an integer between 0 and 128, inclusive. Fail if it does not have such a length.

  The actual merkle root is computed in `ComputeTaprootMerkleRoot` ([interpreter.cpp@1833](https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L1833)) - this code does _not_ check these constraints.

  All the callers do check the constraints before calling `ComputeTaprootMerkleRoot`.  But in the future there may be more callers, and these checks may be inadvertently omitted at those future calls.  Also, code at/near the current call sites may also change and skip these checks.  Therefore _this PR adds those checks as `asserts` directly in `ComputeTaprootMerkleRoot`_ to help prevent that error.

  No unit tests provided: they'd have to be death tests as these are `assert` statements which raise `SIGABRT` and kill the program.  Boost Test has a way to implement death tests (see the in-progress draft PR #25097 at [this code (you may have to click to expand the diff)](https://github.com/bitcoin/bitcoin/pull/25097/files#diff-21483d0e032747850208f21325b29cde89e9c1f55f83a7a166a388cc5c27115aR1089) and could be added here if desired by reviewers.

  Current callers of `ComputeTaprootMerkleRoot`:
  - `InferTaprootTree` ([standard.cpp@1552](https://github.com/bitcoin/bitcoin/blob/master/src/script/standard.cpp#L546))
  - `VerifyTaprootCommittment` ([interpreter.cpp@1859](https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L1859)) does a partial check, but it is called from `VerifyWitnessProgram` ([interpreter.cpp@1922](https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L1918)) where a full check is done

ACKs for top commit:
  sipa:
    ACK bd7c5e2f0a
  theStack:
    ACK bd7c5e2f0a

Tree-SHA512: cec5aebfdf9fc9d13011abdf8427c934edf1df1ffc32b3e7cc5580f12809f24cf83e64ab0c843fabfce3591873bfcfa248277b30820fd786684319a196e4e550
2022-05-26 14:34:04 +02:00
Ryan Ofsky
44904aa632 multiprocess build cleanup: comment on manual dependencies
Also move manual dependency closer to actual build target
2022-05-25 18:01:22 -04:00
Carl Dong
03574b956a tree-wide: clang-format CTxMemPool references
[META] Do this so that we can more easily grep for all actual instances
       of CTxMemPool construction.
2022-05-25 16:54:23 -04:00
David Bakin
bd7c5e2f0a Add BIP-341 specified constraints to ComputeTaprootMerkleRoot
BIP 341 specifies constraints on the size of the control block _c_ used
to compute the taproot merkle root.

> The last stack element is called the control block _c_, and must have
> length _33 + 32m_, for a value of m that is an integer between 0 and
> 128, inclusive. Fail if it does not have such a length.

(See BIP-341 "Script Validation Rules" here: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#script-validation-rules)
2022-05-25 12:51:01 -07:00
furszy
c97e961d46
fuzz: coinselection, add missing fee rate.
Otherwise, 'GroupOutputs' will crash at group insertion time (output.GetEffectiveValue() asserts that the value exists).
2022-05-25 14:07:33 -03:00
Ryan Ofsky
6e1c16c144 multiprocess build fix: ipc/capnp/init.capnp.h: No such file or directory
Error was reported by SatoriHoshiAiko in
https://github.com/bitcoin/bitcoin/issues/25207 and happens unpredictably
because make doesn't always build dependencies in the same order.

The source file src/ipc/capnp/protocol.cpp includes some generated headers so
needs to have an explicit dependency specified in the makefile so the headers
will be generated before the file is compiled. #19160 added the explicit
dependency, but it was incorrect because it referred to an old file path from
before the source file was renamed (ipc.cpp -> protocol.cpp)
2022-05-25 11:40:51 -04:00
James O'Beirne
be6d4315c1 doc: remove misleading AreInputsStandard() comment
This check isn't any longer just about bad pay-to-script-hash inputs; it
also excludes any kind of nonstandard input, unknown witness versions,
coinbases, etc.
2022-05-25 08:03:45 -04:00
laanwj
c4e7717727 refactor: Change LogPrintLevel order to category, severity
This is more consistent with the other functions, as well as with the
logging output itself. If we want to make this change, we should do it
before it's all over the place.
2022-05-25 11:31:58 +02:00
laanwj
ce920713bf leveldb: Log messages from leveldb with category and debug level 2022-05-25 11:26:15 +02:00
laanwj
18ec120bb9 http: Use severity-based logging for messages from libevent
Map libevent's severity to our own severity level for logging.
2022-05-25 11:26:15 +02:00
laanwj
bd971bffb0 logging: Unconditionally log levels >= WARN
Messages with level `WARN` or higher should be logged even when
the category is not provided with `-debug=`, to make sure important
warnings are not lost.
2022-05-25 11:26:15 +02:00
MarcoFalke
fa27ee88ed
Get time less often in AddrManImpl::ResolveCollisions_()
This makes the code less verbose. Also, future changes that change how
to get the time are less verbose.

Moreover, GetAdjustedTime() might arbitrarily change the value during
the execution of this function. For example, the system time advances
over a second boundary, or the network adjusts the time arbitrarily.
Most of the time however the value will not change, so it seems better
to always lock the value in this scope for clarity.
2022-05-25 10:57:08 +02:00
Ben Woosley
f565b2836d
Fixup option name in bench message 2022-05-25 00:26:38 -05: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
90e49c1ece
Merge bitcoin/bitcoin#24464: logging: Add severity level to logs
e11cdc9303  logging: Add log severity level to net.cpp (klementtan)
a8290649a6 logging: Add severity level to logs. (klementtan)

Pull request description:

  **Overview**: This PR introduces a new macro, `LogPrintLevel`, that allows developers to add logs with the severity level. Additionally, it will also print the log category if it is specified.

  Sample log:
  ```
  2022-03-04T16:41:15Z [opencon] [net:debug] trying connection XX.XX.XXX.XXX:YYYYY lastseen=2.7hrs
  ```

  **Motivation**: This feature was suggested in #20576 and I believe that it will bring the following benefits:
  * Allow for easier filtering of logs in `debug.log`
  * Can be extended to allow users to select the minimum level of logs they would like to view (not in the scope of this PR)

  **Details**:
  * New log format. `... [category:level]...`. ie:
    * Do not print category if `category == NONE`
    * Do not print level if `level == NONE`
    * If `category == NONE` and `level == NONE`, do not print any fields (current behaviour)
  * Previous logging functions:
    * `LogPrintf`:  no changes in log as it calls `LogPrintf_` with `category = NONE` and `level = NONE`
    * `LogPrint`: prints additional `[category]` field as it calls `LogPrintf_` with `category = category` and `level = NONE`
  * `net.cpp`: As a proof of concept, updated logs with obvious severity (ie prefixed with `Warning/Error:..`) to use the new logging with severity.

  **Testing**:
  * Compiling and running `bitcoind` with this PR should instantly display logs with the category name (ie `net/tor/...`)
  * Grepping for `net:debug` in `debug.log` should display the updated logs with severity level:
    <details>
    <summary>Code</summary>

    ```
    $ grep "net:debug" debug.log

    2022-03-04T16:41:15Z [opencon] [net:debug] trying connection XXX:YYY lastseen=2.7hrs
    2022-03-04T16:41:16Z [opencon] [net:debug] trying connection XXX:YYY lastseen=16.9hrs
    2022-03-04T16:41:17Z [opencon] [net:debug] trying connection XXX:YYY lastseen=93.2hrs
    2022-03-04T16:41:18Z [opencon] [net:debug] trying connection XXX:YYY lastseen=2.7hrs
    ```
    </details>

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

Tree-SHA512: 89a8c86667ccc0688e5acfdbd399aac1f5bec9f978a160e40b0210b0d9b8fdc338479583fc5bd2e2bc785821363f174f578d52136d228e8f638a20abbf0a568f
2022-05-24 19:32:45 +02: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
Hennadii Stepanov
8898906370
Merge bitcoin-core/gui#593: Getting ready to Qt 6 (8/n). Use QRegularExpression in AddressBookSortFilterProxyModel class
e280087946 qt: Use `QRegularExpression` in `AddressBookSortFilterProxyModel` class (Hennadii Stepanov)
5c5d8f2465 qt, test: Add tests for searching in `AddressBookPage` dialog (Hennadii Stepanov)

Pull request description:

  This is a step in [migration](https://github.com/bitcoin/bitcoin/pull/24798) to Qt 6.

  Related:
  - bitcoin-core/gui#578
  - bitcoin-core/gui#585

  No behavior change. To ensure this, tests have been added.

ACKs for top commit:
  hebasto:
    > tACK [e280087](e280087946) on Ubuntu 21.10 Qt 5.15.2
  promag:
    Tested ACK e280087946 with Qt6 on macOS 12 M1.
  w0xlt:
    tACK e280087946 on Ubuntu 21.10 Qt 5.15.2
  jarolrod:
    Tested ACK e280087946 on M1 mac, x86 mac, x86 Linux with Qt5 and separately with Qt6

Tree-SHA512: 664baacc1504deb2f7fa651ea4a44f3942f5c9058befe4d2ce292beed032d4b1697710cfd10c0909602d8a4a6eeb680414e4a1f56d2038478c1ae2f34965d74f
2022-05-24 10:52:18 +02:00
Hennadii Stepanov
1368634433
Merge bitcoin-core/gui#601: refactor: Pass interfaces::Node references to OptionsModel constructor
31122aa979 refactor: Pass interfaces::Node references to OptionsModel constructor (Ryan Ofsky)

Pull request description:

  Giving OptionsModel access to the node interface is needed as part of #602 to get bitcoind and bitcoin-qt to use the same settings instead of different settings.

  It has been split off from #602 to simplify that PR. Previously these commits were part of bitcoin/bitcoin#15936 and also had some review discussion there.

ACKs for top commit:
  promag:
    Code review ACK 31122aa979.
  furszy:
    Code ACK 31122aa9
  jarolrod:
    ACK 31122aa979

Tree-SHA512: b8529322fd7ba97e19864129e6cf5f9acc58c124f2e5a7c50aca15772c8549de3c24e8b0c27e8cf2c06fd26529e9cdb898b0788a1de3cbfdfbdd3f85c9f0fe69
2022-05-24 10:48:27 +02:00
MacroFake
aa5cd3cc6d
Merge bitcoin/bitcoin#25149: refactor: Add thread safety annotation to BanMan::SweepBanned()
ab75388320 refactor: Remove redundant scope in `BanMan::SweepBanned()` (Hennadii Stepanov)
52c0b3e859 refactor: Add thread safety annotation to `BanMan::SweepBanned()` (Hennadii Stepanov)
3919059deb refactor: Move code from ctor into private `BanMan::LoadBanlist()` (Hennadii Stepanov)

Pull request description:

  This PR adds a proper thread safety annotation to `BanMan::SweepBanned()`.

  Also a simple refactoring applied.

ACKs for top commit:
  ajtowns:
    ACK ab75388320
  w0xlt:
    ACK ab75388320
  theStack:
    Code-review ACK ab75388320

Tree-SHA512: 8699079c308454f3ffe72be2e77f0935214156bd509f9338b1104f8d128bfdd02ee06ee8c1c99b2eefdf317a00edd555d52990caaeb1ed4540eedc1e3c9d1faf
2022-05-24 09:14:58 +02:00
Carl Dong
664a14ba7c coinstats: Move GetUTXOStats to rpc/blockchain
rpc/blockchain.cpp is now the only user of the vestigial
GetUTXOStats(...). And since GetUTXOStats(...)'s special fallback logic
was only really relevant/meant for rpc/blockchain.cpp, we can just move
it there.
2022-05-23 15:19:29 -04: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
faa52387e8 style-only: Rearrange using decls after scripted-diff 2022-05-23 14:53:35 -04:00
Carl Dong
f329a9298c scripted-diff: Move src/kernel/coinstats to kernel::
Introduces a new kernel:: namespace and move all of src/kernel/coinstats
under it.

In the verify script, lines like:

line="$(grep -n 'namespace node {' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)"
sed -i -e "${line}s@namespace node {@namespace kernel {@" -- src/kernel/coinstats.h

Are intended to replace only the last instance of "namespace node" with
"namespace kernel", this is to avoid replacing forward declarations of
things inside the node:: namespace.

-BEGIN VERIFY SCRIPT-
sed -E -i 's@namespace node@namespace kernel@g' -- src/kernel/coinstats.cpp

line="$(grep -n 'namespace node {' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)"
sed -i -e "${line}s@namespace node {@namespace kernel {@" -- src/kernel/coinstats.h

line="$(grep -n '// namespace node' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)"
sed -i -e "${line}s@// namespace node@// namespace kernel@" -- src/kernel/coinstats.h

things='(CCoinsStats|CoinStatsHashType|GetBogoSize|TxOutSer|ComputeUTXOStats)'
git grep -lE 'node::'"$things" | xargs sed -E -i 's@node::'"$things"'@kernel::\1@g'
sed -E -i 's@'"$things"'@kernel::\1@g' -- src/node/coinstats.cpp src/node/coinstats.h
sed -E -i 's@BlockManager@node::\0@g' -- src/kernel/coinstats.cpp
-END VERIFY SCRIPT-
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
Carl Dong
80970985c9 coinstats: Split node/coinstats.h to kernel/coinstats.h
Most of this commit is pure-move.

After this change:

- kernel/coinstats.h
    -> Contains declarations for:
       - enum class CoinStatsHashType
       - struct CCoinsStats
       - GetBogoSize(...)
       - TxOutSer(...)
       - ComputeUTXOStats(...)
- node/coinstats.h
    -> Just GetUTXOStats, which will be removed as we change callers to
       directly use the hashing/indexing codepaths in future commits.
2022-05-23 14:53:35 -04:00
Carl Dong
35f73ce4b2 coinstats: Move hasher codepath to kernel/coinstats
As mentioned in a previous commit, the hashing codepath can now be moved
to a separate file. This decouples callers that only rely on the hashing
codepath from the indexing one.

This is key for libbitcoinkernel, which needs to have the CoinsStats
hashing codepath for AssumeUTXO, but does not wish to be coupled with
indexes.

Note that only the .cpp file is split in this commit, the header files
will be split in a subsequent commit and the #includes to
node/coinstats.h will be adjusted to only #include the necessary
headers.
2022-05-23 14:53:31 -04:00
Carl Dong
b7634fe02b Move logic from LookupUTXOStatsWithIndex to CoinStatsIndex::LookUpStats
The indexing codepath logic in node/coinstats.cpp is simple enough to be
moved into CoinStatsIndex::LookUpStats, avoiding an additional layer of
function calls. Callers are modified accordingly.

Also, add 2 missed BOOST_CHECKs to the coinstatsindex_initial_sync unit
test.
2022-05-23 14:52:25 -04:00
Carl Dong
1352e410a5 coinstats: Separate hasher/index lookup codepaths
Split out ComputeUTXOStats and LookupUTXOStatsWithIndex from
GetUTXOStats, since the hashing and indexing codepaths are quite
disparate in practice.

Also allow add a constructor to CCoinsStats for it to be constructed
from a a block height and hash. This is used in both codepaths.

Also add a note in GetUTXOStats documenting a behaviour quirk that
predates this patchset.

[META] This allows the hashing codepath to be moved to a separate file
       in a future commit, decoupling callers that only rely on the
       hashing codepath from the indexing one. This is key for
       libbitcoinkernel, which needs to have the hashing codepath for
       AssumeUTXO, but does not wish to be coupled with indexes.
2022-05-23 14:52:23 -04:00
Carl Dong
524463daf6 coinstats: Return purely out-param CCoinsStats
In previous commits in this patchset, we removed all in-param members of
CCoinsStats. Now that that's done, we can modify GetUTXOStats to return
an optional CCoinsStats instead of a status bool. Callers are modified
accordingly.

In rpc/blockchain.cpp, we discover that GetUTXOStats' status bool when
getting UTXO stats for pprev was not checked for error. We fix this as
well.
2022-05-23 14:50:35 -04:00
MacroFake
44037a2912
Merge bitcoin/bitcoin#25176: Fix frequent -netinfo JSON errors from missing getpeerinfo#relaytxes
a17c5e96b6 Rename NetinfoRequestHandler::is_block_relay data member to is_tx_relay (Jon Atack)
f0bb7db34c Fix frequent -netinfo JSON errors from null getpeerinfo#relaytxes (Jon Atack)

Pull request description:

  CLI -netinfo frequently returns "error: JSON value is not a boolean as expected" since the merge of #21160, which moved fRelayTxes (renamed to m_relay_txs in that pull) from CNodeStats to CNodeStateStats.

  This change made getpeerinfo "relaytxes" an optional field that can return UniValue IsNull(). It is the only optional field consumed by -netinfo where the latter didn't already handle that case. See also https://github.com/bitcoin/bitcoin/pull/24691.

  Also rename the NetinfoRequestHandler::is_block_relay data member to is_tx_relay and inverse its boolean logic. The naming is out of date and incorrect, as lack of request of tx relay does not imply block relay, and a preference for tx relay doesn't imply that block relay isn't happening. Thanks to Marco Falke and Martin Zumsande for their feedback on this.

  (I may look at reducing the number of optional node stats fields via refactoring at the net processing level, but ongoing refactoring there may make that slow or complicated and this is a one-line fix that works now.)

ACKs for top commit:
  mzumsande:
    Code review ACK a17c5e96b6

Tree-SHA512: dc54ce80b78122874a6794555f99e5b328a1574b52bb3e7f974c699c2b759a60ea0807a6483c5bc0414a950d853c0eeeb13dcc1b790d3917c6ee4c9c99fe159f
2022-05-23 19:03:10 +02:00
Andrew Chow
3368f84c43
Merge bitcoin/bitcoin#25083: Set effective_value when initializing a COutput
6fbb0edac2 Set effective_value when initializing a COutput (ishaanam)

Pull request description:

  Previously in COutput, effective_value was initialized as the absolute value of the txout and the fee as 0. effective_value along with the fee was calculated outside of the COutput constructor and set after the object had been initialized.
  These changes will allow either the fee or the feerate to be passed in a COutput constructor and the fee and effective_value are calculated and set in the constructor. As a result, AvailableCoins also needs to be passed the feerate when utxos are being spent. When balance is calculated or the coins are being listed and feerate is neither available nor required, AvailableCoinsListUnspent is used instead, which runs AvailableCoins while providing the default value for `feerate`. Unit tests for the calculation of effective value have also been added.

ACKs for top commit:
  achow101:
    re-ACK 6fbb0edac2
  Xekyo:
    re-ACK 6fbb0edac2
  w0xlt:
    Code Review ACK 6fbb0edac2
  furszy:
    Looks good, have been touching this area lately, code review ACK 6fbb0eda.

Tree-SHA512: 5943ee4f4b0c1dcfe146f2fc22853e607259d6d53156b80a8a8f4baa70760a8b25ab822777b7f5d21ecb02dac08bdee704a9a918d5660276d6994b19a284b256
2022-05-23 12:55:24 -04: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
MacroFake
66e3b16b8b
Merge bitcoin/bitcoin#25184: refactor: Remove defunct attributes.h includes
71a8dbe5da refactor: Remove defunct attributes.h includes (Ben Woosley)

Pull request description:

  Since the removal of NODISCARD in 81d5af42f4,
  the only attributes.h def is LIFETIMEBOUND, and it's included in many more
  places that it is used.

  This removes all includes which do not have an associated use of LIFETIMEBOUND,
  and adds it to the following files, due to their use of the same:
  * src/validationinterface.h
  * src/script/standard.h

  See also #20499.

Top commit has no ACKs.

Tree-SHA512: f3e10a5cda5ab78371b77b702f4a241ff69d490a16cc6059f1a4202b97c584accdbc951cc7b6120eae94bee3b9249e9117b45cf6ed1a5228ca23b5638fcf7b7b
2022-05-23 09:41:02 +02:00
Hennadii Stepanov
dfe11a1a7e
Merge bitcoin-core/gui#586: Getting ready to Qt 6 (6/n). Replace QCoreApplication::quit() with QCoreApplication::exit(0)
252f363f2f qt: Replace `QCoreApplication::quit()` with `QCoreApplication::exit(0)` (Hennadii Stepanov)

Pull request description:

  ### Qt 5:
   - no behavior change.

  See https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qcoreapplication.cpp?h=5.15#n2012:
  ```cpp
  void QCoreApplication::quit()
  {
      exit(0);
  }
  ```

  ### Qt 6:
   - this change avoids sending a duplicated `QEvent::Quit`

  We use `QEvent::Quit` to [handle](https://github.com/bitcoin-core/gui/pull/547) macOS dock menu events. Qt 6 uses `QEvent::Quit` more [widely](89f7a2759c). We do not want a duplicated `QEvent::Quit` which fires `Assert(node.args);` in the [`Shutdown()`](d1b3dfb275/src/init.cpp (L200)) function.

ACKs for top commit:
  promag:
    Code review ACK 252f363f2f.

Tree-SHA512: 6a04cbcf523c0375158a59b29afadf18da99738c8db8b8728f99319a8cdc10806d2f06dc5a7d3b8b0e1a5f1711be778a75d4ecdefef7cf66e26ae2848f7f57db
2022-05-23 08:57:41 +02:00
Hennadii Stepanov
b0e16eb3ac
Merge bitcoin-core/gui#600: refactor: Add OptionsModel getOption/setOption methods
a63b60f02b refactor: Add OptionsModel getOption/setOption methods (Ryan Ofsky)

Pull request description:

  This is a trivial change which is needed as part of #602 to get bitcoind and bitcoin-qt to use the same settings instead of different settings. It is split off from #602 because it causes a lot of rebase conflicts (any time there is a GUI options change).

  This PR is very small and easy to review ignoring whitespace: https://github.com/bitcoin-core/gui/pull/600/files?w=1

ACKs for top commit:
  vasild:
    ACK a63b60f02b
  furszy:
    Code review ACK a63b60f0
  promag:
    Code review ACK a63b60f02b.

Tree-SHA512: 1d99a1ce435b4055c1a38d2490702cf5b89bacc7d168c9968a60550bfd9f6dace649d5e98699de68d6305f02d5d1e3eb7e177ab578b98b996dd873b1df0ed236
2022-05-22 20:12:41 +02:00
Calvin Kim
e734228d85 Update GCSFilter benchmarks
Element count used in the GCSFilter benchmarks are increased to 100,000
from 10,000. Testing the benchmarks with different element counts showed
that a filter with 100,000 elements resulted in the same ns/op. This
this a desirable thing to have as it allows us to reason about how long
a single filter element takes to process, letting us easily calculate
how long a filter with N elements (where N > 100,000) would take to
process.

GCSFilterConstruct benchmark is now called without batch. This makes
intra-bench results more intuitive as all benchmarks are in ns/op
instead of a custom unit. There are no downsides to this change as
testing showed that there is no observable difference in error rates
in the benchmarks when calling without batch.
2022-05-22 14:17:15 +09:00
Patrick Strateman
aee9a8140b Add GCSFilterDecodeSkipCheck benchmark
This benchmark allows us to compare the differences between doing the
sanity check for corruption via GolombRiceDecode() vs checking the hash
of the encoded block filter.
2022-05-22 14:00:41 +09:00
Patrick Strateman
299023c1d9 Add GCSFilterDecode and GCSBlockFilterGetHash benchmarks.
All of the benchmarks are standardized on the BASIC filter parameters
so we can compare between all the benchmarks. All the GCS
benchmarks are renamed to have "GCS" as the prefix.
2022-05-22 13:46:26 +09:00
Ben Woosley
71a8dbe5da
refactor: Remove defunct attributes.h includes
Since the removal of NODISCARD in 81d5af42f4,
the only attributes def is LIFETIMEBOUND, and it's included in many more
places that it is used.

This removes all includes which do not have an associated use of LIFETIMEBOUND,
and adds it to the following files, due to their use of the same:
* src/validationinterface.h
* src/script/standard.h
2022-05-21 13:54:33 -05:00
Hennadii Stepanov
e280087946
qt: Use QRegularExpression in AddressBookSortFilterProxyModel class
Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
2022-05-21 17:44:57 +02:00
Hennadii Stepanov
5c5d8f2465
qt, test: Add tests for searching in AddressBookPage dialog 2022-05-21 17:42:36 +02:00
ishaanam
6fbb0edac2 Set effective_value when initializing a COutput
Previously in COutput, effective_value was initialized as the absolute
value of the txout, and fee as 0. effective_value along with fee were
calculated outside of the COutput constructor and set after the
object had been initialized. These changes will allow either the fee
or the feerate to be passed in a COutput constructor. If either are
provided, fee and effective_value are calculated and set in the
constructor. As a result, AvailableCoins also needs to be passed the
feerate when utxos are being spent. When balance is calculated or the
coins are being listed and feerate is neither available nor required,
AvailableCoinsListUnspent is used instead, which runs AvailableCoins
while providing the default value for feerate. Unit tests for the
calculation of effective value have also been added.
2022-05-21 11:25:54 -04:00
Hennadii Stepanov
252f363f2f
qt: Replace QCoreApplication::quit() with QCoreApplication::exit(0)
Qt 5:
 - no behavior change

Qt 6:
 - this change avoids sending a duplicated `QEvent::Quit`
2022-05-21 16:57:31 +02:00
Carl Dong
46eb9fc56a coinstats: Extract index_requested in-member to in-param
This change removes CCoinsStats' index_requested in-param member and
adds it to the relevant functions instead.
2022-05-20 16:33:24 -04:00
Carl Dong
a789f3f2b8 coinstats: Extract hash_type in-member to in-param
Currently, CCoinsStats is a struct with both in-params and out-params
where the hash_type and index_requested members are the only in-params.

This change removes CCoinsStats' hash_type in-param member and adds it
to the relevant functions instead.

[META] In subsequent commits, all of CCoinsStats' members which serve as
       in-params will be moved out so as to make CCoinsStats a pure
       out-param struct.
2022-05-20 16:33:24 -04:00
Carl Dong
102294898d includes: Remove rpc/util.h -> node/coinstats.h
Confirmed with IWYU that this is unnecessary.
2022-05-20 16:33:24 -04:00
Carl Dong
0848db9c35 fuzz: Remove useless GetUTXOStats fuzz case
In the GetUTXOStats fuzz case, GetUTXOStats is always called with a
CCoinsViewCache. Which is guaranteed to throw a std::logic_error when
its ::Cursor() method is called on the first line of GetUTXOStats.

In the fuzz case, we basically catch this logic error and declare
victory if we caught it.

There is no point to fuzzing this deterministic logic.

Confirmed with IWYU that the node/coinstats.h #include is no longer
necessary.
2022-05-20 16:33:24 -04:00
Carl Dong
52b1939993 kernel: Remove unnecessary blockfilter{index,}.cpp
It is no longer necessary to link in blockfilter.cpp and
index/blockfilterindex.cpp after merge of PR#21726 since validation has
been decouple from the blockfilterindex.
2022-05-20 16:33:24 -04: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
640eb772e5
Merge bitcoin/bitcoin#25064: [kernel 2b/n] Add ChainstateManager::m_adjusted_time_callback
53494bc739 validation: Have ChainstateManager own m_chainparams (Carl Dong)
04c31c1295 Add ChainstateManager::m_adjusted_time_callback (Carl Dong)
dbe45c34f8 Add ChainstateManagerOpts, using as ::Options (Carl Dong)

Pull request description:

  ```
  This decouples validation.cpp from netaddress.cpp (transitively,
  timedata.cpp, and asmap.cpp).

  This is important for libbitcoinkernel as:

  - There is no reason for the consensus engine to be coupled with
    netaddress, timedata, and asmap
  - Users of libbitcoinkernel can now easily supply their own
    std::function that provides the adjusted time.

  See the src/Makefile.am changes for some satisfying removals.
  ```

Top commit has no ACKs.

Tree-SHA512: a093ec6ecacdc659d656574f05bd31ade6a6cdb64d5a97684f94ae7e55c0e360b78177553d4d1ef40280192674464d029a0d68e96caf8711d9274011172f1330
2022-05-20 19:40:01 +01:00
MacroFake
aac99faa66
Merge bitcoin/bitcoin#25175: refactor: Improve thread safety analysis by propagating some negative capabilities
2b3373c152 refactor: Propagate negative `!m_tx_relay_mutex` capability (Hennadii Stepanov)
5a6e3c1db3 refactor: Propagate negative `!m_most_recent_block_mutex` capability (Hennadii Stepanov)

Pull request description:

  This PR is a follow-up for bitcoin/bitcoin#22778 and bitcoin/bitcoin#24062, and it seems [required](https://github.com/bitcoin/bitcoin/pull/24931#issuecomment-1132800173) for bitcoin/bitcoin#24931.

  See details in the commit messages.

ACKs for top commit:
  ajtowns:
    ACK 2b3373c152
  w0xlt:
    ACK 2b3373c152

Tree-SHA512: 8a4bb9641af8d79824ec12e2d6bfce0e09524094b298a2edcdb2ab115fbaa21215b9c97a6b059f8aa023551071fd5798eca66ab8d262a3f97246a91d960850d0
2022-05-20 18:43:09 +01:00
Andrew Chow
3aa851ad2a
Merge bitcoin/bitcoin#24820: test: 3 new tests for SelectCoins function
3f8def51d5 add 3 new test cases for SelectCoins() (akankshakashyap)

Pull request description:

  Three new tests have been added.

  1. More coins should be selected when effective fee < long term fee.
  2. Less coin should be selected when effective fee > long term fee.
  3. If a coin is preselected, it should be selected even if disadvantageous.

ACKs for top commit:
  achow101:
    ACK 3f8def51d5
  brunoerg:
    ACK 3f8def51d5

Tree-SHA512: 8db6dd942b02a38c99953b801605f98c4c17729768fdfcf7605c5bbdb17509500a39d0a78a4b19aab37812d2994ec7630d2b4e78d1d348f1c27b67588d74e155
2022-05-20 12:06:30 -04:00
Carl Dong
53494bc739 validation: Have ChainstateManager own m_chainparams
We want m_chainparams to be alive for the duration of
ChainstateManager's lifetime since ChainstateManager's behaviour depends
on m_chainparams.

We could allow for a std::shared_ptr to be passed in as m_chainparams,
but that complicates things further. Given that CChainParams is not an
entity class or struct, we can just copy it and have ChainstateManager
own it.
2022-05-20 11:57:54 -04:00
Carl Dong
04c31c1295 Add ChainstateManager::m_adjusted_time_callback
This decouples validation.cpp from netaddress.cpp (transitively,
timedata.cpp, and asmap.cpp).

This is important for libbitcoinkernel as:

- There is no reason for the consensus engine to be coupled with
  netaddress, timedata, and asmap
- Users of libbitcoinkernel can now easily supply their own
  std::function that provides the adjusted time.

See the src/Makefile.am changes for some satisfying removals.
2022-05-20 11:57:51 -04:00
Carl Dong
dbe45c34f8 Add ChainstateManagerOpts, using as ::Options
[META] Although it seems like we don't need it for just one option,
       we're going to introduce another member to this struct *in the
       next commit*. In future patchsets for libbitcoinkernel decoupling
       it from ArgsManager, even more members will be added here.
2022-05-20 11:54:18 -04:00
Anthony Towns
d2852917ee sync.h: Imply negative assertions when calling LOCK 2022-05-21 01:23:23 +10:00
Anthony Towns
bba87c0553 scripted-diff: Convert global Mutexes to GlobalMutexes
-BEGIN VERIFY SCRIPT-
sed -i -E -e '/^([a-z]+ )?Mutex [a-z]/ s/Mutex/GlobalMutex/' $(git grep -lE '^([a-z]+ )?Mutex [a-z]')
-END VERIFY SCRIPT-
2022-05-21 01:23:23 +10:00
Anthony Towns
a559509a0b sync.h: Add GlobalMutex type 2022-05-21 01:23:23 +10:00
Anthony Towns
be6aa72f9f qt/clientmodel: thread safety annotation for m_cached_tip_mutex 2022-05-21 01:23:02 +10:00
Anthony Towns
f24bd45b37 net_processing: thread safety annotation for m_tx_relay_mutex 2022-05-21 01:22:43 +10:00
Jon Atack
a17c5e96b6 Rename NetinfoRequestHandler::is_block_relay data member to is_tx_relay
and inverse its logic.

The naming is out of date and incorrect, as lack of request of tx relay does not
imply block relay, and a preference for tx relay doesn't imply that block relay
isn't happening.
2022-05-20 16:06:07 +02:00
Hennadii Stepanov
ab75388320
refactor: Remove redundant scope in BanMan::SweepBanned() 2022-05-20 15:20:42 +02:00
Hennadii Stepanov
52c0b3e859
refactor: Add thread safety annotation to BanMan::SweepBanned() 2022-05-20 15:17:00 +02:00
Hennadii Stepanov
3919059deb
refactor: Move code from ctor into private BanMan::LoadBanlist()
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2022-05-20 15:15:45 +02:00
MacroFake
4d0c00dffd
Merge bitcoin/bitcoin#25168: refactor: Avoid passing params where not needed
fa1b76aeb0 Do not call global Params() when chainman is in scope (MacroFake)
fa30234be8 Do not pass CChainParams& to PeerManager::make (MacroFake)
fafe5c0ca2 Do not pass CChainParams& to BlockAssembler constructor (MacroFake)
faf012b438 Do not pass Consensus::Params& to Chainstate helpers (MacroFake)
fa4ee53dca Do not pass time getter to Chainstate helpers (MacroFake)

Pull request description:

  It seems confusing to pass chain params, consensus params, or a time function around when it is not needed.

  Fix this by:

  * Inlining the passed time getter function. I don't see a use case why this should be mockable.
  * Using `chainman.GetConsensus()` or `chainman.GetParams()`, where possible.

ACKs for top commit:
  promag:
    Code review ACK fa1b76aeb0.
  vincenzopalazzo:
    ACK fa1b76aeb0

Tree-SHA512: 1abff5cba4b4871d97f17dbcdf67bc9255ff21fa4150a79a74e39b28f0610eab3e7dee24d56872dd6e111f003b55e288958cdd467e6218368d896f191e4ec9cd
2022-05-20 13:35:15 +01:00
Jon Atack
f0bb7db34c Fix frequent -netinfo JSON errors from null getpeerinfo#relaytxes
"error: JSON value is not a boolean as expected"

due to fRelayTxes/m_relay_txs being moved in PR 21160 from CNodeStats to
CNodeStateStats, which made getpeerinfo#relaytxes an optional field that
can return UniValue IsNull().
2022-05-20 14:33:12 +02:00
Hennadii Stepanov
2b3373c152
refactor: Propagate negative !m_tx_relay_mutex capability
Could be verified with
$ ./configure CC=clang CXX=clang++ CXXFLAGS='-Wthread-safety -Wthread-safety-negative'
$ make clean
$ make 2>&1 | grep m_tx_relay_mutex
2022-05-20 13:31:08 +02:00
Hennadii Stepanov
5a6e3c1db3
refactor: Propagate negative !m_most_recent_block_mutex capability
Could be verified with
$ ./configure CC=clang CXX=clang++ CXXFLAGS='-Wthread-safety -Wthread-safety-negative'
$ make clean
$ make 2>&1 | grep m_most_recent_block_mutex
2022-05-20 13:25:45 +02:00
Hennadii Stepanov
8c61374ba7
Merge bitcoin-core/gui#581: refactor: Revamp ClientModel code to handle core signals
bcbf982553 qt, doc: Remove unneeded comments (Hennadii Stepanov)
9bd1565f65 qt: Revamp ClientModel code to handle {Block|Header}Tip core signals (Hennadii Stepanov)
48f6d39659 qt: Revamp ClientModel code to handle BannedListChanged core signal (Hennadii Stepanov)
36b12af7ee qt: Revamp ClientModel code to handle AlertChanged core signal (Hennadii Stepanov)
bfe5140c50 qt: Revamp ClientModel code to handle NetworkActiveChanged core signal (Hennadii Stepanov)
639563d7fe qt: Revamp ClientModel code to handle NumConnectionsChanged core signal (Hennadii Stepanov)
508e2dca5e qt: Revamp ClientModel code to handle ShowProgress core signal (Hennadii Stepanov)

Pull request description:

  This PR:
  - is a pure refactoring with no behavior change
  - gets rid of `QMetaObject::invokeMethod()` "dynamic" calls, i.e., without compile-time checks of a called function name and its parameters
  - replaces `std::bind`s with lambdas, making parameter permutation (including parameter omitting) explicit
  - makes code simpler, more concise, and easier to reason about

  Additionally, debug messages have been unified.

ACKs for top commit:
  promag:
    Code review ACK bcbf982553
  w0xlt:
    tACK bcbf982553 on Ubuntu 21.10, Qt 5.15.2.

Tree-SHA512: 35f62b84f916b3ad7442f0fea945d344b3c448878b33506ac7b81fdf5e49bd2a82e12a6927dc91f62c335487bf2305cc45e2f08985303eef31c3ed2dd39e1037
2022-05-20 12:08:22 +02:00
Hennadii Stepanov
8118970c86
Merge bitcoin-core/gui#594: scripted-diff: replace deprecated Q_OS_MAC with Q_OS_MACOS
e3daecae03 scripted-diff: replace deprecated Q_OS_MAC with Q_OS_MACOS (João Barbosa)

Pull request description:

  `Q_OS_MAC` is deprecated but it is also defined when Qt is configured with `-xplatform macx-ios-clang`, and currently it guards some features not available on iOS, like `QProcess`.

ACKs for top commit:
  jarolrod:
    tACK e3daecae03
  hebasto:
    ACK e3daecae03.

Tree-SHA512: 17b4b891c70f027f6a420be830e61bd87fde5297a4473a5b122e4e34bdf83141635bd5cf5143efe95a0dd6f8cf50bc67a2de6cbfed7956952369587c74ece225
2022-05-20 11:44:29 +02:00
laanwj
0cd1a2eff9
Merge bitcoin/bitcoin#23595: util: Add ParseHex<std::byte>() helper
facd1fb911 refactor: Use Span of std::byte in CExtKey::SetSeed (MarcoFalke)
fae1006019 util: Add ParseHex<std::byte>() helper (MarcoFalke)
fabdf81983 test: Add test for embedded null in hex string (MarcoFalke)

Pull request description:

  This adds the hex->`std::byte` helper after the `std::byte`->hex helper was added in commit 9394964f6b

ACKs for top commit:
  pk-b2:
    ACK facd1fb911
  laanwj:
    Code review ACK facd1fb911

Tree-SHA512: e2329fbdea2e580bd1618caab31f5d0e59c245a028e1236662858e621929818870b76ab6834f7ac6a46d7874dfec63f498380ad99da6efe4218f720a60e859be
2022-05-20 10:47:30 +02: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
fanquake
a39002e0c6
Merge bitcoin/bitcoin#25170: build: Enable RPC_DOC_CHECK on --enable-debug
fafae678f6 build: Enable RPC_DOC_CHECK on --enable-debug (MacroFake)

Pull request description:

  This probably makes no large difference, as the setting is already enabled by default in the functional tests. However, I think it is nice to also enable it in debug builds by default to catch issues while manually testing without the runtime flags specified.

  See also https://github.com/bitcoin/bitcoin/issues/24709

ACKs for top commit:
  vincenzopalazzo:
    utACK fafae678f6

Tree-SHA512: cea3276fc9b5a3bc0f6d9819be9a50b19ecf762729d3e3975abdf00da06beaa3f664b18a826fbab1fedd9143bc0624a95a490bfe40c4b5b0a0f94dbc565ce738
2022-05-20 08:36:00 +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
fanquake
6407c0e8a3
Merge bitcoin/bitcoin#25101: Add mockable clock type
fa305fd92c Add mockable clock type and TicksSinceEpoch helper (MarcoFalke)

Pull request description:

  This will be used primarily by the addr time refactor (https://github.com/bitcoin/bitcoin/pull/24697) to make addr relay time type safe. However, it can also be used in other places, and can be reviewed independently, so I split it up.

ACKs for top commit:
  jonatack:
    ACK fa305fd92c per `git range-diff 7b3343f fa20781 fa305fd`
  ajtowns:
    ACK fa305fd92c

Tree-SHA512: da00200126833c1f55b1b1e68f596eab5c9254e82b188ad17779c08ffd685e198a7c5270791b4b69a858dc6ba4e051fe0c8b445d203d356d0c884f6365ee1cfe
2022-05-20 07:48:07 +01:00
Ryan Ofsky
f9fdcec7e9 settings: Add resetSettings() method
Allows the GUI to clear settings.json file and save settings.json.bak file when
GUI "Reset Options" button is pressed or -resetguisettings command line option
is used. (GUI code already backs up and resets the "guisettings.ini" file this
way, so this just makes the same behavior possible for "settings.json")
2022-05-19 11:32:56 -04:00
Ryan Ofsky
31122aa979 refactor: Pass interfaces::Node references to OptionsModel constructor
Will allow OptionsModel to read/write settings to the node settings.json
file and share settings with the node, instead of storing them
externally in QSettings.

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
2022-05-19 11:32:56 -04:00
Ryan Ofsky
a63b60f02b refactor: Add OptionsModel getOption/setOption methods
Easiest to review ignoring whitespace.
2022-05-19 11:32:56 -04:00
fanquake
0de36941ec
Merge bitcoin/bitcoin#25153: scripted-diff: Use getInt<T> over get_int/get_int64
fa9af21878 scripted-diff: Use getInt<T> over get_int/get_int64 (MacroFake)

Pull request description:

  Seems better to see the return type directly and be able to modify it easier, as the return type is used for exceptions (in-range checking and parsing feedback).

ACKs for top commit:
  fanquake:
    ACK fa9af21878

Tree-SHA512: 284aa2527d0f663ca01550115025c9c64c787531d595f866c718f6ad09b9b0cac1e683a7d77f8009b75de990fd37166b44063ffa83fba8a04e9a31600b4c2725
2022-05-19 16:32:56 +01:00
Ryan Ofsky
77fabffef4 init: Remove Shutdown() node.args reset
This commit removes the `node.args = nullptr` assignment in the Shutdown()
function.

Clearing node.args there never made sense because it made the
Shutdown() function not idempotent, making it fragile and causing issues like
https://github.com/bitcoin/bitcoin/issues/23186.

The assignment also causes segfaults in GUI unit tests when a new
node().initParameterInteraction() call is added in OptionsModel to apply to Qt
settings (happens because AppTests calls Shutdown() which sets node.args to
null, and OptionTests runs after AppTests and then needs node.args not to be
null.)
2022-05-19 11:32:56 -04:00
Ryan Ofsky
0e55bc6e7f settings: Add update/getPersistent/isIgnored methods
Add interfaces::Node methods to give GUI finer grained control over
settings.json file. Update method is used to write settings to the file,
getPersistent and isIgnored methods are used to find out about settings
file and command line option interactions.
2022-05-19 11:32:56 -04:00
Sebastian Falbesoner
ef0aa74836 rpc: wallet: remove -deprecatedrpc=exclude_coinbase logic 2022-05-19 16:10:59 +02:00
klementtan
e11cdc9303
logging: Add log severity level to net.cpp 2022-05-19 21:05:43 +08:00
klementtan
a8290649a6
logging: Add severity level to logs. 2022-05-19 21:05:35 +08:00
fanquake
e18fd4763e
Merge bitcoin/bitcoin#25074: index: During sync, commit best block after indexing
7171ebc7cb index: Don't commit a best block before indexing it during sync (Martin Zumsande)

Pull request description:

  This changes the periodic commit of the best block during the index sync phase to use the already indexed predecessor of the current block index, instead of committing the current one that will only be indexed (by calling `WriteBlock()`) after committing the best block.

  The previous code would leave the index database in an inconsistent state until the block is actually indexed - if an unclean shutdown happened at just this point in time, the index could get corrupted because at next startup, we'd assume that we have already indexed this block.

ACKs for top commit:
  ryanofsky:
    Code review ACK 7171ebc7cb. Looks great! Just commit message changes since last review

Tree-SHA512: a008de511dd6a1731b7fdf6a90add48d1e53f7f7d6402672adb83e362677fc5b9f5cd021d3111728cb41d73f1b9c2140db79d7e183df0ab359cda8c01b0ef928
2022-05-19 14:00:22 +01:00
Martin Zumsande
7171ebc7cb index: Don't commit a best block before indexing it during sync
Committing a block prior to indexing would leave the index database
in an inconsistent state until it is indexed, which could corrupt the
index in case of a unclean shutdown. Thus commit its predecessor.

Co-authored-by: Luke Dashjr <luke-jr+git@utopios.org>
2022-05-19 13:20:55 +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
fanquake
986bae8e72
Merge bitcoin/bitcoin#22778: net processing: Reduce resource usage for inbound block-relay-only connections
9db82f1bca [net processing] Don't initialize TxRelay for non-tx-relay peers. (John Newbery)
b0a4ac9c26 [net processing] Add m_tx_relay_mutex to protect m_tx_relay ptr (John Newbery)
290a8dab02 [net processing] Comment all TxRelay members (John Newbery)
42e3250497 [net processing] [refactor] Move m_next_send_feefilter and m_fee_filter_sent (John Newbery)

Pull request description:

  block-relay-only connections are additional outbound connections that bitcoind makes since v0.19. They participate in block relay, but do not propagate transactions or addresses. They were introduced in #15759.

  When creating an outbound block-relay-only connection, since we know that we're never going to announce transactions over that connection, we can save on memory usage by not a `TxRelay` data structure for that connection. When receiving an inbound connection, we don't know whether the connection was opened by the peer as block-relay-only or not, and therefore we always construct a `TxRelay` data structure for inbound connections.

  However, it is possible to tell whether an inbound connection will ever request that we start announcing transactions to it. The `fRelay` field in the `version` message may be set to `0` to indicate that the peer does not wish to receive transaction announcements. The peer may later request that we start announcing transactions to it by sending a `filterload` or `filterclear` message, **but only if we have offered `NODE_BLOOM` services to that peer**. `NODE_BLOOM` services are disabled by default, and it has been recommended for some time that users not enable `NODE_BLOOM` services on public connections, for privacy and anti-DoS reasons.

  Therefore, if we have not offered `NODE_BLOOM` to the peer _and_ it has set `fRelay` to `0`, then we know that it will never request transaction announcements, and that we can save resources by not initializing the `TxRelay` data structure.

ACKs for top commit:
  MarcoFalke:
    review ACK 9db82f1bca 🖖
  dergoegge:
    Code review ACK 9db82f1bca
  naumenkogs:
    ACK 9db82f1bca

Tree-SHA512: 83a449a56cd6bf6ad05369f5ab91516e51b8c471c07ae38c886d51461e942d492ca34ae63d329c46e56d96d0baf59a3e34233e4289868f911db3b567072bdc41
2022-05-19 09:27:24 +01:00
MacroFake
fafae678f6
build: Enable RPC_DOC_CHECK on --enable-debug 2022-05-19 07:54:57 +02: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
7b3343f300
Merge bitcoin/bitcoin#25108: tidy: add modernize-use-default-member-init
ac6fbf2c83 tidy: use modernize-use-default-member-init (fanquake)
7aa40f5563 refactor: use C++11 default initializers (fanquake)

Pull request description:

  Refactor and then enable [`modernize-use-default-member-init`](https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-default-member-init.html) in our `clang-tidy` job.

Top commit has no ACKs.

Tree-SHA512: 536b406f20639f8c588fe9e96175ec60c7bb825506b2670b562370b2f572801c24203c483443be3c199e1b958c0765d4532e57c57a4e78689162a1dd422d844f
2022-05-18 19:19:55 +02:00
MacroFake
fa9af21878
scripted-diff: Use getInt<T> over get_int/get_int64
-BEGIN VERIFY SCRIPT-
 sed -i 's|\<get_int64\>|getInt<int64_t>|g' $(git grep -l get_int ':(exclude)src/univalue')
 sed -i 's|\<get_int\>|getInt<int>|g'       $(git grep -l get_int ':(exclude)src/univalue')
-END VERIFY SCRIPT-
2022-05-18 19:15:03 +02:00
MarcoFalke
fa305fd92c
Add mockable clock type and TicksSinceEpoch helper 2022-05-18 18:58:05 +02:00
MacroFake
fa1b76aeb0
Do not call global Params() when chainman is in scope 2022-05-18 18:46:48 +02:00
MacroFake
fa30234be8
Do not pass CChainParams& to PeerManager::make 2022-05-18 18:46:27 +02:00
MacroFake
fafe5c0ca2
Do not pass CChainParams& to BlockAssembler constructor 2022-05-18 18:46:07 +02:00
MacroFake
faf012b438
Do not pass Consensus::Params& to Chainstate helpers 2022-05-18 18:45:30 +02:00
MacroFake
fa4ee53dca
Do not pass time getter to Chainstate helpers 2022-05-18 18:44:04 +02:00
John Newbery
9db82f1bca [net processing] Don't initialize TxRelay for non-tx-relay peers.
Delay initializing the TxRelay data structure for a peer until we receive
a version message from that peer. At that point we'll know whether it
will ever relay transactions. We only initialize the m_tx_relay
data structure if:

- this isn't an outbound block-relay-only connection; AND
- fRelay=true OR we're offering NODE_BLOOM to this peer
  (NODE_BLOOM means that the peer may turn on tx relay later)
2022-05-18 17:08:24 +01:00
John Newbery
b0a4ac9c26 [net processing] Add m_tx_relay_mutex to protect m_tx_relay ptr 2022-05-18 17:02:23 +01:00
John Newbery
290a8dab02 [net processing] Comment all TxRelay members
This fully comments all the TxRelay members. The only significant change
is to the comment for m_relay_txs. Previously the comment stated that
one of the purposes of the field was that "We don't relay tx invs before
receiving the peer's version message". However, even without the
m_relay_txs flag, we would not send transactions to the peer before
receiving the `version` message, since SendMessages() returns
immediately if fSuccessfullyConnected is not set to true, which only
happens once a `version` and `verack` message have been received.
2022-05-18 17:02:11 +01:00
John Newbery
42e3250497 [net processing] [refactor] Move m_next_send_feefilter and m_fee_filter_sent
Move m_next_send_feefilter and m_fee_filter_sent out of the `TxRelay`
data structure. All of the other members of `TxRelay` are related to
sending transactions _to_ the peer, whereas m_fee_filter_sent and
m_next_send_feefilter are both related to receiving transactions _from_
the peer. A node's tx relay behaviour is not always symmetrical (eg a
blocksonly node will ignore incoming transactions, but may still send
out its own transactions), so it doesn't make sense to group the
feefilter sending data with the TxRelay data in a single structure.

This does not change behaviour, since IsBlockOnlyConn() is always equal
to !peer.m_tx_relay. We still don't send feefilter messages to outbound
block-relay-only peers (tested in p2p_feefilter.py).
2022-05-18 17:01:37 +01:00
MacroFake
002411dc53
Merge bitcoin/bitcoin#25157: Fix -rpcwait with -netinfo returning negative time durations
3a998d2e37 Use steady_clock in ConnectAndCallRPC and inline time call in loop conditional (Jon Atack)
3799d2dcdd Fix -rpcwait with -netinfo printing negative time durations (Jon Atack)

Pull request description:

  - Fix `bitcoin-cli -rpcwait -netinfo 1` returning negative time durations on its first invocation after node startup in the "send", "recv", and "age" columns (potentially the "txn" and "blk" columns also). To reproduce, start bitcoind on mainnet (for a longer startup time) and run `bitcoin-cli -rpcwait -netinfo <n>` where n is 1 or larger. The negative time durations are larger with a slower CPU speed or e.g. higher `checkblocks`/`checklevel` config option settings.

  Examples:
  ```
  <->   type   net  mping   ping send recv  txn  blk  hb addrp addrl  age id
  out manual onion               -126 -126                             -2  0
                       ms     ms  sec  sec  min  min                  min
  ```

  ```
  <->   type   net  mping   ping send recv  txn  blk  hb addrp addrl  age id
  out manual cjdns                -64  -64                             -1  0
                       ms     ms  sec  sec  min  min                  min
  ```
  ```
  <->   type   net  mping   ping send recv  txn  blk  hb addrp addrl  age id
  out manual  ipv4                -89  -89    *              .         -1  0
                       ms     ms  sec  sec  min  min                  min
  ```
  ```
  <->   type   net  mping   ping send recv  txn  blk  hb addrp addrl  age id
  out manual  ipv6               -133         *              .         -2  0
                       ms     ms  sec  sec  min  min                  min
  ```

  - Use `steady_clock` in ConnectAndCallRPC and inline the time call in the loop conditional to avoid unnecessary invocations and an unneeded local variable allocation.

ACKs for top commit:
  MarcoFalke:
    cr ACK 3a998d2e37

Tree-SHA512: 141430d47189ad9f646ce8e51cb31c21b395f6294bb27ba9f7ae4c1e1505a63209a4a19662a0b462806437a9cfd07f1ea114e775adc2872d87397fe823f8b8dc
2022-05-18 16:56:56 +02:00
Vasil Dimov
b2733ab6a8
net: add new method Sock::Listen() that wraps listen()
This will help to increase `Sock` usage and make more code mockable.
2022-05-18 16:40:13 +02:00
Vasil Dimov
3ad7de225e
net: add new method Sock::Bind() that wraps bind()
This will help to increase `Sock` usage and make more code mockable.
2022-05-18 16:40:12 +02:00
MacroFake
629e250cbd
Merge bitcoin/bitcoin#25148: refactor: Remove NO_THREAD_SAFETY_ANALYSIS from non-test/benchmarking code
a55db4ea1c Add more proper thread safety annotations (Hennadii Stepanov)
8cfe93e3fc Add proper thread safety annotation to `CWallet::GetTxConflicts()` (Hennadii Stepanov)
ca446f2c59 Add proper thread safety annotation to `CachedTxGetAvailableCredit()` (Hennadii Stepanov)

Pull request description:

  In non-test/benchmarking code, there are three cases of the `NO_THREAD_SAFETY_ANALYSIS` annotation which are accompanied with `TODO` comments.

  This PR adds proper thread safety annotations instead of `NO_THREAD_SAFETY_ANALYSIS`.

ACKs for top commit:
  laanwj:
    Code review ACK a55db4ea1c

Tree-SHA512: 806d72eebc1edf088bfa435c8cd11465be0de6789798dd92abd008425516768acb864a73d834a49d412bb10f7fccfb47473f998cb72739dab6caeef6bcfaf191
2022-05-18 16:23:43 +02:00
S3RK
c3981e379f wallet: do not count wallet utxos as external 2022-05-18 08:25:04 +02:00
fanquake
ac6fbf2c83
tidy: use modernize-use-default-member-init 2022-05-17 17:19:07 +01:00
fanquake
7aa40f5563
refactor: use C++11 default initializers 2022-05-17 17:18:58 +01: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
fanquake
dd8a2df488
Merge bitcoin/bitcoin#25107: bench: Add --sanity-check flag, use it in make check
4f31c21b7f bench: Make all arguments -kebab-case (laanwj)
652b54e532 bench: Add `--sanity-check` flag, use it in `make check` (laanwj)

Pull request description:

  The benchmarks are run as part of `make check` for a crash-sanity check. The actual results are being ignored. So only run them for one iteration.

  This makes the `bench_bitcoin` part take 2m00 instead of 5m20 here. Which is still too long (imo), but this needs to be solved in the `WalletLoading*` benchmarks which take that long per iteration.

  Also change all `bench_bitcoin` arguments to kebab-case to be consistent with the other tools (in a separate commit).

ACKs for top commit:
  jonatack:
    ACK 4f31c21b7f on the sanity-check version per  `git diff c52a71e 4f31c28` (modulo s/--sanity check/--sanity-check/ in src/bench/bench.cpp::L61)
  hebasto:
    ACK 4f31c21b7f, tested on Ubuntu 22.04.

Tree-SHA512: 2661d130fd82e57c9041755190997a4af588fadddcdd05e04fd024f75da1202480e9feab5764566e8dfe7930e8ae0ec71e93f40ac373274953d274072723980d
2022-05-17 16:19:07 +01:00
Jon Atack
3a998d2e37 Use steady_clock in ConnectAndCallRPC and inline time call in loop conditional
to avoid unnecessary invocations and an unneeded local variable allocation.
2022-05-17 16:56:50 +02:00
Jon Atack
3799d2dcdd Fix -rpcwait with -netinfo printing negative time durations
Fixes negative time duration values in the "send", "recv",
and "age" columns (potentially the "txn" and "blk" columns also)
for the first run of -rpcwait -netinfo after bitcoind startup.

To reproduce, start bitcoind on mainnet and run
`bitcoin-cli -rpcwait -netinfo <n>` where n is 1 or larger.

The negative times will be larger/more apparent with a slower
CPU speed or e.g. higher checkblocks/checklevel config option
settings.
2022-05-17 16:18:22 +02:00
Sebastian Falbesoner
6b636730f4 tracing: fix coin_selection:aps_create_tx_internal calling logic
According to the documentation, the tracepoint
`coin_selection:aps_create_tx_internal` "Is called when the second
`CreateTransactionInternal` with Avoid Partial Spends enabled completes."

Currently it is only called if the second call to
`CreateTransactionInternal` succeeds, i.e. the third parameter is always
`true` and we don't get notified in the case that it fails.

Fix this by introducing a boolean variable for the result of the call
and moving the tracepoint call outside the if body.
2022-05-17 16:11:40 +02:00
Suhas Daftuar
0569b5c4bb Sync chain more readily from inbound peers during IBD
When in IBD, if the honest chain is only known by inbound peers, then we must
eventually sync from them in order to learn it. This change allows us to
perform initial headers sync and fetch blocks from inbound peers, if we have no
blocks in flight.

The restriction on having no blocks in flight means that we will naturally
throttle our block downloads to any such inbound peers that we may be
downloading from, until we leave IBD. This is a tradeoff between preferring
outbound peers for most of our block download, versus making sure we always
eventually will get blocks we need that are only known by inbound peers even
during IBD, as otherwise we may be stuck in IBD indefinitely (which could have
cascading failure on the network, if a large fraction of the network managed to
get stuck in IBD).
2022-05-17 09:36:47 -04:00
fanquake
1ab389b1ba
Merge bitcoin/bitcoin#20640: wallet, refactor: return out-params of CreateTransaction() as optional struct
4c5ceb040c wallet: CreateTransaction(): return out-params as (optional) struct (Sebastian Falbesoner)
c9fdaa5e3a wallet: CreateTransactionInternal(): return out-params as (optional) struct (Sebastian Falbesoner)

Pull request description:

  The method `CWallet::CreateTransaction` currently returns several values in the form of out-parameters:
  * the actual newly created transaction (`CTransactionRef& tx`)
  * its required fee (`CAmount& nFeeRate`)
  * the position of the change output (`int& nChangePosInOut`) -- as the name suggests, this is both an in- and out-param

  By returning these values in an optional structure (which returns no value a.k.a. `std::nullopt` if an error occured), the interfaces is shorter, cleaner (requested change position is now in-param and can be passed by value) and callers don't have to create dummy variables for results that they are not interested in.

  Note that the names of the replaced out-variables were kept in `CreateTransactionInternal` to keep the diff minimal. Also, the fee calculation data (`FeeCalculation& fee_calc_out`) would be another candidate to put into the structure, but `FeeCalculation` is currently an opaque data type in the wallet interface and I think it should stay that way.

  As a potential follow-up, I think it would make sense to also do the same refactoring for `CWallet::FundTransaction`, which has a very similar parameter structure.

  Suggested by laanwj in https://github.com/bitcoin/bitcoin/pull/20588#issuecomment-739838428.

ACKs for top commit:
  achow101:
    re-ACK 4c5ceb040c
  Xekyo:
    ACK 4c5ceb040c
  w0xlt:
    crACK 4c5ceb040c

Tree-SHA512: 27e5348bbf4f698713002d40c834dcda59c711c93207113e14522fc6d9ae7f4d8edf1ef6d214c5dd62bb52943d342878960ca333728828bf39b645a27d55d524
2022-05-17 11:04:43 +01:00
John Newbery
c65bf50b44 Remove fUseWTXID parameter from CBlockHeaderAndShortTxIDs constructor
All uses of CBlockHeaderAndShortTxIDs in the product code are
constructed with fUseWTXID=true, so remove the parameter.

There is one use of the CBlockHeaderAndShortTxIDs constructor with
fUseWTXID=false in the unit tests. This is used to construct a
CBlockHeaderAndShortTxIDs for a block with only the coinbase
transaction, so setting fUseWTXID to true or false makes no difference.

Suggested in https://github.com/bitcoin/bitcoin/pull/20799#pullrequestreview-963480278
2022-05-17 10:37:10 +01:00
laanwj
4f31c21b7f bench: Make all arguments -kebab-case
This is customary for UNIX-style arguments, and more consistent with our
other tools
2022-05-17 11:32:25 +02:00
laanwj
652b54e532 bench: Add --sanity-check flag, use it in make check
The benchmarks are run as part of `make check` for a minimum sanity
check. The actual results are being ignored. So only run them for one
iteration.

This makes the `bench_bitcoin` part take 2m00 instead of 5m20 here.
Which is still too long (imo), but this needs to be solved in the
`WalletLoading*` benchmarks which take that long per iteration.
2022-05-17 11:32:25 +02:00
MacroFake
0be1dc1f56
Merge bitcoin/bitcoin#24062: refactor: replace RecursiveMutex m_most_recent_block_mutex with Mutex
83003ffe04 refactor: replace RecursiveMutex `m_most_recent_block_mutex` with Mutex (Sebastian Falbesoner)
8edd0d31ac refactor: reduce scope of lock `m_most_recent_block_mutex` (Sebastian Falbesoner)

Pull request description:

  This PR is related to #19303 and gets rid of the RecursiveMutex `m_most_recent_block_mutex`. All of the critical sections (5 in total) only directly access the guarded elements, i.e. it is not possible that within one section another one is called, and we can use a regular Mutex:

  b019cdc036/src/net_processing.cpp (L1650-L1655)

  b019cdc036/src/net_processing.cpp (L1861-L1865)

  b019cdc036/src/net_processing.cpp (L3149-L3152)

  b019cdc036/src/net_processing.cpp (L3201-L3206)

  b019cdc036/src/net_processing.cpp (L4763-L4769)

  The scope of the last critical section is reduced in the first commit, in order to avoid calling the non-trivial method `CConnman::PushMessage` while the lock is held.

ACKs for top commit:
  furszy:
    Code ACK 83003ffe with a small comment.
  hebasto:
    ACK 83003ffe04
  w0xlt:
    ACK 83003ffe04

Tree-SHA512: 3df290cafd2f6c4d40afb9f14e822a77d9c1828e66f5e2233f3ac1deccc2b0a8290bc5fb8eb992f49d39e887b50bc0e9aad63e05db2d870791a8d409fb95695f
2022-05-17 08:44:09 +02:00
MacroFake
8270740bef
Merge bitcoin/bitcoin#25114: rpc: remove deprecated "softforks" field from getblockchaininfo
a01b92ad86 doc: add release notes about removal of the `deprecatedrpc=softforks` flag (Sebastian Falbesoner)
8c5533c7a9 rpc: remove deprecated "softforks" field from getblockchaininfo (Sebastian Falbesoner)

Pull request description:

  Information on soft fork status has been moved from the `getblockchaininfo` RPC to the `getdeploymentinfo` RPC in #23508. The "softfork" result in `getblockchaininfo` was still available for 23.0 with the `-deprecatedrpc=softforks` configuration option, but this can be fully removed now for the next release (24.0).

ACKs for top commit:
  shaavan:
    ACK a01b92ad86
  ajtowns:
    ACK a01b92ad86

Tree-SHA512: 692d9d02fdf0b3c18376644a85b24b57efebf612738084c01ef47d47e41861e773688613a808e81f10ab6eec340de00eef96987a1e34d612aaf7f0a0b134d89e
2022-05-17 08:25:25 +02:00
Andrew Chow
91a42d63ef
Merge bitcoin/bitcoin#25019: parse external signer master fp as bytes in ExternalSigner::SignTransaction
2a22f034ca parsing external signer master fingerprint string as bytes instead of caring for lower/upper case in ExternalSigner::SignTransaction (avirgovi)

Pull request description:

  Some external signers scripts may provide master fingerprint in uppercase format. In that case core will fail with `Signer fingerprint 00000000 does not match any of the inputs` as it only works with lowercase format. Even if the fingerprints match, yet one is lowercase the other uppercase.

  ExternalSigner::SignTransaction is the only place where it is needed IMO, as changing it in other places may break the communication with the external signer (i.e. enumerating with lowercase may not find the device).

ACKs for top commit:
  achow101:
    ACK 2a22f034ca
  theStack:
    Code-review ACK 2a22f034ca
  Sjors:
    utACK 2a22f034ca

Tree-SHA512: f3d84b83fb0b5e06c405eaf9bf20a2fa864bf4172fd4de113b80b9b9a525a76f2f8cf63031b480358b3a7666023a2aef131fb89ff50448c66df3ed541da10f99
2022-05-16 15:57:07 -04:00
Andrew Chow
98f4db3305
Merge bitcoin/bitcoin#25088: Wallet: Ensure m_attaching_chain is set before registering for signals
ba10b90915 Wallet: Ensure m_attaching_chain is set before registering for signals (Luke Dashjr)

Pull request description:

  Avoids a race where chainStateFlushed could be called before rescanning began, yet rescan gets interrupted or fails

  Followup for #24984 avoiding a race between registering and setting the flag.

ACKs for top commit:
  mzumsande:
    Code Review ACK ba10b90915
  achow101:
    ACK ba10b90915

Tree-SHA512: 1d2fa2db189d3e87f2d0863cf2ab62166094436483f0da16760b1083a4743bf08e476a3277e0d36564213d65dd6f0a1fc16a4bf68d3338c991a14d1de9fc0fee
2022-05-16 15:29:40 -04:00
Hennadii Stepanov
a55db4ea1c
Add more proper thread safety annotations 2022-05-16 20:51:40 +02:00
Hennadii Stepanov
8cfe93e3fc
Add proper thread safety annotation to CWallet::GetTxConflicts() 2022-05-16 20:51:39 +02:00
Hennadii Stepanov
ca446f2c59
Add proper thread safety annotation to CachedTxGetAvailableCredit() 2022-05-16 20:51:39 +02:00
Andrew Chow
187504b038
Merge bitcoin/bitcoin#23662: rpc: improve getreceivedby{address,label} performance
f336ff7f21 rpc: avoid expensive `IsMine` calls in `GetReceived` tally (Sebastian Falbesoner)
a7b65af2a4 rpc: avoid scriptPubKey<->CTxDestination conversions in `GetReceived` tally (Sebastian Falbesoner)

Pull request description:

  The RPC calls `getreceivedbyaddress`/`getreceivedbylabel` both use the internal helper function `GetReceived` which was introduced in PR #17579 to deduplicate tallying code. For every wallet-related transaction output, the following unnecessary operations are currently performed in the tally loop, leading to a quite bad performance (as reported in #23645):
  - converting from CScript -> TxDestination (`ExtractDestination(...)`), converting from TxDestination -> CScript (`CWallet::IsMine(const CTxDestination& dest)`); this can be avoided by directly using output scripts in the search set instead of addresses (first commit)
  - checking if the iterated output script belongs to the wallet by calling `IsMine`; this can be avoided by only adding addresses to the search set which fulfil `IsMine` in the first place (second commit)

  ### Benchmark results
  The functional test [wallet_pr23662.py](https://github.com/theStack/bitcoin/blob/pr23662_benchmarks/test/functional/wallet_pr23662.py) (not part of this PR) creates transactions with 15000 different addresses:
  - 5000 outputs (500 txs with 10 outputs each) with label set, IsMine set (received)
  - 5000 outputs (500 txs with 10 outputs each) with label set, IsMine not set (sent)
  - 5000 outputs (500 txs with 10 outputs each) without label set, IsMine not set (sent)

  Then, the time is measured for calling `getreceivedbyaddress` and `getreceivedbylabel`, the latter with two variants. Results on my machine:

  | branch             | `getreceivedbyaddress` (single) | `getreceivedbylabel` (single) | `getreceivedbylabel` (10000) |
  |--------------------|---------------------------------|-------------------------------|------------------------------|
  | master             |             406.13ms            |          425.33ms             |          446.58ms            |
  | PR (first commit)  |             367.18ms            |          365.81ms             |          426.33ms            |
  | PR (second commit) |               3.96ms            |            4.83ms             |          339.69ms            |

  Fixes #23645.

ACKs for top commit:
  achow101:
    ACK f336ff7f21
  w0xlt:
    ACK f336ff7f21
  furszy:
    Code ACK f336ff7f

Tree-SHA512: 9cbf402b9e269713bd3feda9e31719d9dca8a0dfd526de12fd3d561711589195d0c50143432c65dae279c4eab90a4fc3f99e29fbc0452fefe05113e92d129b8f
2022-05-16 14:35:42 -04:00
Sebastian Falbesoner
4c5ceb040c wallet: CreateTransaction(): return out-params as (optional) struct 2022-05-16 17:46:34 +02:00
Sebastian Falbesoner
c9fdaa5e3a wallet: CreateTransactionInternal(): return out-params as (optional) struct 2022-05-16 17:37:10 +02:00