Commit graph

21949 commits

Author SHA1 Message Date
John Newbery
d0e9774174 [net processing] Tidy up sendcmpct processing
- use better local variable names
- drop unnecessary if statements
2022-05-15 16:13:31 -04:00
John Newbery
30c3a01874 [net processing] fPreferHeaderAndIDs implies fProvidesHeaderAndIDs
Remove all if(fProvidesHeaderAndIDs) conditionals inside
if(fPreferHeaderAndIDs) conditionals.
2022-05-15 16:13:31 -04:00
John Newbery
b486f72176 [net processing] Remove fWantsCmpctWitness
It is now completely redundant with fProvidesHeadersAndIDs.
2022-05-15 16:13:31 -04:00
John Newbery
a45d53cab5 [net processing] Remove fSupportsDesiredCmpctVersion
It is now completely redundant with fProvidesHeadersAndIDs.
2022-05-15 16:13:29 -04:00
John Newbery
25edb2b7bd [net processing] Simplify sendcmpct processing
nCMPCTBLOCKVersion must always be 2 when processing.
2022-05-15 15:37:56 -04:00
John Newbery
42882fc8fc [net processing] Only accept sendcmpct with version=2
Subsequent commits will remove support for other versions of compact blocks.

Add a test that a received `sendcmpct` message with version = 1 is
ignored.
2022-05-15 15:37:56 -04:00
John Newbery
16730b64bb [net processing] Only advertise support for version 2 compact blocks
Subsequent commits will remove support.
2022-05-15 15:37:56 -04:00
amadeuszpawlik
ada8358ef5 Sanitize port in addpeeraddress()
- Ensures port sanitization in `addpeeraddress()`
- Adds test to check for invalid port values
2022-05-14 10:22:16 +02:00
MacroFake
fae3200bbf
test: Slim down versionbits_tests.cpp 2022-05-13 13:39:16 +02:00
Sebastian Falbesoner
8c5533c7a9 rpc: remove deprecated "softforks" field from getblockchaininfo 2022-05-13 11:44:28 +02:00
MacroFake
fa347a9066
rpc: Fix implicit-integer-sign-change in gettxout 2022-05-13 11:39:48 +02:00
fanquake
225e5b57b2
Merge bitcoin/bitcoin#25113: Bump univalue subtree
f403531f97 Squashed 'src/univalue/' changes from a44caf65fe..6c19d050a9 (MacroFake)

Pull request description:

  Only change is some header-shuffling and adding `getInt`.

ACKs for top commit:
  fanquake:
    ACK fac2c796cb

Tree-SHA512: 8bdf7d88ce06f0851f99f30c30fc926a13b79ae72bcebd5e170ed0e1d882b184d9279f96488e234fbe560036e31cb180aa1e5666aebd9833b9a119c6b214fa30
2022-05-13 10:36:05 +01:00
MacroFake
25dd4d8513
Merge bitcoin/bitcoin#24595: deploymentstatus: move g_versionbitscache global to ChainstateManager
bb5c24b120 validation: move g_versionbitscache into ChainstateManager (Anthony Towns)
eca22c726a test/versionbits: make versionbitscache a parameter (Anthony Towns)
d603f1d8a7 deploymentstatus: make versionbitscache a parameter (Anthony Towns)
78adef1753 refactor: use chainman instead of chainParams for DeploymentActive* (Anthony Towns)
deffe0df6c deploymentstatus: allow chainman in place of consensusParams (Anthony Towns)
eaa2e3f25c validation: move UpdateUncommittedBlockStructures and GenerateCoinbaseCommitment into ChainstateManager (Anthony Towns)
5c67e84d37 validation: replace ::Params() calls with chainstate/chainman member (Anthony Towns)
38860f93b6 validation: remove redundant CChainParams params from ChainstateManager methods (Anthony Towns)
69675ea4e7 validation: add CChainParams to ChainstateManager (Anthony Towns)

Pull request description:

  Gives `ChainstateManager` a reference to the `CChainParams` its working on, and simplifies some of the functions that would otherwise take that as a parameter. Removes the `g_versionbitscache` global by moving it into `ChainstateManager`.

ACKs for top commit:
  dongcarl:
    reACK bb5c24b120
  MarcoFalke:
    review ACK bb5c24b120 📙

Tree-SHA512: 3fa74905e5df561e3e74bb0b8fce6085c5311e6633e7d74c0fb0c82a907f5bbb1fd4ebc5d11d4f0b1c019bb51eabb9f6e4bcc4652a696d36a5878c807b85f121
2022-05-13 09:00:21 +02:00
MacroFake
b3f0a34389
Merge bitcoin/bitcoin#25119: net, refactor: move StartExtraBlockRelayPeers() from header to implementation
51ec96b904 refactor: move StartExtraBlockRelayPeers from header to implementation (Jon Atack)

Pull request description:

  where all the other logging actions in src/net.{h,cpp} are located.

  StartExtraBlockRelayPeers() does not appear to be a hotspot that needs to be inlined for performance, as it is called from CheckForStaleTipAndEvictPeers(), called in turn from StartScheduledTasks() with a scheduleEvery delta of 45 seconds, called at the end of AppInitMain() on bitcoind startup.

  This allows dropping `#include <logging.h>` from net.h, which can improve compile time/speed. Currently, none of the other includes in net.h use logging.h, except src/sync.h if DEBUG_LOCKCONTENTION is defined.

ACKs for top commit:
  LarryRuane:
    ACK 51ec96b904
  theStack:
    ACK 51ec96b904

Tree-SHA512: 69b2c09163c48bfcb43355af0aa52ee7dd81efc755a7aa6a10f5e400b5e14109484437960a62a1cfac2524c2cfae981fee082846b19526b540ef5b86be97f0fe
2022-05-13 07:47:45 +02:00
Jon Atack
51ec96b904 refactor: move StartExtraBlockRelayPeers from header to implementation
where all the other logging actions in src/net.{h,cpp} are located.

StartExtraBlockRelayPeers() does not appear to be a hotspot that needs to be
inlined for performance, as it is called from CheckForStaleTipAndEvictPeers(),
called in turn from StartScheduledTasks() with a scheduleEvery delta of 45
seconds, called at the end of AppInitMain() on bitcoind startup.

This allows dropping `#include <logging.h>` from net.h, which can improve
compile time/speed. Currently, none of the other includes in net.h use
logging.h, except src/sync.h if DEBUG_LOCKCONTENTION is defined.
2022-05-12 17:41:32 +02:00
Sebastian Falbesoner
672d49c863 scripted-diff: replace non-standard fixed width integer types (u_int... -> uint`...)
-BEGIN VERIFY SCRIPT-
sed -i 's/u_int/uint/g' $(git grep -l u_int)
-END VERIFY SCRIPT-
2022-05-12 15:44:24 +02:00
MacroFake
fac2c796cb
Bump univalue subtree 2022-05-12 11:52:28 +02:00
MacroFake
dd9f61a184
Merge bitcoin/bitcoin#25102: Remove unused GetTimeSeconds
fab9e8a29c Remove unused GetTimeSeconds (MacroFake)

Pull request description:

  Seems confusing to have this helper when it is possible to get the system time in a type-safe way by simply calling `std::chrono::system_clock::now` (C++11).

  This patch replaces `GetTimeSeconds` and removes it:
  * in `bitcoin-cli.cpp` by `system_clock`
  * in `test/fuzz/fuzz.cpp` by `steady_clock`

ACKs for top commit:
  laanwj:
    Code review ACK fab9e8a29c
  naumenkogs:
    ACK fab9e8a29c

Tree-SHA512: 517e300b0baf271cfbeebd4a0838871acbea9360f9dd23572a751335c20c1ba261b1b5ee0aec8a36abd20c94fab83ce94f46042745279aca1f0ca2f885a03b6e
2022-05-12 10:04:54 +02:00
MacroFake
a2a8e919ee
Merge bitcoin/bitcoin#24925: refactor: make GetRand a template, remove GetRandInt
ab1ea29ba1 refactor: make GetRand a template, remove GetRandInt (pasta)

Pull request description:

  makes GetRand a template for which any integral type can be used, where the default behavior is to return a random integral up to the max of the integral unless a max is provided.
  This simplifies a lot of code from GetRand(std::numeric_limits<uint64_t>::max() -> GetRand<uint64_t>()

ACKs for top commit:
  laanwj:
    Code review ACK ab1ea29ba1

Tree-SHA512: db5082a0e21783389f1be898ae73e097b31ab48cab1a2c0e29348a4adeb545d4098193aa72a547c6baa6e8205699aafec38d6a27b3d65522fb3246f91b4daae9
2022-05-12 08:57:22 +02:00
Anthony Towns
436ce0233c sync.h: strengthen AssertLockNotHeld assertion 2022-05-12 02:25:56 +10:00
Anthony Towns
7d73f58e9c Increase threadsafety annotation coverage 2022-05-12 02:25:55 +10:00
MacroFake
9db941d773
Merge bitcoin/bitcoin#25100: Switch scheduler to steady_clock
fa90516422 Switch scheduler to steady_clock (MacroFake)

Pull request description:

  There is already `mockscheduler`, so it seems brittle, confusing and redundant to be able to mock the scheduler by adjusting the system clock.

ACKs for top commit:
  laanwj:
    Code review ACK fa90516422
  w0xlt:
    crACK fa90516422

Tree-SHA512: 60e99065ffb881a9fb25a346d311d99424fbc72a3b636c94b5f5c17ed6373c40f358a9b27825c518d12968c033e6cfd3c62d2b62cacdddc44a0b5b74f6c1a7ae
2022-05-11 17:18:25 +02:00
MacroFake
cca900e382
Merge bitcoin/bitcoin#25104: wallet: Change log interval to use steady_clock
bdc6881e2f wallet: Change log interval to use `steady_clock` (w0xlt)

Pull request description:

  This refactors the log interval variables to use `steady_clock` as it is best suitable for measuring intervals.

ACKs for top commit:
  laanwj:
    This makes sense. Code review ACK bdc6881e2f
  dunxen:
    Code review ACK bdc6881

Tree-SHA512: 738b4aa45cef01df77102320f83096a0a7d0c63d7fcf098a8c0ab16b29453a87dc789c110105590e1e215d03499db1d889a94f336dcb385b6883c8364c9d39b7
2022-05-11 17:09:44 +02:00
MacroFake
fab9e8a29c
Remove unused GetTimeSeconds 2022-05-11 16:39:23 +02:00
Sebastian Falbesoner
9feb887082 rpc: check fopen return code in dumptxoutset
This change improves the usability of the `dumptxoutset` RPC in two ways,
in the case that an invalid path is passed:
  1. return from the RPC immediately, rather then when the file is first
     tried to be written (which is _after_ calculating the UTXO set hash)
  2. return a proper return code and error message instead of the cryptic
     "CAutoFile::operator<<: file handle is nullptr: unspecified
      iostream_category error" (-1)
2022-05-11 16:03:40 +02:00
w0xlt
bdc6881e2f wallet: Change log interval to use steady_clock
This refactors the log interval variables to use `steady_clock`
as it is best suitable for measuring intervals.
2022-05-10 21:12:52 -03:00
MacroFake
fa90516422
Switch scheduler to steady_clock 2022-05-10 10:54:54 +02:00
MacroFake
fb7c12c26f
Merge bitcoin/bitcoin#24921: Add time helpers for std::chrono::steady_clock and FastRandomContext::rand_uniform_delay
fa4fb8d98b random: Add FastRandomContext::rand_uniform_delay (MarcoFalke)
faa5c62967 Add time helpers for std::chrono::steady_clock (MarcoFalke)

Pull request description:

  A steady clock can be used in the future for the scheduler, for example.

  A random uniform delay applied to a time point can be used in the future for time points passed to the scheduler, or delays in net processing.

  Currently they are unused outside of tests, but if they turn out unused in the future (unlikely), they can trivially be removed again. I am splitting them out, so that several branches/pulls can build on top of them without duplicating the commits.

ACKs for top commit:
  ajtowns:
    ACK fa4fb8d98b

Tree-SHA512: 2c37174468fe84b1cdf2a032f458706df44b99a5f99062417bb42078b6f69e2f1738d20c21cd9386ca5a35f3bc0583e547ba40168c66f6aa42f700ba35dd95d4
2022-05-10 07:56:06 +02:00
MacroFake
967654d079
Merge bitcoin/bitcoin#25079: index: Change sync variables to use std::chrono::steady_clock
92b35aba22 index, refactor: Change sync variables to use `std::chrono::steady_clock` (w0xlt)

Pull request description:

  This PR refactors the sync variables to use `std::chrono::steady_clock` as it is best suitable for measuring intervals.

ACKs for top commit:
  jonatack:
    utACK 92b35aba22
  ajtowns:
    ACK 92b35aba22 - code review only

Tree-SHA512: cd4bafde47b30beb88c0aac247e41b4dced2ff2845c67a7043619da058dcff4f84374a7c704a698f3055c888d076d25503c2f38ace8fbc5456f624e0efe1e188
2022-05-10 07:35:36 +02:00
Anthony Towns
bb5c24b120 validation: move g_versionbitscache into ChainstateManager 2022-05-10 12:09:33 +10:00
Anthony Towns
eca22c726a test/versionbits: make versionbitscache a parameter 2022-05-10 12:09:33 +10:00
Anthony Towns
d603f1d8a7 deploymentstatus: make versionbitscache a parameter 2022-05-10 12:09:33 +10:00
Anthony Towns
78adef1753 refactor: use chainman instead of chainParams for DeploymentActive* 2022-05-10 12:09:33 +10:00
Anthony Towns
deffe0df6c deploymentstatus: allow chainman in place of consensusParams 2022-05-10 12:09:33 +10:00
Anthony Towns
eaa2e3f25c validation: move UpdateUncommittedBlockStructures and GenerateCoinbaseCommitment into ChainstateManager 2022-05-10 12:09:33 +10:00
Anthony Towns
5c67e84d37 validation: replace ::Params() calls with chainstate/chainman member 2022-05-10 12:09:33 +10:00
Anthony Towns
38860f93b6 validation: remove redundant CChainParams params from ChainstateManager methods 2022-05-10 12:09:33 +10:00
Anthony Towns
69675ea4e7 validation: add CChainParams to ChainstateManager 2022-05-10 12:09:27 +10:00
Hennadii Stepanov
b9219b233f
Merge bitcoin-core/gui#590: refactor: Declare WalletModel member functions with const
f70ee34c71 qt, refactor: Declare `WalletModel` member functions with `const` (Hennadii Stepanov)

Pull request description:

  After bitcoin/bitcoin#12830 the `WalletModel` class has two member functions: be7a5f2fc4/src/qt/walletmodel.h (L81) and be7a5f2fc4/src/qt/walletmodel.h (L154)

  This PR drops the former one as redundant, and declares `WalletModel` member functions with the `const` qualifier where appropriate.

ACKs for top commit:
  promag:
    Code review ACK f70ee34c71.
  kristapsk:
    cr ACK f70ee34c71
  w0xlt:
    Code Review ACK f70ee34c71

Tree-SHA512: 43e6661822c667229ea860fb94c2e3154c33773dbd9fca1f6f76cc31c5875a1a0e8caa65ddfc20dec2a43e29e7b2469b3b6fa148fe7ec000ded518b4958b2b38
2022-05-09 22:33:58 +02:00
Hennadii Stepanov
3dd95cb5c2
Merge bitcoin-core/gui#591: test: Add tests for tableView in AddressBookPage dialog
15069130c6 qt, test: Add tests for `tableView` in `AddressBookPage` dialog (Hennadii Stepanov)
edae3ab699 qt: No need to force Qt::QueuedConnection for NotifyAddressBookChanged (Hennadii Stepanov)

Pull request description:

  This PR is a prerequisite for more thorough testing of filtering in the `AddressBookPage` class in context of bitcoin-core/gui#578 and bitcoin-core/gui#585.

  Required for bitcoin-core/gui#592.

ACKs for top commit:
  promag:
    Code review ACK 15069130c6.

Tree-SHA512: 86986d47606cbd54d813436c7afb21894e2200b6d3042a7aa0b5e84821c765bd68b14ad38a445069891ab33f2d7bcd4933b8373e14e9afb0c91f1a6ddf4da740
2022-05-09 22:19:39 +02:00
Jon Atack
ca1ac1f0e0 scripted-diff: Rename MainSignalsInstance() class to MainSignalsImpl()
```
-BEGIN VERIFY SCRIPT-
s() { git grep -l "$1" src test doc | xargs sed -i "s/$1/$2/g"; }
s 'MainSignalsInstance' 'MainSignalsImpl'
-END VERIFY SCRIPT-
2022-05-09 18:35:44 +02:00
Jon Atack
2aaec2352d refactor: remove unused forward declarations in validationinterface.h 2022-05-09 18:33:40 +02:00
Jon Atack
23854f8402 refactor: make MainSignalsInstance() a class
and use Doxygen documentation for it, per our developer notes.

Context:

MainSignalsInstance was created in 3a19fed9db and originally was a struct
collection of boost::signals methods moved to validationinterface.cpp, in order
to no longer need to include boost/signals in validationinterface.h.

MainSignalsInstance then evolved in d6815a2313 to remove boost/signals2 and became class-like.

[C.8: Use class rather than struct if any member is
non-public](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-class)

[C.2: Use class if the class has an invariant; use struct if the data members can vary
independently](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently)

A class also has the advantage of default private access, as opposed to public for a struct.
2022-05-09 18:33:32 +02:00
MacroFake
dab18f03f7
Merge bitcoin/bitcoin#24946: Unroll the ChaCha20 inner loop for performance
81c09ee45c Unroll the ChaCha20 inner loop for performance (Pieter Wuille)

Pull request description:

  Unrolling the inner ChaCha20 loop gives a ~15% speedup for me in the CHACHA20_* benchmarks. It's a simple change, this performance helps with RNG generation, and will matter more for BIP324.

ACKs for top commit:
  martinus:
    tested ACK  81c09ee with clang++ 13.0.1, test `CHACHA20_1MB`:
  MarcoFalke:
    ACK 81c09ee45c 🍟

Tree-SHA512: 108bd0ba573bb08de92d611e7be7c09a2c2700f9655f44129b87f9b71f7e101dfc6bd345783e7b4b9b40f0b003913cf59187f422da8cdb5b20887f7855b2611a
2022-05-09 13:56:36 +02:00
Luke Dashjr
ba10b90915 Wallet: Ensure m_attaching_chain is set before registering for signals
Avoids a race where chainStateFlushed could be called before rescanning began, yet rescan gets interrupted or fails
2022-05-09 01:54:16 +00:00
MarcoFalke
fa4fb8d98b
random: Add FastRandomContext::rand_uniform_delay 2022-05-08 11:47:55 +02:00
MarcoFalke
faa5c62967
Add time helpers for std::chrono::steady_clock 2022-05-08 11:47:45 +02:00
w0xlt
92b35aba22 index, refactor: Change sync variables to use std::chrono::steady_clock
This refactors the sync variables to use `std::chrono::steady_clock`
as it is best suitable for measuring intervals.
2022-05-08 04:02:33 -03:00
avirgovi
2a22f034ca parsing external signer master fingerprint string as bytes instead of caring for lower/upper case in ExternalSigner::SignTransaction 2022-05-07 11:09:52 +02:00
MacroFake
59ac8bacd5
Merge bitcoin/bitcoin#24804: Sanity assert GetAncestor() != nullptr where appropriate
308dd2e93e Sanity assert GetAncestor() != nullptr where appropriate (Adam Jonas)

Pull request description:

  Re-opening #17232. I have rebased the PR and addressed jonatack's nit suggestions.

  Add sanity asserts for return value of `CBlockIndex::GetAncestor()` where appropriate.

  In validation.cpp `CheckSequenceLocks`, check the return value of `tip->GetAncestor(maxInputHeight)` stored into `lp->maxInputBlock`. If it ever returns `nullptr` because the ancestor isn't found, it's going to be a bad bug to keep going, since a `LockPoints` object with the `maxInputBlock` member set to `nullptr` signifies no relative lock time.

  In the other places, the added asserts would prevent accidental dereferencing of a null pointer which is undefined behavior.

  Co-Authored-By: Adam Jonas <jonas@chaincode.com>
  Co-Authored-By: danra <danra@users.noreply.github.com>

ACKs for top commit:
  jonatack:
    ACK 308dd2e93e

Tree-SHA512: 5bfdaab1499607ae2c3cd3e2e9e8c37850bfd0e327e680f4e36c81f9c6d98a543af78ecfac1ab0e06325d264412615a04d52005875780c7db2a4d81bd2d2259a
2022-05-06 11:46:20 +02:00
MacroFake
b557a24be9
Merge bitcoin/bitcoin#19426: refactor: Change * to & in MutableTransactionSignatureCreator
fac6cfc50f refactor: Change * to & in MutableTransactionSignatureCreator (MarcoFalke)

Pull request description:

  The `MutableTransactionSignatureCreator` constructor takes in a pointer to a mutable transaction. This is problematic for several reasons:

  * It would be undefined behaviour to pass in a nullptr because for signature creation, the memory of the mutable transaction is accessed
  * No caller currently passes in a nullptr, so passing a reference as a pointer is confusing

  Fix all issues by replacing `*` with `&` in `MutableTransactionSignatureCreator`

ACKs for top commit:
  theStack:
    Code-review ACK fac6cfc50f
  jonatack:
    ACK fac6cfc50f

Tree-SHA512: d84296b030bd4fa2709e5adbfe43a5f8377d218957d844af69a819893252af671df7f00004f5ba601a0bd70f3c1c2e58c4f00e75684da663f28432bb5c89fb86
2022-05-06 11:12:10 +02:00
MacroFake
b2e7811c62
Merge bitcoin/bitcoin#24538: miner: bug fix? update for ancestor inclusion using modified fees, not base
e4303c337c [unit test] prioritisation in mining (glozow)
7a8d60676b [miner] bug fix: update for parent inclusion using modified fee (glozow)
0f9a44461c MOVEONLY: group miner tests into MinerTestingSetup functions (glozow)

Pull request description:

  Came up while reviewing #24364, where some of us incorrectly assumed that we use the same fee deduction in `CTxMemPoolModifiedEntry::nModFeesWithAncestors` when first constructing an entry and in `update_for_parent_inclusion`.

  Actually, the behavior is this: when a mempool entry's ancestor is included in the block template, we create a `CTxMemPoolModifiedEntry` for it, subtracting the ancestor's modified fees from `nModFeesWithAncestors`. If another ancestor is included, we update it again, but use the ancestor's _base_ fees instead.

  I can't explain why we use `GetFee` in one place and `GetModifiedFee` in the other, but I'm quite certain we should be using the same one for both.

  And should it be base or modified fees? Modified, otherwise the child inherits the prioritisation of the parent, but only until the parent gets mined. If we want prioritisation to cascade down to current in-mempool descendants, we should probably document that in the `prioritsetransaction` helpstring and implement it in `CTxMemPool::mapDeltas`, not as a quirk in the mining code?

  Wrote a test in which a mempool entry has 2 ancestors, both prioritised, and both included in a block template individually. This test should fail without the s/GetFee/GetModifiedFee commit.

ACKs for top commit:
  ccdle12:
    tested ACK e4303c3
  MarcoFalke:
    ACK e4303c337c 🚗

Tree-SHA512: 4cd94106fbc9353e9f9b6d5af268ecda5aec7539245298c940ca220606dd0737264505bfaae1f83d94765cc2d9e1a6e913a765048fe6c19292482241761a6762
2022-05-06 11:06:13 +02:00
MacroFake
fa2deae2a8
Wrap boost::replace_all 2022-05-05 20:50:24 +02:00
Adam Jonas
308dd2e93e Sanity assert GetAncestor() != nullptr where appropriate
Add sanity asserts for return value of `CBlockIndex::GetAncestor()` where appropriate.

In validation.cpp `CheckSequenceLocks`, check the return value of `tip->GetAncestor(maxInputHeight)` stored into `lp->maxInputBlock`. If it ever returns `nullptr` because the ancestor isn't found, it's going to be a bad bug to keep going, since a `LockPoints` object with the `maxInputBlock` member set to `nullptr` signifies no relative lock time.

In the other places, the added asserts would prevent accidental dereferencing of a null pointer which is undefined behavior.

Co-Authored-By: Aurèle Oulès <aurele@oules.com>
Co-Authored-By: danra <danra@users.noreply.github.com>
2022-05-05 15:55:44 +02:00
t-bast
4185570340
Add RPC to get mempool txs spending outputs
We add an RPC to fetch the mempool transactions spending given outpoints.
Without this RPC, application developers would need to first call
`getrawmempool` which returns a long list of `txid`, then fetch each of
these txs individually to check whether they spend the given outpoint(s).

This RPC can later be enriched to also find confirmed transactions instead
of being restricted to mempool transactions.
2022-05-05 14:56:48 +02:00
MacroFake
0d080a183b
Merge bitcoin/bitcoin#24141: Rename message_command variables in src/net* and src/rpc/net.cpp
e71c51b27d refactor: rename command -> message type in comments in the src/net* files (Shashwat)
2b09593bdd scripted-diff: Rename message command to message type (Shashwat)

Pull request description:

  This PR is a follow-up to #24078.

  > a message is not a command, but simply a message of some type

  The first commit covers the message_command variable name and comments not addressed in the original PR in `src/net*` files.
  The second commit goes beyond the original `src/net*` limit of #24078 and does similar changes in the `src/rpc/net.cpp` file.

ACKs for top commit:
  MarcoFalke:
    review ACK e71c51b27d 💥

Tree-SHA512: 24015d132c00f15239e5d3dc7aedae904ae3103a90920bb09e984ff57723402763f697d886322f78e42a0cb46808cb6bc9d4905561dc6ddee9961168f8324b05
2022-05-05 08:37:35 +02:00
laanwj
d4475ea7ae
Merge bitcoin/bitcoin#22235: script: add script to generate example bitcoin.conf
b42643c253 doc: update init.cpp -conf help text (josibake)
970b9987ad doc: update devtools, release-process readmes (josibake)
50635d27b4 build: include bitcoin.conf in build outputs (josibake)
6aac946f49 doc: update bitcoin-conf.md (Josiah Baker)
1c7e820ded script: add script to generate example bitcoin.conf (josibake)
b483084d86 doc: replace bitcoin.conf with placeholder file (josibake)

Pull request description:

  create a script for parsing the output from `bitcoind --help` to create an example conf file for new users

  ## problem

  per #10746 , `bitcoin.conf` not being put into the data directory during installation causes some confusion for users when running bitcoin. in the discussion on the issue, one proposed solution was to have an example config file and instruct users to `cp` it into their data directory after startup. in addition to #10746 , there have been other requests for a "skeleton config file" (https://github.com/bitcoin/bitcoin/issues/19641) to help users get started with configuring bitcoind.

  the main issue with an example config file is that it creates a second source of truth regarding what options are available for configuring bitcoind. this means any changes to the options (including the addition or removal of options) would have to be updated for the command line and also updated in the example file.

  this PR addresses this issue by providing a script to generate an example file directly from the `bitcoind --help` on-demand by running `contrib/devtools/gen-bitcoin-conf.sh`. this solution was originally proposed on #10746 and would also solve #19641 . this guarantees any changes made to the command-line options or the command-line options help would also be reflected in the example file after compiling and running the script.

  the main purpose of this script is to generate a config file to be included with releases, same as `gen-manpages.sh`. this ensures every release also includes an up-to-date, full example config file for users to edit. the script is also available for users who compile from source for generating an example config for their compiled binary.

  ## special considerations

  this removes the `bitcoin.conf` example file from the repo as it is now generated by this script. the original example file did contain extra text related to how to use certain options but going forward all option help docs should be moved into `init.cpp`

  this also edits `init.cpp` to have the option help indicate that `-conf` is not usable from the config file. this is similar to how `-includeconf` 's help indicates it cannot be used from the command line

ACKs for top commit:
  laanwj:
    Tested and code review ACK b42643c253

Tree-SHA512: 4546e0cef92aa1398da553294ce4712d02e616dd72dcbe0b921af474e54f24750464ec813661f1283802472d1e8774e634dd1cc26fbf1f13286d3e0406c02c09
2022-05-04 21:12:56 +02:00
laanwj
5e1aacab57
Merge bitcoin/bitcoin#24933: util: Replace non-threadsafe strerror
e3a06a3c6c test: Add `strerror` to locale-dependence linter (laanwj)
f00fb1265a util: Increase buffer size to 1024 in SysErrorString (laanwj)
718da302c7 util: Refactor SysErrorString logic (laanwj)
e7f2f77756 util: Use strerror_s for SysErrorString on Windows (laanwj)
46971c6dbf util: Replace non-threadsafe strerror (laanwj)

Pull request description:

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

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

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

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

ACKs for top commit:
  jonatack:
    ACK e3a06a3c6c

Tree-SHA512: 20e71ebb9e979d4e1d8cafbb2e32e20c2a63f09115fe72cdde67c8f80ae98c531d286f935fd8a6e92a18b72607d7bd3e846b2d871d9691a6036b0676de8aaf25
2022-05-04 21:08:30 +02:00
Pieter Wuille
81c09ee45c Unroll the ChaCha20 inner loop for performance 2022-05-04 14:53:46 -04:00
josibake
b42643c253
doc: update init.cpp -conf help text
update help to reflect this option cannot be used from the config file
2022-05-04 20:45:50 +02:00
laanwj
fe6a299fc0
Merge bitcoin/bitcoin#24852: util: optimize HexStr
5e61532e72 util: optimizes HexStr (Martin Leitner-Ankerl)
4e2b99f72a bench: Adds a benchmark for HexStr (Martin Leitner-Ankerl)
67c8411c37 test: Adds a test for HexStr that checks all 256 bytes (Martin Leitner-Ankerl)

Pull request description:

  In my benchmark, this rewrite improves runtime 27% (g++) to 46% (clang++) for the benchmark `HexStrBench`:

  g++ 11.2.0
  |             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |                0.94 |    1,061,381,310.36 |    0.7% |           12.00 |            3.01 |  3.990 |           1.00 |    0.0% |      0.01 | `HexStrBench` master
  |                0.68 |    1,465,366,544.25 |    1.7% |            6.00 |            2.16 |  2.778 |           1.00 |    0.0% |      0.01 | `HexStrBench` branch

  clang++ 13.0.1
  |             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |                0.80 |    1,244,713,415.92 |    0.9% |           10.00 |            2.56 |  3.913 |           0.50 |    0.0% |      0.01 | `HexStrBench` master
  |                0.43 |    2,324,188,940.72 |    0.2% |            4.00 |            1.37 |  2.914 |           0.25 |    0.0% |      0.01 | `HexStrBench` branch

  Note that the idea for this change comes from denis2342 in #23364. This is a rewrite so no unaligned accesses occur.

  Also, the lookup table is now calculated at compile time, which hopefully makes the code a bit easier to review.

ACKs for top commit:
  laanwj:
    Code review ACK 5e61532e72
  aureleoules:
    tACK 5e61532e72.
  theStack:
    ACK 5e61532e72 🚤

Tree-SHA512: 40b53d5908332473ef24918d3a80ad1292b60566c02585fa548eb4c3189754971be5a70325f4968fce6d714df898b52d9357aba14d4753a8c70e6ffd273a2319
2022-05-04 20:36:09 +02:00
fanquake
33aaf434af
Merge bitcoin/bitcoin#24976: netgroup: Follow-up for #22910
e5d1831517 [netgroup] Use nStartByte as offset for the last byte of the group (dergoegge)

Pull request description:

  This addresses my review [comments](https://github.com/bitcoin/bitcoin/pull/22910#discussion_r856095896) I left on #22910.

  This has no effect on the current logic as `nStartByte` is only used for internal addresses which only ever add 10 whole bytes to the returned group. However to avoid future bugs, I think we should use `nStartByte` as offset for the last byte as well, in case we ever add a new address type that makes makes use of `nStartByte` and adds fractional bytes to the group.

ACKs for top commit:
  jnewbery:
    Code review ACK e5d1831517
  theStack:
    Concept and code-review ACK e5d1831517

Tree-SHA512: 4c08c7d6cb38b553e998798b3e3b790177aaa2141a48e277dfd538e01a7fccadf644329e93c5b0fb5e7e4037494c8dfe061b94eb52c6b31dc21bdf99eb0e311a
2022-05-04 18:57:53 +01:00
fanquake
bde5836f99
Merge bitcoin/bitcoin#25057: refactor: replace remaining boost::split with SplitString
f849e63bad fuzz: SplitString with multiple separators (Martin Leitner-Ankerl)
d1a9850102 http: replace boost::split with SplitString (Martin Leitner-Ankerl)
0d7efcdf75 core_read: Replace boost::split with SplitString (Martin Leitner-Ankerl)
b7ab9db545 Extend Split to work with multiple separators (Martin Leitner-Ankerl)

Pull request description:

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

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

Tree-SHA512: f37d4dbe11cab2046e646045b0f018a75f978d521443a2c5001512737a1370e22b09247d5db0e5c9e4153229a4e2d66731903c1bba3713711c4cae8cedcc775d
2022-05-04 18:20:27 +01:00
MarcoFalke
fac6cfc50f
refactor: Change * to & in MutableTransactionSignatureCreator 2022-05-04 11:49:29 +02:00
MacroFake
d17bbc3c48
Merge bitcoin/bitcoin#25060: blockstorage: add LIFETIMEBOUND to GetFirstStoredBlock()::start_time
4cb9d21434 blockstorage: add LIFETIMEBOUND to GetFirstStoredBlock()::start_time (Jon Atack)

Pull request description:

  Suggested in https://github.com/bitcoin/bitcoin/pull/25016#discussion_r862330288, the lifetimebound attribute here indicates that a resource owned by the `start_block` param of `CBlockIndex* BlockManager::GetFirstStoredBlock()` can be retained by the method's return value, which enables detecting the use of out-of-scope stack memory (ASan `stack-use-after-scope`) at compile time.

  See https://releases.llvm.org/12.0.0/tools/clang/docs/AttributeReference.html#lifetimebound and #22278 for related discussion, and #25040 for a similar example.

ACKs for top commit:
  MarcoFalke:
    review ACK 4cb9d21434

Tree-SHA512: a3f5ef83ebb6f08555d7c89f2437a682071b4ad77a7aa3326b6d2282c909bf9fcf4dac6bf05ee1d9931f2102cad4a02df5468bde1cf377d7126e84e8541604dc
2022-05-04 11:05:57 +02:00
fanquake
c290249fff
Merge bitcoin/bitcoin#25058: rpc: Move output script RPCs to separate file, rename misc.cpp
fa758f9bc5 scripted-diff: Rename rpc/misc.cpp to rpc/node.cpp (MacroFake)
fa87eb8ce1 rpc: Move output script RPCs to separate file (MacroFake)

Pull request description:

  RPCs handling output scripts (addresses, scriptPubKeys, and output script descriptors) should not be placed in a file called `misc.cpp`, so move them out, then rename `misc.cpp`.

ACKs for top commit:
  pk-b2:
    ACK fa758f9bc5
  vincenzopalazzo:
    ACK fa758f9bc5

Tree-SHA512: 0cf8b5b8456361015513e93d3e604ea07d998dd578415b1d0e2918fb401fc44547fc1bb80b7c33c2086f6268e7b8f59837d2955f57434f646ea7921f0158b32d
2022-05-04 10:03:43 +01:00
MacroFake
14cb53dfe9
Merge bitcoin/bitcoin#25040: refactor: Pass lifetimebound reference to SingleThreadedSchedulerClient
fa4652ce59 Pass lifetimebound reference to SingleThreadedSchedulerClient (MacroFake)

Pull request description:

  Currently a pointer is passed, which is confusing and requires run-time asserts to avoid nullptr dereference.

  All call sites can pass a reference, so do that. Also mark it LIFETIMEBOUND to avoid call sites passing a temporary. Also, unrelated cleanup in touched lines.

ACKs for top commit:
  pk-b2:
    ACK fa4652ce59
  jonatack:
    Code review ACK fa4652ce59 rebased to master, debug build, unit tests
  vincenzopalazzo:
    ACK fa4652ce59

Tree-SHA512: cd7ec77347e195d659b8892d34c1e9644d4f88552a4d5fa310dc1756eb27050a99d3098b0b0d27f8474230f82c178fd9e22e7018d8248d5e47a7f4caad395e25
2022-05-04 10:54:26 +02:00
MacroFake
880cec91fa
Merge bitcoin/bitcoin#25047: tidy: add readability-redundant-declaration
c2b295881f tidy: add readability-redundant-declaration (fanquake)

Pull request description:

ACKs for top commit:
  vincenzopalazzo:
    ACK c2b295881f
  jonatack:
    Review-only ACK c2b295881f

Tree-SHA512: 992dd81f9d0c511efcd8d9d1a8c05fc1401b854272f28f7f31ca0922164ddd7d7c01bfcf5ca268472b5d68969137110f5c0844a52938d294750584e1a948a874
2022-05-04 09:50:16 +02:00
Martin Leitner-Ankerl
f849e63bad
fuzz: SplitString with multiple separators
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2022-05-04 07:34:48 +02:00
Martin Leitner-Ankerl
d1a9850102
http: replace boost::split with SplitString
Also removes boost/algorithm/string.hpp from expected includes
2022-05-04 07:34:48 +02:00
Martin Leitner-Ankerl
0d7efcdf75
core_read: Replace boost::split with SplitString
Note that `SplitString` doesn't support token compression, but in this case
it does not matter as empty strings are already skipped anyways.

Also removes split.hpp and classification.hpp from expected includes
2022-05-04 07:34:47 +02:00
Martin Leitner-Ankerl
b7ab9db545
Extend Split to work with multiple separators 2022-05-04 07:34:47 +02:00
Jon Atack
4cb9d21434 blockstorage: add LIFETIMEBOUND to GetFirstStoredBlock()::start_time
See PR 22278 for discussion.

Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2022-05-03 22:20:31 +02:00
MacroFake
12455acca2
Merge bitcoin/bitcoin#24470: Disallow more unsafe string->path conversions allowed by path append operators
f64aa9c411 Disallow more unsafe string->path conversions allowed by path append operators (Ryan Ofsky)

Pull request description:

  Add more `fs::path` `operator/` and `operator+` overloads to prevent unsafe string->path conversions on Windows that would cause strings to be decoded according to the current Windows locale & code page instead of the correct string encoding.

  Update application code to deal with loss of implicit string->path conversions by calling `fs::u8path` or `fs::PathFromString` explicitly, or by just changing variable types from `std::string` to `fs::path` to avoid conversions altogether, or make them happen earlier.

  In all cases, there's no change in behavior either (1) because strings only contained ASCII characters and would be decoded the same regardless of what encoding was used, or (2) because of the 1:1 mapping between paths and strings using the `PathToString` and `PathFromString` functions.

  Motivation for this PR was just that I was experimenting with #24469 and noticed that operations like `fs::path / std::string` were allowed, and I thought it would be better not to allow them.

ACKs for top commit:
  hebasto:
    ACK f64aa9c411

Tree-SHA512: 944cce49ed51537ee7a35ea4ea7f5feaf0c8fff2fa67ee81ec5adebfd3dcbaf41b73eb35e49973d5f852620367f13506fd12a7a9b5ae3a7a0007414d5c9df50f
2022-05-03 10:39:42 +02:00
fanquake
64d2715533
Merge bitcoin/bitcoin#25053: Guard #include <config/bitcoin-config.h>
88044a14d9 Guard `#include <config/bitcoin-config.h>` (Hennadii Stepanov)

Pull request description:

  A fix for builds when the `HAVE_CONFIG_H` macro is not defined.

ACKs for top commit:
  Empact:
    Code Review ACK 88044a14d9

Tree-SHA512: f2bf1693c7671d7113dccaf66ae34a84719d86cb3271fa18b36611deab93a48d787b3ccfbd735d3b763017d709971cb1151d8d7f30390720009e6e2a6275b5b0
2022-05-03 09:03:23 +01:00
MacroFake
fa758f9bc5
scripted-diff: Rename rpc/misc.cpp to rpc/node.cpp
-BEGIN VERIFY SCRIPT-
 git mv src/rpc/misc.cpp src/rpc/node.cpp
 sed -i 's@rpc/misc.cpp@rpc/node.cpp@g' $(git grep -l misc.cpp)
 sed -i 's,RegisterMiscRPCCommands,RegisterNodeRPCCommands,g' $(git grep -l RegisterMiscRPCCommands)
-END VERIFY SCRIPT-
2022-05-03 09:05:15 +02:00
MacroFake
fa87eb8ce1
rpc: Move output script RPCs to separate file
Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-05-03 08:59:18 +02:00
MacroFake
2c56404088
Merge bitcoin/bitcoin#25029: rpc: Move fee estimation RPCs to separate file
fa753abd7c rpc: Move fee estimation RPCs to separate file (MacroFake)

Pull request description:

  Fee estimation is generally used by wallets when creating txs. It doesn't have anything to do with creating or submitting blocks.

ACKs for top commit:
  pk-b2:
    ACK fa753abd7c
  brunoerg:
    crACK fa753abd7c

Tree-SHA512: 81e0edc936198a0baf0f5bfa8cfedc12db51759c7873bb0082dfc5f0040d7f275b35f639c6f5b86fa1ea03397b0d5e757c2ce1b6b16f1029880a39b9c3aaceda
2022-05-03 08:17:50 +02:00
Hennadii Stepanov
88044a14d9
Guard #include <config/bitcoin-config.h> 2022-05-02 16:41:30 +02:00
MacroFake
5c93fc188d
Merge bitcoin/bitcoin#25017: validation: make CScriptCheck and prevector swap members noexcept
e5485e8e4b test, bench: make prevector and checkqueue swap member functions noexcept (Jon Atack)
abc1ee5090 validation: make CScriptCheck and prevector swap member functions noexcept (Jon Atack)

Pull request description:

  along with those seen elsewhere in the codebase (prevector and checkqueue units/fuzz/bench).

  A swap must not fail; when a class has a swap member function, it should be declared noexcept.
  https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c84-a-swap-function-must-not-fail

ACKs for top commit:
  pk-b2:
    ACK e5485e8e4b
  w0xlt:
    ACK e5485e8e4b

Tree-SHA512: c82359d5e13f9262ce45efdae9baf71e41ed26568e0aff620e2bfb0ab37a62b6d56ae9340a28a0332c902cc1fa87da3fb72d6f6d6f53a8b7e695a5011f71f7f1
2022-05-02 14:14:58 +02:00
fanquake
c2b295881f
tidy: add readability-redundant-declaration 2022-05-01 10:39:40 +01:00
MacroFake
fa12706fc6
Reject invalid rpcauth formats 2022-04-30 12:53:35 +02:00
MacroFake
5d53cf3878
Merge bitcoin/bitcoin#24543: net processing: Move remaining globals into PeerManagerImpl
778343a379 scripted-diff: Rename PeerManagerImpl members (dergoegge)
91c339243e [net processing] Move nHighestFastAnnounce into PeerManagerImpl (dergoegge)
10b83e2aa3 [net processing] Move block cache state into PeerManagerImpl (dergoegge)
a4c55a93ef [net processing] Inline and simplify UpdatePreferredDownload (dergoegge)
490c08f96a [net processing] Move nPreferredDownload into PeerManagerImpl (dergoegge)
a292df283a [net processing] Move mapNodeState into PeerManagerImpl (dergoegge)
37ecaf3e7a [net processing] Move CNodeState declaration above PeerManagerImpl (dergoegge)

Pull request description:

  This PR moves the remaining net processing globals into `PeerManagerImpl`. This will make testing the peer manager in isolation easier and also acts as a code clean up.

ACKs for top commit:
  jnewbery:
    Code review ACK 778343a379
  MarcoFalke:
    ACK 778343a379 🗒

Tree-SHA512: 4f22105d1de37b94c3ef349f38784a30cf8d450d394a6a7849e5bd78940a71e3edbffa3d25e8efb35d7f698fd255f199de7bd4c33e23af5621a6e4e67ed43cb5
2022-04-30 11:51:22 +02:00
MacroFake
fa4652ce59
Pass lifetimebound reference to SingleThreadedSchedulerClient 2022-04-30 09:17:17 +02:00
MacroFake
fa753abd7c
rpc: Move fee estimation RPCs to separate file
Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-04-29 16:25:06 +02:00
MacroFake
fafa727612
test: Remove boost::split from getarg_tests.cpp 2022-04-29 14:35:50 +02:00
MacroFake
26296eba3d
Merge bitcoin/bitcoin#25025: test: Remove boost::split from rpc_tests.cpp
fad35e9afd test: Remove boost::split from rpc_tests.cpp (MacroFake)

Pull request description:

  No need for boost, as there are no tabs.

  Can be tested with:

  ```diff
  diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp
  index 50b5078110..ad6a888ad0 100644
  --- a/src/test/rpc_tests.cpp
  +++ b/src/test/rpc_tests.cpp
  @@ -29,6 +29,7 @@ public:

   UniValue RPCTestingSetup::CallRPC(std::string args)
   {
  +Assert(args.find('\t')==std::string::npos);
       std::vector<std::string> vArgs;
       boost::split(vArgs, args, boost::is_any_of(" \t"));
       std::string strMethod = vArgs[0];

ACKs for top commit:
  fanquake:
    utACK fad35e9afd

Tree-SHA512: 3df789a222b407d61ad549adc4bbded00705d7c3db07472c31ce0e82216fe3ae27724b7f0ee3e85084bdf405cc28185e85487c9a7001620d6654fda77bab8eb3
2022-04-29 14:05:29 +02:00
fanquake
194b414697
Merge bitcoin/bitcoin#25016: refactor: GetFirstStoredBlock() and getblockchaininfo follow-ups
e2b954e87f rpc: use GetBlockTime() for getblockchaininfo#time (Jon Atack)
86ce844d3b blockstorage, refactor: pass GetFirstStoredBlock() start_block by reference (Jon Atack)
ed12c0a49d blockstorage, refactor: make GetFirstStoredBlock() a member of BlockManager (Jon Atack)

Pull request description:

  Picks up the remaining review feedback in #21726 and #24956.

  - make the global function `GetFirstStoredBlock()` a member of the `BlockManager` class
  - pass the `start_block` param of `GetFirstStoredBlock()` by reference instead of a pointer
  - use `GetBlockTime()` for RPC getblockchaininfo#time

ACKs for top commit:
  MarcoFalke:
    ACK e2b954e87f

Tree-SHA512: 546e3c2e18245996b5b286829a605ae919eff3510963ec71b7c9ede521b1f501697e5b2f9d35d7a0606a74cbc8907201c58acf1e2cf7daaa86eefe2e3a8e296b
2022-04-29 12:36:34 +01:00
fanquake
246db98897
Merge bitcoin/bitcoin#25024: test: Split MempoolAncestryTests into two
fa2102e239 test: Split MempoolAncestryTests into two (MacroFake)

Pull request description:

  The two tests don't share any state, so it seems clearer to put them in separate scopes.

ACKs for top commit:
  jnewbery:
    Code review ACK fa2102e239

Tree-SHA512: 6669f50f8d5944fed55ecc88aa1bd139bddf6a40e3c2e8f88c3cc7e70cf6d4650c0dd652c7f304813893827c3930d626268655cd9b3f17ff9c9a1a02f0359714
2022-04-29 12:33:17 +01:00
fanquake
91ac12be44
Merge bitcoin/bitcoin#25013: Remove cs_main from verifymessage, move msg utils to new file
fa60169811 rpc: Move signmessage RPC util to new file (MacroFake)
fa9425177e Remove cs_main from verifymessage (MacroFake)

Pull request description:

  The `verifymessage` RPC has several issues:

  * It takes `cs_main` for no reason, blocking progress on removing the `cs_main` global mutex.
  * It is located in a file called `misc`, which is not a very helpful name.

  Fix all issues.

ACKs for top commit:
  vincenzopalazzo:
    ACK fa60169811

Tree-SHA512: c71a1f481b828e0a544405fecbbc7ca44e66ea46b498d7aed1f1c584d6a99724deb13e89d90b9d5cdeecbce293e6a41e9f7ae299543f6d761bf9e7a839b6c7f3
2022-04-29 12:20:10 +01:00
MacroFake
fad35e9afd
test: Remove boost::split from rpc_tests.cpp 2022-04-29 11:40:42 +02:00
MacroFake
fa2102e239
test: Split MempoolAncestryTests into two 2022-04-29 09:43:11 +02:00
MacroFake
91a6736136
Merge bitcoin/bitcoin#25009: Crash debug builds on PCKG_MEMPOOL_ERROR
fa10c9f5a1 Crash debug builds on PCKG_MEMPOOL_ERROR (MacroFake)

Pull request description:

  Would be nice to allow fuzz targets to meaningfully cover this code

ACKs for top commit:
  glozow:
    utACK fa10c9f5a1
  vincenzopalazzo:
    ACK fa10c9f5a1

Tree-SHA512: 68efacedbf72f67cf3dc0bb9927a698492cdc1b08df91ef6af863ad8828b78058a64e52d64d244a5b2966cb9e63797b2647d1bb222677bf83b26fca6e4b1dbf0
2022-04-29 08:20:04 +02:00
Andrew Chow
606ce05ec2
Merge bitcoin/bitcoin#18554: wallet: ensure wallet files are not reused across chains
5f213213cb tests: add tests for cross-chain wallet use prevention (Seibart Nedor)
968765973b wallet: ensure wallet files are not reused across chains (Seibart Nedor)

Pull request description:

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

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

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

Tree-SHA512: 2c934300f113e772fc31c16ef5588526300bbc36e4dcef7d77bd0760c5c8f0ec77f766b1bed5503eb0157fa26dc900ed54d2ad1b41863c1f736ce5c1f3b67bec
2022-04-28 15:59:47 -04:00
Andrew Chow
4cf9fa0b66
Merge bitcoin/bitcoin#24984: wallet: ignore chainStateFlushed notifications while attaching chain
2052e3aa9a wallet: ignore chainStateFlushed notifications while attaching chain (Martin Zumsande)

Pull request description:

  Fixes #24487

  When a rescan is performed during `CWallet::AttachChain()` (e.g. when loading an old wallet) but this is interrupted by a shutdown signal, the wallet will currently stop the rescan, receive a `chainStateFlushed` signal, set the saved best block to the tip and shut down. At next startup, the rescan is not continued or repeated because of this. But some blocks have never been scanned by the wallet, which could lead to an incorrect balance.

  Fix this by ignoring `chainStateFlushed` notifications until the chain is attached. Since `CWallet::chainStateFlushed` is being manually called by `AttachChain()` anyway after finishing with the rescan, it is not a problem if intermediate notifications are ignored.

  Manual rescans started / aborted by the `rescanblockchain` / `abortrescan` RPCs are not affected by this.

  I didn't choose alternative ways of fixing this issue that would delay the validationinterface registration or change anything else about the handling of `blockConnected` signals for the reasons mentioned in [this existing comment](https://github.com/bitcoin/bitcoin/blob/master/src/wallet/wallet.cpp#L2937-L2944).

ACKs for top commit:
  achow101:
    ACK 2052e3aa9a
  ryanofsky:
    Code review ACK 2052e3aa9a. This is a straightforward fix for the bug described in #24487 where a wallet could skip scanning blocks if is shut down in the middle of a sync and a chainStateFlushed notification was received during the sync. It would be nice to write a test for this but probably would be tricky to write.
  w0xlt:
    Code Review ACK 2052e3aa9a

Tree-SHA512: a6186173d72b26bd4adbf2315e11af365004a723ea5565a0f7b868584dc47c321a6572eafaeb2420bd21eed1c7ad92b47e6218c5eb72313a3c6bee58364e2247
2022-04-28 14:54:17 -04:00
Jon Atack
e2b954e87f rpc: use GetBlockTime() for getblockchaininfo#time 2022-04-28 20:51:33 +02:00
Jon Atack
86ce844d3b blockstorage, refactor: pass GetFirstStoredBlock() start_block by reference
instead of by pointer, so as to not accept a nullptr.
2022-04-28 20:42:08 +02:00
Jon Atack
ed12c0a49d blockstorage, refactor: make GetFirstStoredBlock() a member of BlockManager
instead of a global
2022-04-28 20:42:08 +02:00
Jon Atack
e5485e8e4b test, bench: make prevector and checkqueue swap member functions noexcept
Reason:
A swap must not fail; when a class has a swap member function, it should be declared noexcept.
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c84-a-swap-function-must-not-fail
2022-04-28 20:34:43 +02:00
MacroFake
dabec99013
Merge bitcoin/bitcoin#24956: Call CHECK_NONFATAL only once where needed
fab34d392c Call CHECK_NONFATAL only once where needed (MarcoFalke)

Pull request description:

  Now that `CHECK_NONFATAL` is the identity function starting with commit b1c5991eeb, it can be called less often in places where it was called more than once on the same value.

ACKs for top commit:
  jonatack:
    Review ACK fab34d392c

Tree-SHA512: ae221d7ee81f8d0be7ab21ce54d5d209e691df8a5c7f4a6f6db282453391904f87f533a2b7f85d6259827de8b85dacd9e0d9dbeecc4245a338247e0893ff3459
2022-04-28 20:23:22 +02:00
Jon Atack
abc1ee5090 validation: make CScriptCheck and prevector swap member functions noexcept
Reason:
A swap must not fail; when a class has a swap member function, it should be declared noexcept.
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c84-a-swap-function-must-not-fail
2022-04-28 20:22:56 +02:00
fanquake
dd17c42a16
Merge bitcoin/bitcoin#24322: [kernel 1/n] Introduce initial libbitcoinkernel
035fa1f07a build: Remove LIBTOOL_APP_LDFLAGS for bitcoin-chainstate (Cory Fields)
3f0595095d docs: Add libbitcoinkernel_la_SOURCES explanation (Carl Dong)
94ad45deb2 ci: Build libbitcoinkernel (Carl Dong)
26b2e7ffb3 build: Extract the libbitcoinkernel library (Carl Dong)
1df44dd20c b-cs: Define G_TRANSLATION_FUN in bitcoinkernel.cpp (Carl Dong)
83a0bb7cc9 build: Separate lib_LTLIBRARIES initialization (Carl Dong)
c1e16cb31f build: Create .la library for bitcoincrypto (Carl Dong)
8bdfe057c7 build: Create .la library for leveldb (Carl Dong)
05d1525b6d build: Create .la library for crc32c (Carl Dong)
64caf94479 build: Remove vestigial LIBLEVELDB_SSE42 (Carl Dong)
1392e8e2d8 build: Don't add unrelated libs to LIBTEST_* (Carl Dong)

Pull request description:

  Part of: #24303

  This PR introduces a `libbitcoinkernel` static library linking in the minimal list of files necessary to use our consensus engine as-is. `bitcoin-chainstate` introduced in #24304 now will link against `libbitcoinkernel`.

  Most of the changes are related to the build system.

  Please read the commit messages for more details.

ACKs for top commit:
  theuni:
    This may be my favorite PR ever. It's a privilege to ACK 035fa1f07a.

Tree-SHA512: b755edc3471c7c1098847e9b16ab182a6abb7582563d9da516de376a770ac7543c6fdb24238ddd4d3d2d458f905a0c0614b8667aab182aa7e6b80c1cca7090bc
2022-04-28 15:14:32 +01:00
fanquake
e36c612e5a
Merge bitcoin/bitcoin#24988: lint: Mention NONFATAL_UNREACHABLE in lint-assertions.py
fa82a1ed83 lint: Mention NONFATAL_UNREACHABLE in lint-assertions.py (MacroFake)

Pull request description:

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

ACKs for top commit:
  fanquake:
    ACK fa82a1ed83

Tree-SHA512: cf398eceb135672137183bfa19ee57a82553a3dbcbce74db954c6fcd79f9606092cc0d8217610fe6cd67b7ef2d4f01d90329f0f568516d9b14aa2cd0f0715478
2022-04-28 12:40:36 +01:00
MacroFake
b51e60f914
Merge bitcoin/bitcoin#22564: refactor: Move mutable globals cleared in ::UnloadBlockIndex to BlockManager
7ab07e0332 validation: Prune UnloadBlockIndex and callees (Carl Dong)
7d99d725cd validation: No mempool clearing in UnloadBlockIndex (Carl Dong)
572d831927 Clear {versionbits,warning}cache in ~Chainstatemanager (Carl Dong)
eca4ca4d60 style-only: Use std::clamp for check_ratio, rename (Carl Dong)
fe96a2e4bd style-only: Use for instead of when loading Chainstate (Carl Dong)
5921b863e3 init: Reset mempool and chainman via reconstruction (Carl Dong)
6e747e80e7 validation: default initialize and guard chainman members (Anthony Towns)
98f4bdae81 refactor: Convert warningcache to std::array (Carl Dong)

Pull request description:

  Fixes #22964

  -----

  This is a small part of the work to accomplish what I described in 972c5166ee:
  ```
  Over time, we should probably move these mutable global state variables
  into ChainstateManager or CChainState so it's easier to reason about
  their lifecycles.
  ```

  `::UnloadBlockIndex` manually resets a subset of our mutable globals in addition to unloading the `ChainstateManager` and clearing the mempool. The need for this manual reset (AFAICT) arises out of the fact that many of these globals are closely related to the block index (hence `::UnloadBlockIndex`), and need to be reset with it.

  I've shot this "manual reset" gun at my foot several times while doing the de-globalize chainman work.

  Thankfully, now that we have a `BlockManager` class that owns the block index, these globals should be moved under that class so that they can live and die with the block index. These moves, along with making the block index non-heap-based, eliminates:
  1. 3585b52139 The need to reason about when we need to manually call `::UnloadBlockIndex` (this decision can at times seem almost arbitrary)
  2. f741623c25 The need to have an `::UnloadBlockIndex` or explicit `~ChainstateManager` at all

ACKs for top commit:
  MarcoFalke:
    ACK 7ab07e0332 👘
  ajtowns:
    ACK 7ab07e0332
  ryanofsky:
    Code review ACK 7ab07e0332. This all looks good and simplifies things nicely. I left some minor suggestions below but feel free to ignore.

Tree-SHA512: a36ee3fc122ce0b4e8d1c432662d7009df06264b724b793252978a1e409dde7a7ef1f78b9ade3f8bfb5388213f10ae2d058d57a7a46ae563e9034d7d33a52b69
2022-04-28 12:14:06 +02:00
MacroFake
fa60169811
rpc: Move signmessage RPC util to new file
Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-04-28 11:19:29 +02:00
MacroFake
fa9425177e
Remove cs_main from verifymessage 2022-04-28 11:09:38 +02:00
laanwj
f00fb1265a util: Increase buffer size to 1024 in SysErrorString
Increase the error message buffer to 1024 as recommended in the manual
page (Thanks Jon Atack)
2022-04-28 10:24:06 +02:00
laanwj
718da302c7 util: Refactor SysErrorString logic
Deduplicate code and error checks by making sure `s` stays `nullptr`
in case of error. Return "Unknown error" instead of an empty string in
this case.
2022-04-28 10:24:06 +02:00
laanwj
e7f2f77756 util: Use strerror_s for SysErrorString on Windows 2022-04-28 10:24:06 +02:00
laanwj
46971c6dbf util: Replace non-threadsafe strerror
Some uses of non-threadsafe `strerror` have snuck into the code since
they were removed in #4152. Add a wrapper `SysErrorString` for
thread-safe strerror alternatives and replace all uses of `strerror`
with this.
2022-04-28 10:24:06 +02:00
MacroFake
9446de160f
Merge bitcoin/bitcoin#24831: tidy: add include-what-you-use
9b0a13a289 tidy: Add include-what-you-use (fanquake)
74cd038e30 refactor: fix includes in src/init (fanquake)
c79ad935f0 refactor: fix includes in src/compat (fanquake)

Pull request description:

  We recently added a [`clang-tidy` job](https://github.com/bitcoin/bitcoin/blob/master/ci/test/00_setup_env_native_tidy.sh) to the CI, which generates a compilation database. We can leverage that now existing database to begin running [include-what-you-use](https://include-what-you-use.org/) over the codebase.

  This PR demonstrates using a mapping_file to indicate fixups / includes that may differ from IWYU suggestions. In this case, I've added some fixups for glibc includes that I've [upstreamed changes for](https://github.com/include-what-you-use/include-what-you-use/pull/1026):
  ```bash
  # Fixups / upstreamed changes
  [
    { include: [ "<bits/termios-c_lflag.h>", private, "<termios.h>", public ] },
    { include: [ "<bits/termios-struct.h>", private, "<termios.h>", public ] },
    { include: [ "<bits/termios-tcflow.h>", private, "<termios.h>", public ] },
  ]
  ```

  The include "fixing" commits of this PR:
  * Adds missing includes.
  * Swaps C headers for their C++ counterparts.
  * Removes the pointless / unmaintainable `//for abc, xyz` comments. When using IWYU, if anyone wants to see / generate those comments, to see why something is included, it is trivial to do so (IWYU outputs them by default). i.e:
  ```cpp
  // The full include-list for compat/stdin.cpp:
  #include <compat/stdin.h>
  #include <poll.h>                  // for poll, pollfd, POLLIN
  #include <termios.h>               // for tcgetattr, tcsetattr
  #include <unistd.h>                // for isatty, STDIN_FILENO
  ```

  TODO:
  - [ ] Qt mapping_file. There is one in the IWYU repo, but it's for Qt 5.11. Needs testing.
  - [ ] Boost mapping_file. There is one in the IWYU repo, but it's for Boost 1.75. Needs testing.

  I'm not suggesting we turn this on the for entire codebase, or immediately go-nuts refactoring all includes. However I think our dependency includes are now slim enough, and our CI infrastructure in place such that we can start doing this in some capacity, and just automate away include fixups / refactorings etc.

ACKs for top commit:
  MarcoFalke:
    review ACK 9b0a13a289
  jonatack:
    ACK 9b0a13a289 reviewed changes and run CI output in https://cirrus-ci.com/task/4750910332076032

Tree-SHA512: 00beab5a5f2a6fc179abf08321a15391ecccaa91ab56f3c50c511e7b29a0d7c95d8bb43eac2c31489711086f6f77319d43d803cf8ea458e7cd234a780d9ae69e
2022-04-28 10:06:26 +02:00
Cory Fields
035fa1f07a build: Remove LIBTOOL_APP_LDFLAGS for bitcoin-chainstate
See added comment.

Note that this won't actually have any effect until we add the mingw-w64
DLL fix since LIBTOOL_APP_LDFLAGS is undefined for other platforms.
2022-04-27 17:36:49 -04:00
Carl Dong
3f0595095d docs: Add libbitcoinkernel_la_SOURCES explanation 2022-04-27 17:36:39 -04:00
Carl Dong
26b2e7ffb3 build: Extract the libbitcoinkernel library
I strongly recommend reviewing with the following git-diff flags:
  --patience --color-moved=dimmed-zebra

Extract out a libbitcoinkernel library linking in all files necessary
for using our consensus engine as-is. Link bitcoin-chainstate against
it.

See previous commit "build: Add example bitcoin-chainstate executable"
for more context.

We explicitly specify -fvisibility=default, which effectively overrides
the effects of --enable-reduced-exports since libbitcoinkernel requires
default symbol visibility

When compiling for mingw-w64, specify -static in both:

- ..._la_CXXFLAGS so that libtool will avoid building two versions of
  each object (one PIC, one non-PIC). We just need the one that is
  suitable for static linking.
- ..._la_LDFLAGS so that libtool will create a static library.

If we don't specify this, then libtool will prefer the non-static PIC
version of the object, which is built with -DDLL_EXPORT -DPIC for
mingw-w64 targets. This can cause symbol resolution problems when we
link this library against an executable that does specify -all-static,
since that will be built without the -DDLL_EXPORT flag.

Unfortunately, this means that for mingw-w64 we can only build a static
version of the library for now. This will be fixed.

However, on other targets, the shared library creation works fine.

-----

Note to users: You need to either specify:

  --enable-experimental-util-chainstate

or,

  --with-experimental-kernel-lib

To build the libbitcionkernel library. See the configure help for more
details.

build shared libbitcoinkernel where we can
2022-04-27 17:36:39 -04:00
MarcoFalke
facd1fb911
refactor: Use Span of std::byte in CExtKey::SetSeed 2022-04-27 19:53:37 +02:00
MarcoFalke
fae1006019
util: Add ParseHex<std::byte>() helper 2022-04-27 19:53:17 +02:00
MarcoFalke
fabdf81983
test: Add test for embedded null in hex string
Also, fix style in the corresponding function. The style change can be
reviewed with "--word-diff-regex=."
2022-04-27 19:18:20 +02:00
MacroFake
f0a834e2f1
Merge bitcoin/bitcoin#18642: Use std::chrono for the time to rotate destination of addr messages + tests
2ff8f4dd81 Add tests for addr destination rotation (Gleb Naumenko)
77ccb7fce1 Use std::chrono for salting when randomizing ADDR destination (Gleb Naumenko)

Pull request description:

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

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

  Also added couple tests for this behavior.

ACKs for top commit:
  jonatack:
    ACK 2ff8f4dd81

Tree-SHA512: 16f703ef3ffee13ce3afa82ca7b4baa27308af18cd2eececdce5565badfb68656a2ad9c4594b73772e4bfa99b3fb15f8e4089c1cb4be98c0bae6730a9d2f8a25
2022-04-27 18:59:46 +02:00
MacroFake
fa10c9f5a1
Crash debug builds on PCKG_MEMPOOL_ERROR 2022-04-27 18:26:47 +02:00
laanwj
132d5f8c2f
Merge bitcoin/bitcoin#25001: Modernize util/strencodings and util/string: string_view and optional
fa7078d84f scripted-diff: Rename ValidAsCString to ContainsNoNUL (MacroFake)
e7d2fbda63 Use std::string_view throughout util strencodings/string (Pieter Wuille)
8ffbd1412d Make DecodeBase{32,64} take string_view arguments (Pieter Wuille)
1a72d62152 Generalize ConvertBits to permit transforming the input (Pieter Wuille)
78f3ac51b7 Make DecodeBase{32,64} return optional instead of taking bool* (Pieter Wuille)
a65931e3ce Make DecodeBase{32,64} always return vector, not string (Pieter Wuille)
a4377a0843 Reject incorrect base64 in HTTP auth (Pieter Wuille)
d648b5120b Make SanitizeString use string_view (Pieter Wuille)
963bc9b576 Make IsHexNumber use string_view (Pieter Wuille)
40062997f2 Make IsHex use string_view (Pieter Wuille)
c1d165a8c2 Make ParseHex use string_view (Pieter Wuille)

Pull request description:

  Make use of `std::string_view` and `std::optional` in the util/{strencodings, string} files.

  This avoids many temporary string/vector objects being created, while making the interface easier to read. Changes include:
  * Make all input arguments in functions in util/strencodings and util/string take `std::string_view` instead of `std::string`.
  * Add `RemovePrefixView` and `TrimStringView` which also *return* `std::string_view` objects (the corresponding `RemovePrefix` and `TrimString` keep returning an `std::string`, as that's needed in many call sites still).
  * Stop returning `std::string` from `DecodeBase32` and `DecodeBase64`, but return vectors. Base32/64 are fundamentally algorithms for encoding bytes as strings; returning `std::string` from those (especially doing it conditionally based on the input arguments/types) is just bizarre.
  * Stop taking a `bool* pf_invalid` output argument pointer in `DecodeBase32` and `DecodeBase64`; return an `std::optional` instead.
  * Make `DecodeBase32` and `DecodeBase64` more efficient by doing the conversion from characters to integer symbols on-the-fly rather than through a temporary vector.

ACKs for top commit:
  MarcoFalke:
    re-ACK fa7078d84f only change is rebase and adding a scripted-diff 🍲
  martinus:
    Code review ACK fa7078d84f, found no issue
  laanwj:
    Code review ACK  fa7078d84f
  sipa:
    utACK fa7078d84f (as far as the commit that isn't mine goes)

Tree-SHA512: 5cf02e541caef0bcd100466747664bdb828a68a05dae568cbcd0632a53dd3a4c4e85cd8c48ebbd168d4247d5c9666689c16005f1c8ad75b0f057d8683931f664
2022-04-27 17:18:54 +02:00
Carl Dong
7ab07e0332 validation: Prune UnloadBlockIndex and callees
In previous commits in this patchset, we've made sure that every
Unload/UnloadBlockIndex member function resets its own members, and does
not reach out to globals.

This means that their corresponding classes' default destructors can now
replace them, and do an even more thorough job without the need to be
updated for every new member variable.

Therefore, we can remove them, and also remove UnloadBlockIndex since
that's not used anymore.

Unfortunately, chainstatemanager_loadblockindex relies on
CChainState::UnloadBlockIndex, so that needs to stay for now.
2022-04-27 11:13:38 -04:00
Carl Dong
7d99d725cd validation: No mempool clearing in UnloadBlockIndex
The only caller that uses this is ~ChainTestingSetup() where we
immediately destroy the mempool afterwards.
2022-04-27 11:13:38 -04:00
Carl Dong
572d831927 Clear {versionbits,warning}cache in ~Chainstatemanager
Also add TODO item to deglobalize the {versionbits,warning}cache, which
should really only need to be cleared if we change the chainparams.
2022-04-27 11:13:38 -04:00
Carl Dong
eca4ca4d60 style-only: Use std::clamp for check_ratio, rename 2022-04-27 11:13:32 -04:00
Carl Dong
fe96a2e4bd style-only: Use for instead of when loading Chainstate
It's a bit clearer and restricts the scope of fLoaded
2022-04-27 11:09:05 -04:00
Carl Dong
5921b863e3 init: Reset mempool and chainman via reconstruction
Fixes https://github.com/bitcoin/bitcoin/issues/22964

Previously, we used UnloadBlockIndex() in order to reset node.mempool
and node.chainman. However, that has proven to be fragile (see
https://github.com/bitcoin/bitcoin/issues/22964), and requires
UnloadBlockIndex and its callees to be updated manually for each member
that's introduced to the mempool and chainman classes.

In this commit, we stop using the UnloadBlockIndex function and we
simply reconstruct node.mempool and node.chainman.

Since PeerManager needs a valid reference to both node.mempool and
node.chainman, we also move PeerManager's construction via `::make` to
after the chainstate activation sequence is complete.

There are no more callers to UnloadBlockIndex after this commit, so it
and its sole callees can be pruned.
2022-04-27 11:09:00 -04:00
Hennadii Stepanov
0b8e2868f5
Merge bitcoin-core/gui#589: Getting ready to Qt 6 (7/n). Do not pass WalletModel* to a queued connection
ab73d5985d Do not pass `WalletModel*` to queued connection (Hennadii Stepanov)
fdf7285950 refactor: Make `RPCExecutor*` a member of the `RPCConsole` class (Hennadii Stepanov)
61457c179a refactor: Guard `RPCConsole::{add,remove}Wallet()` with `ENABLE_WALLET` (Hennadii Stepanov)

Pull request description:

  On master (094d9fda5c), the following queued connection 094d9fda5c/src/qt/rpcconsole.cpp (L1107) uses a `const WalletModel*` parameter regardless whether the `ENABLE_WALLET` macro is defined.

  Although this code works in Qt 5, it is flawed. On Qt 6, the code gets broken because the fully defined `WalletModel` type is required which is not the case if `ENABLE_WALLET` is undefined.

  This PR fixes the issue described above.

ACKs for top commit:
  promag:
    ACK ab73d5985d
  jarolrod:
    code review ACK ab73d5985d

Tree-SHA512: 544ba984da4480aa34f1516a737d6034eb5616b8f78db38dc9bf2d15c15251957bc0b0c9b0d5a365552da9b64a850801a6f4caa12b0ac220f51bd2b334fbe545
2022-04-27 14:50:39 +02:00
MacroFake
fa7078d84f
scripted-diff: Rename ValidAsCString to ContainsNoNUL
-BEGIN VERIFY SCRIPT-
 sed -i 's,ValidAsCString,ContainsNoNUL,g' $(git grep -l ValidAsCString)
-END VERIFY SCRIPT-
2022-04-27 14:16:35 +02:00
Pieter Wuille
e7d2fbda63 Use std::string_view throughout util strencodings/string 2022-04-27 14:13:39 +02:00
Pieter Wuille
8ffbd1412d Make DecodeBase{32,64} take string_view arguments 2022-04-27 14:12:55 +02:00
Pieter Wuille
1a72d62152 Generalize ConvertBits to permit transforming the input 2022-04-27 14:12:55 +02:00
Pieter Wuille
78f3ac51b7 Make DecodeBase{32,64} return optional instead of taking bool* 2022-04-27 14:12:55 +02:00
Pieter Wuille
a65931e3ce Make DecodeBase{32,64} always return vector, not string
Base32/base64 are mechanisms for encoding binary data. That they'd
decode to a string is just bizarre. The fact that they'd do that
based on the type of input arguments even more so.
2022-04-27 14:12:55 +02:00
Pieter Wuille
a4377a0843 Reject incorrect base64 in HTTP auth
In addition, to make sure that no call site ignores the invalid
decoding status, make the pf_invalid argument mandatory.
2022-04-27 14:12:55 +02:00
Pieter Wuille
d648b5120b Make SanitizeString use string_view 2022-04-27 14:12:55 +02:00
Pieter Wuille
963bc9b576 Make IsHexNumber use string_view 2022-04-27 14:12:55 +02:00
Pieter Wuille
40062997f2 Make IsHex use string_view 2022-04-27 14:12:55 +02:00
Pieter Wuille
c1d165a8c2 Make ParseHex use string_view 2022-04-27 14:12:55 +02:00
MarcoFalke
fab34d392c
Call CHECK_NONFATAL only once where needed 2022-04-27 13:35:24 +02:00
Anthony Towns
6e747e80e7 validation: default initialize and guard chainman members 2022-04-26 18:43:37 -04:00
Carl Dong
98f4bdae81 refactor: Convert warningcache to std::array 2022-04-26 18:41:59 -04:00
Carl Dong
1df44dd20c b-cs: Define G_TRANSLATION_FUN in bitcoinkernel.cpp
[META] This is done in preparation for extracting libbitcoinkernel in a
       following commit. It seems logical that generally users of a
       library shouldn't need to export its own symbols to use the
       library.
2022-04-26 16:30:53 -04:00
Carl Dong
83a0bb7cc9 build: Separate lib_LTLIBRARIES initialization
Set lib_LTLIBRARIES with '=' to an empty value at the top of the
Makefile.am and append to it from the library-local block for
readability.

Here's the error you get if you don't set lib_LTLIBRARIES to be empty:

    error: lib_LTLIBRARIES must be set with '=' before using '+='

[META] In a subsequent commit, we're going to introduce a library and
       append it to lib_LTLIBRARIES in its local block, this makes
       things more readable.
2022-04-26 16:30:53 -04:00
Carl Dong
c1e16cb31f build: Create .la library for bitcoincrypto
Libtool will yell at you if you try to link a shared library against
static ones.

This change creates a libtool archive library for bitcoincrypto and
allows a shared library to be linked against it portably.

Also specify -static in both:

- ..._la_CXXFLAGS so that libtool will avoid building two versions of
  each object (one PIC, one non-PIC). We just need the one that is
  suitable for static linking.
- ..._la_LDFLAGS so that libtool will create a static library.

[META] This change is done in preparation for a future commit where we
       link the libbitcoinkernel library against this one.
2022-04-26 16:30:41 -04:00
Carl Dong
8bdfe057c7 build: Create .la library for leveldb
Libtool will yell at you if you try to link a shared library against
static ones.

This change creates a libtool archive library for leveldb and allows a
shared library to be linked against it portably.

Also specify -static in both:

- ..._la_CXXFLAGS so that libtool will avoid building two versions of
  each object (one PIC, one non-PIC). We just need the one that is
  suitable for static linking.
- ..._la_LDFLAGS so that libtool will create a static library.

If we don't specify this, then libtool will build two versions of each
object and prefer the non-static PIC version of the object, which is
built with -DDLL_EXPORT -DPIC for mingw-w64 targets. This can cause
symbol resolution problems when we link this library against an
executable that does specify -all-static, since that will be built
without the -DDLL_EXPORT flag.

This is especially important for leveldb and memenv since they link
against libwinpthreads, which has difference symbols depending on
whether DLL_EXPORT is defined or not.

[META] This change is done in preparation for a future commit where we
       link the libbitcoinkernel library against this one.

Appendix:

The specific linker errors when linking memenv built without -all-static
against a bitcoind with -all-static look like:

x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `__gthread_mutex_unlock':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `__gthread_mutex_unlock':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `__gthread_mutex_unlock':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `__gthread_mutex_unlock':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/distsrc-base/distsrc-99874bd94511-x86_64-w64-mingw32/src/leveldb/helpers/memenv/memenv.cc:230: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `__gthread_mutex_unlock':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/distsrc-base/distsrc-99874bd94511-x86_64-w64-mingw32/src/leveldb/helpers/memenv/memenv.cc:230: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `__gthread_mutex_unlock':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `__gthread_mutex_unlock':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `__gthread_mutex_unlock':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `__gthread_mutex_unlock':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/distsrc-base/distsrc-99874bd94511-x86_64-w64-mingw32/src/leveldb/helpers/memenv/memenv.cc:285: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/stl_map.h:501: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:733: undefined reference to `__imp_pthread_mutex_init'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `std::_Vector_base<char*, std::allocator<char*> >::_Vector_impl_data::_Vector_impl_data()':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/stl_vector.h:97: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `std::mutex::lock()':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/std_mutex.h:104: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `leveldb::Status::IOError(leveldb::Slice const&, leveldb::Slice const&)':
/distsrc-base/distsrc-99874bd94511-x86_64-w64-mingw32/src/./leveldb/include/leveldb/status.h:53: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `leveldb::Status::IOError(leveldb::Slice const&, leveldb::Slice const&)':
/distsrc-base/distsrc-99874bd94511-x86_64-w64-mingw32/src/./leveldb/include/leveldb/status.h:53: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `leveldb::Status::IOError(leveldb::Slice const&, leveldb::Slice const&)':
/distsrc-base/distsrc-99874bd94511-x86_64-w64-mingw32/src/./leveldb/include/leveldb/status.h:53: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/stl_map.h:1069: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/stl_tree.h:350: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `leveldb::Status::IOError(leveldb::Slice const&, leveldb::Slice const&)':
/distsrc-base/distsrc-99874bd94511-x86_64-w64-mingw32/src/./leveldb/include/leveldb/status.h:53: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/distsrc-base/distsrc-99874bd94511-x86_64-w64-mingw32/src/./leveldb/include/leveldb/status.h:53: more undefined references to `__imp_pthread_mutex_unlock' follow
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `std::mutex::lock()':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/std_mutex.h:104: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/stl_map.h:1069: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `leveldb::Status::IOError(leveldb::Slice const&, leveldb::Slice const&)':
/distsrc-base/distsrc-99874bd94511-x86_64-w64-mingw32/src/./leveldb/include/leveldb/status.h:53: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:740: undefined reference to `__imp_pthread_mutex_destroy'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `std::mutex::lock()':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/std_mutex.h💯 undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/distsrc-base/distsrc-99874bd94511-x86_64-w64-mingw32/src/leveldb/helpers/memenv/memenv.cc:268: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:733: undefined reference to `__imp_pthread_mutex_init'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `std::_Vector_base<char*, std::allocator<char*> >::_Vector_impl_data::_Vector_impl_data()':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/stl_vector.h:97: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o): in function `std::mutex::lock()':
/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/std_mutex.h:104: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: /gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/bits/std_mutex.h:104: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:733: undefined reference to `__imp_pthread_mutex_init'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:749: undefined reference to `__imp_pthread_mutex_lock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
x86_64-w64-mingw32-ld: leveldb/.libs/libmemenv.a(libmemenv_la-memenv.o):/gnu/store/yn52na8xbgzpiq7fdpm9pfyyf5w3z60m-gcc-cross-x86_64-w64-mingw32-10.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:779: undefined reference to `__imp_pthread_mutex_unlock'
2022-04-26 16:29:35 -04:00
Carl Dong
05d1525b6d build: Create .la library for crc32c
Libtool will yell at you if you try to link a shared library against
static ones.

This change creates a libtool archive library for crc32c and allows a
shared library to be linked against it portably.

Also specify -static in both:

- ..._la_CXXFLAGS so that libtool will avoid building two versions of
  each object (one PIC, one non-PIC). We just need the one that is
  suitable for static linking.
- ..._la_LDFLAGS so that libtool will create a static library.

[META] This change is done in preparation for a future commit where we
       link the libbitcoinkernel library against this one.
2022-04-26 16:25:38 -04:00
fanquake
bd616bc16a
Merge bitcoin/bitcoin#24917: Make BlockManager::LoadBlockIndex private
fa1970f075 Make BlockManager::LoadBlockIndex private (MarcoFalke)

Pull request description:

  * After commit fa27f03b49 `BlockManager::LoadBlockIndex` is only called by `BlockManager::LoadBlockIndexDB`. Thus, it can be made `private`.

  * After commit c600ee3816 `m_best_invalid` is no longer accessed by `BlockManager::LoadBlockIndex`. Thus, the unused `friend` can be removed.

ACKs for top commit:
  mruddy:
    ACK fa1970f075 I verified by double checking references, then applying the patch, and running `make check`. LGTM.

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

Pull request description:

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

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

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

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

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

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

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

Pull request description:

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

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

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

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

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

Tree-SHA512: a4bf7a910cdf464622f2f3b5d44c15b891f24852df6e7f8c5b177fe3d8aaa4a1164593a24c3960eb22b16544fa7140e5c745345367b9e291b78395084c0ac8ff
2022-04-26 19:16:27 +01:00
fanquake
833add0f48
Merge bitcoin/bitcoin#24989: scripted-diff: rename BytePtr to AsBytePtr
bae4561938 scripted-diff: rename BytePtr to AsBytePtr (João Barbosa)

Pull request description:

  Building with iPhoneOS SDK fails because it also has `BytePtr` defined
  in [/usr/include/MacTypes.h](https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/MacTypes.h.auto.html):
  ```cpp
  typedef UInt8 *                         BytePtr;
  ```

ACKs for top commit:
  MarcoFalke:
    cr ACK bae4561938
  laanwj:
    Code review ACK bae4561938
  sipa:
    utACK bae4561938
  prusnak:
    Approach ACK bae4561938

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

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

The motivation for this change is to prevent a GUI bug that happens with
https://github.com/bitcoin/bitcoin/pull/15936, reported in
https://github.com/bitcoin/bitcoin/pull/15936#pullrequestreview-937685759 by
vasild, that happens after a proxy setting is enabled and disabled in the GUI.
But this change also makes sense on its own to remove a potentially confusing
error message.
2022-04-26 10:09:39 -04:00
fanquake
f4005af3ec
Merge bitcoin/bitcoin#24977: rpc: Explain active and internal in listdescriptors
4637bbe448 rpc: Explain active and internal in listdescriptors (Andrew Chow)

Pull request description:

  The current help text for active and internal in listdescriptors is not particularly helpful. They require the reader to already know what those terms mean. This help text is updated to actually explain the definitions of those words in context of a descriptor wallet.

ACKs for top commit:
  S3RK:
    ACK 4637bbe448
  jarolrod:
    ACK 4637bbe448
  w0xlt:
    ACK 4637bbe448

Tree-SHA512: 0af2c04f3b9920799cf616ad618bde9248eb9f74cc28f443b5b0f6646deba76e9b1415aca0865ad3bcc24aa6af0e9d07ad7b7cd80f0fe80838cf847f1b944426
2022-04-26 15:09:39 +01:00
fanquake
cc3877f831
Merge bitcoin/bitcoin#24971: tidy: modernize-use-nullptr
9c96f1008b tidy: enable modernize-use-nullptr (fanquake)
e53274868e Don't use zero as null pointer constant (-Wzero-as-null-pointer-constant) (practicalswift)

Pull request description:

  Alternative to #15112 which uses `clang-tidy` to do perform the checking, rather than `-Wzero-as-null-pointer-constant`, and avoids having to uses pragmas, i.e:
  ```cpp
  #if defined(HAVE_CONFIG_H)
  #include <config/bitcoin-config.h>
  #endif

  #if defined(HAVE_W_ZERO_AS_NULL_POINTER_CONSTANT)
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
  #pragma GCC diagnostic ignored "-Wunknown-pragmas"
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
  #endif
  ```
  to suppress warnings coming from upstream code.

  Can be tested by dropping the preceding commit. Should produce errors like:
  ```bash
  clang-tidy-14 --use-color -p=/home/ubuntu/ci_scratch/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu /home/ubuntu/ci_scratch/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/netbase.cpp
  /home/ubuntu/ci_scratch/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/netbase.cpp:678:36: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
          if (!Socks5(strDest, port, 0, sock)) {
                                     ^
                                     nullptr

  ```

ACKs for top commit:
  laanwj:
    Concept and code review ACK 9c96f1008b

Tree-SHA512: d822a354e44ba8f7fc53da9a4be7de5c25cc4ffc7c57651b76fdd1a030764b0390cfd79fca94685b8a3ff4f4d13054764f12d1f0d8c2a1b9ba519a7524f7f5bf
2022-04-26 14:55:46 +01:00
laanwj
23ebd7a802
Merge bitcoin/bitcoin#24959: Remove not needed clang-format off comments
fa870e3d4c Remove not needed clang-format off comments (MarcoFalke)

Pull request description:

  It seems odd to disable clang-format and force manual formatting when there is no need for it. So remove the clang-format comments and other unneeded comments.

  Can be reviewed with `--word-diff-regex=. --ignore-all-space`

  Looks like this was initially added in commit d9d79576f4 to accommodate a linter that has since been removed and replaced by a functional test.

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

Tree-SHA512: 0f8f97c12f5dbe517dd96c10b10ce1b8772d8daed33e6b41f73ea1040e89888cf3b8c0ad7b20319e366fe30c71e8b181c89098ae7f6a3deb8647e1b4731db815
2022-04-26 15:11:37 +02:00
fanquake
269dcad16e
Merge bitcoin/bitcoin#24789: init, index: disallow indexes when running reindex-chainstate
dac44fc06f init: disallow reindex-chainstate with optional indexes (Martin Zumsande)
62e14285f9 doc: Add note that -reindex will rebuild optional indexes (Martin Zumsande)

Pull request description:

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

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

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

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

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

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

Tree-SHA512: c1abf7d350648ae227c3fd6c95d9a54c3bac9de70915275dea1c87cca6d9a76a056c0e306d95ef8cfe4df1f8525b418e0e7a4f52ded3be464041c0dc297f8930
2022-04-26 12:11:39 +01:00
fanquake
30c1c6ed80
Merge bitcoin/bitcoin#24979: Precomputed hashes are note #16 in BIP341
df08c23f01 Precomputed hashes are note #16 in BIP341 (Gregory Sanders)

Pull request description:

  Seems to have drifted one space

ACKs for top commit:
  fanquake:
    ACK df08c23f01

Tree-SHA512: f0e959743f67ad4b46584f44305d27a89b52874d70091e004ec05dfd2f8c6481e9edceecb0af98f519ad3debb0c0bb26fa27f370545b6e15f366bd0af1158bab
2022-04-26 12:01:20 +01:00
fanquake
9c96f1008b
tidy: enable modernize-use-nullptr 2022-04-26 10:43:33 +01:00
practicalswift
e53274868e
Don't use zero as null pointer constant (-Wzero-as-null-pointer-constant) 2022-04-26 10:41:45 +01:00
dergoegge
778343a379 scripted-diff: Rename PeerManagerImpl members
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); }

ren mapNodeState                              m_node_states
ren cs_most_recent_block                      m_most_recent_block_mutex
ren most_recent_block                         m_most_recent_block
ren most_recent_compact_block                 m_most_recent_compact_block
ren most_recent_block_hash                    m_most_recent_block_hash
ren fWitnessesPresentInMostRecentCompactBlock m_most_recent_compact_block_has_witnesses
ren nPreferredDownload                        m_num_preferred_download_peers
ren nHighestFastAnnounce                       m_highest_fast_announce
-END VERIFY SCRIPT-
2022-04-26 11:12:56 +02:00
dergoegge
91c339243e [net processing] Move nHighestFastAnnounce into PeerManagerImpl 2022-04-26 11:12:05 +02:00
fanquake
f436bfd126
Merge bitcoin/bitcoin#22953: refactor: introduce single-separator split helper (boost::split replacement)
a62e84438d fuzz: add `SplitString` fuzz target (MarcoFalke)
4fad7e46d9 test: add unit tests for `SplitString` helper (Kiminuo)
9cc8e876e4 refactor: introduce single-separator split helper `SplitString` (Sebastian Falbesoner)

Pull request description:

  This PR adds a simple string split helper `SplitString` that takes use of the spanparsing `Split` function that was first introduced in #13697 (commit fe8a7dcd78). This enables to replace most calls to `boost::split`, in the cases where only a single separator character is used. Note that while previous attempts to replace `boost::split` were controversial (e.g. #13751), this one has a trivial implementation: it merely uses an internal helper (that is unit tested and in regular use with output descriptiors) and converts its result from spans to strings. As a drawback though, not all `boost::split` instances can be tackled.

  As a possible optimization, one could return a vector of `std::string_view`s (available since C++17) instead of strings, to avoid copies. This would need more carefulness on the caller sites though, to avoid potential lifetime issues, and it's probably not worth it, considering that none of the places where strings are split are really performance-critical.

ACKs for top commit:
  martinus:
    Code review ACK a62e84438d. Ran all tests. I also like that with `boost::split` it was not obvious that the resulting container was cleared, and with `SplitString` API that's obvious.

Tree-SHA512: 10cb22619ebe46831b1f8e83584a89381a036b54c88701484ac00743e2a62cfe52c9f3ecdbb2d0815e536c99034558277cc263600ec3f3588b291c07eef8ed24
2022-04-26 09:54:49 +01:00
João Barbosa
bae4561938 scripted-diff: rename BytePtr to AsBytePtr
Building with iPhoneOS SDK fails because it also has `BytePtr` defined 
in /usr/include/MacTypes.h.

-BEGIN VERIFY SCRIPT-
sed -i 's/BytePtr/AsBytePtr/' $(git grep -l "BytePtr" src)
-END VERIFY SCRIPT-
2022-04-26 09:41:45 +01:00
laanwj
a19f641a80
Merge bitcoin/bitcoin#24157: p2p: Replace RecursiveMutex cs_totalBytesSent with Mutex and rename it
709af67add p2p: replace RecursiveMutex `m_total_bytes_sent_mutex` with Mutex (w0xlt)
8be75fd0f0 p2p: add assertions and negative TS annotations for `m_total_bytes_sent_mutex` (w0xlt)
a237a065cc scripted-diff: rename cs_totalBytesSent -> m_total_bytes_sent_mutex (w0xlt)

Pull request description:

  Related to #19303, this PR gets rid of the RecursiveMutex `cs_totalBytesSent` and also adds `AssertLockNotHeld` macros combined with `LOCKS_EXCLUDED` thread safety annotations to avoid recursive locking.

ACKs for top commit:
  jonatack:
    ACK 709af67add per `git range-diff 7a4ac71 eff7918 709af67`, rebase to master, clang 15 debug build, and build with -Wthread-safety-negative
  vasild:
    ACK 709af67add
  hebasto:
    ACK 709af67add, tested on Ubuntu 22.04.

Tree-SHA512: 560b4e6c92b1511911d69185207df6ee809db09b96d97f96430d8d2595dc05c98cc691aaec8a58ef87cf2ab0a98675c210b8ce0be3dedb81e31114bbbfdfd8be
2022-04-26 10:21:52 +02:00
Martin Zumsande
2052e3aa9a wallet: ignore chainStateFlushed notifications while attaching chain 2022-04-26 10:12:46 +02:00
MacroFake
fa82a1ed83
lint: Mention NONFATAL_UNREACHABLE in lint-assertions.py 2022-04-26 10:01:54 +02:00
João Barbosa
e3daecae03 scripted-diff: replace deprecated Q_OS_MAC with Q_OS_MACOS
-BEGIN VERIFY SCRIPT-
sed -i 's/Q_OS_MAC/Q_OS_MACOS/' $(git grep -l "Q_OS_MAC" src/qt)
-END VERIFY SCRIPT-
2022-04-26 01:13:29 +01:00
Fabian Jahr
825d19839b
Index: Allow coinstatsindex with pruning enabled 2022-04-25 23:22:00 +02:00
Fabian Jahr
f08c9fb0c6
Index: Use prune locks for blockfilterindex
Prior to this change blocks could be pruned up to the last block before the blockfilterindex current best block.
2022-04-25 23:22:00 +02:00
Fabian Jahr
2561823531
blockstorage: Add prune locks to BlockManager
This change also introduces an aditional buffer of 10 blocks (PRUNE_LOCK_BUFFER) that will not be pruned before the best block.

Co-authored-by: Luke Dashjr <luke-jr+git@utopios.org>
2022-04-25 23:21:58 +02:00
Fabian Jahr
231fc7b035
refactor: Introduce GetFirstStoredBlock helper function 2022-04-25 23:18:01 +02:00
Gregory Sanders
df08c23f01 Precomputed hashes are note #16 in BIP341 2022-04-25 11:58:42 -04:00
Andrew Chow
4637bbe448 rpc: Explain active and internal in listdescriptors
The current help text for active and internal in listdescriptors is not
particularly helpful. They require the reader to already know what those
terms mean. This help text is updated to actually explain the
definitions of those words in context of a descriptor wallet.
2022-04-25 09:48:03 -04:00
dergoegge
e5d1831517 [netgroup] Use nStartByte as offset for the last byte of the group
Should we ever introduce a new address type that makes use of
`nStartByte` and adds fractional bytes to the group, then nStartByte
should be used as the offset for the last byte.
2022-04-25 15:09:14 +02:00
MarcoFalke
fa870e3d4c
Remove not needed clang-format off comments
Can be reviewed with --word-diff-regex=. --ignore-all-space
2022-04-25 10:55:07 +02:00
John Newbery
b8f17fbcb4 [tests] Move TxOrphange tests to orphange_tests.cpp 2022-04-25 08:37:01 +01:00
Martin Zumsande
dac44fc06f init: disallow reindex-chainstate with optional indexes
It currently leads to corruption (coinstatsindex) or
data duplication (blockfilterindex), so disable it.
2022-04-24 22:28:25 +02:00
Martin Leitner-Ankerl
11e7908484
prevector: only allow trivially copyable types
The prevector implementation currently can't be used with types that are
not trivially copyable, due to the use of memmove. Trivially copyable
implies that it is trivially destructible, see
https://eel.is/c++draft/class.prop#1.3

That means that the checks for std::is_trivially_destructible are not
necessary, and in fact where used it wouldn't be enough. E.g. in
`erase(iterator, iterator)` the elements in range first-last are destructed,
but it does not destruct elements left after `memmove`.

This commit removes the checks for `std::is_trivially_destructible`
and instead adds a `static_assert(std::is_trivially_copyable_v<T>);` to
make sure `prevector` is only used with supported types.
2022-04-24 20:02:04 +02:00
MarcoFalke
b1c5991eeb
Merge bitcoin/bitcoin#24812: util/check: Add CHECK_NONFATAL identity function and NONFATAL_UNREACHABLE macro
ee02c8bd9a util/check: Add CHECK_NONFATAL identity function, NONFATAL_UNREACHABLE AND UNREACHABLE macros (Aurèle Oulès)

Pull request description:

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

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

  Also adds `UNREACHABLE_NONFATAL` macro.

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

Tree-SHA512: 3cba09223cd7b22e62fe5d0b46c4a024c1d9957d4268ba6d3fb07fcc0a5854fc0886bb3266184e6a7df5df91373b3e84edd6adf6999c4e934aeef8c043b01aa2
2022-04-24 12:00:05 +02:00
Hennadii Stepanov
15069130c6
qt, test: Add tests for tableView in AddressBookPage dialog 2022-04-23 19:51:39 +02:00
Hennadii Stepanov
edae3ab699
qt: No need to force Qt::QueuedConnection for NotifyAddressBookChanged
This change simplifies tests for `AddressBookPage` class.
No user-faced behavior change.
2022-04-23 15:20:26 +02:00
Hennadii Stepanov
f70ee34c71
qt, refactor: Declare WalletModel member functions with const 2022-04-23 14:30:15 +02:00
KevinMusgrave
7036cf52aa Delete UpdatePackagesForAdded at beginning of addPackageTxs.
As described in commit 9cea7e3715, this is no longer needed because priority transaction selection (addPriorityTxs) was removed in commit 272b25a6a9.
2022-04-22 19:52:15 -04:00
Hennadii Stepanov
be7a5f2fc4
Merge bitcoin-core/gui#587: refactor: Replace GUIUtil::ObjectInvoke() with QMetaObject::invokeMethod()
6958a26aa1 Revert "qt: Add ObjectInvoke template function" (Hennadii Stepanov)
249984f4f9 qt: Replace `GUIUtil::ObjectInvoke()` with `QMetaObject::invokeMethod()` (Hennadii Stepanov)

Pull request description:

  A comment in 5659e73493 states that `GUIUtil::ObjectInvoke`
  > can be replaced by a call to the QMetaObject::invokeMethod functor overload after Qt 5.10

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

Tree-SHA512: 6a840289568113cf38df6c1092821d626c2d206768a21d4dc6846b9dcccb4130477adb45ba718bb6bc15a3041871a7df3238983ac03db80406732be597693266
2022-04-22 18:51:37 +02:00
pasta
ab1ea29ba1 refactor: make GetRand a template, remove GetRandInt 2022-04-22 09:04:39 -05:00
fanquake
505ba39665
Merge bitcoin/bitcoin#22910: net: Encapsulate asmap in NetGroupManager
36f814c0e8 [netgroupman] Remove NetGroupManager::GetAsmap() (John Newbery)
4709fc2019 [netgroupman] Move asmap checksum calculation to NetGroupManager (John Newbery)
1b978a7e8c [netgroupman] Move GetMappedAS() and GetGroup() logic to NetGroupManager (John Newbery)
ddb4101e63 [net] Only use public CNetAddr functions and data in GetMappedAS() and GetGroup() (John Newbery)
6b2268162e [netgroupman] Add GetMappedAS() and GetGroup() (John Newbery)
19431560e3 [net] Move asmap into NetGroupManager (John Newbery)
17c24d4580 [init] Add netgroupman to node.context (John Newbery)
9b3836710b [build] Add netgroup.cpp|h (John Newbery)

Pull request description:

  The asmap data is currently owned by addrman, but is used by both addrman and connman. #22791 made the data const and private (so that it can't be updated by other components), but it is still passed out of addrman as a reference to const, and used by `CNetAddress` to calculate the group and AS of the net address.

  This RFC PR proposes to move all asmap data and logic into a new `NetGroupManager` component. This is initialized at startup, and the client components addrman and connman simply call `NetGroupManager::GetGroup(const CAddress&)` and `NetGroupManager::GetMappedAS(const CAddress&)` to get the net group and AS of an address.

ACKs for top commit:
  mzumsande:
    Code Review ACK 36f814c0e8
  jnewbery:
    CI failure seems spurious. I rebased onto latest master to trigger a new CI run, but whilst I was doing that, mzumsande ACKed 36f814c0e8, so I've reverted to that.
  dergoegge:
    Code review ACK 36f814c0e8

Tree-SHA512: 244a89cdfd720d8cce679eae5b7951e1b46b37835fccb6bdfa362856761bb110e79e263a6eeee8246140890f3bee2850e9baa7bc14a388a588e0e29b9d275175
2022-04-22 14:43:14 +01:00
akankshakashyap
3f8def51d5 add 3 new test cases for SelectCoins()
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.
2022-04-22 14:49:49 +05:30
w0xlt
709af67add p2p: replace RecursiveMutex m_total_bytes_sent_mutex with Mutex 2022-04-22 05:40:24 -03:00
w0xlt
8be75fd0f0 p2p: add assertions and negative TS annotations for m_total_bytes_sent_mutex
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2022-04-22 05:40:24 -03:00
Ryan Ofsky
f64aa9c411 Disallow more unsafe string->path conversions allowed by path append operators
Add more fs::path operator/ and operator+ overloads to prevent unsafe
string->path conversions on Windows that would cause strings to be
decoded according to the current Windows locale & code page instead of
the correct string encoding.

Update application code to deal with loss of implicit string->path
conversions by calling fs::u8path or fs::PathFromString explicitly, or
by just changing variable types from std::string to fs::path to avoid
conversions altoghther, or make them happen earlier.

In all cases, there's no change in behavior either (1) because strings
only contained ASCII characters and would be decoded the same regardless
of what encoding was used, or (2) because of the 1:1 mapping between
paths and strings using the PathToString and PathFromString functions.

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2022-04-21 12:01:00 -05:00
laanwj
173c796268
Merge bitcoin/bitcoin#24854: Remove not needed ArithToUint256 roundtrips in tests
fad6d4f952 Remove not needed ArithToUint256 roundtrips in tests (MarcoFalke)
fa456ccb22 Remove duplicate static_asserts (MarcoFalke)

Pull request description:

  No need to go from `arith_uint256`->`uint256` when a `uint256` can be constructed right away.

ACKs for top commit:
  laanwj:
    Code review ACK fad6d4f952

Tree-SHA512: bea901ea5904bf61a0dadf7168c6b126f7e62ff1180d4aa72063c28930a01a8baa57ab0d324226bd4de72fb59559455c29c049d90061f888044198aae1426dcb
2022-04-21 18:05:47 +02:00
laanwj
43bb106613
Merge bitcoin/bitcoin#24213: refactor: use Span in random.*
3ae7791bca refactor: use Span in random.* (pasta)

Pull request description:

  ~This PR does two things~
  1. use a Span<unsigned char> for GetRandBytes and GetStrongRandBytes

  ~2. make GetRand a template for which any integral type can be used, where the default behavior is to return a random integral up to the max of the integral unless a max is provided.
  This simplifies a lot of code from `GetRand(std::numeric_limits<uint64_t>::max()` -> `GetRand<uint64_t>()`~

  MarcoFalke this was inspired by your comment here: https://github.com/bitcoin/bitcoin/pull/24185#issuecomment-1025514263 about using Span, so hopefully I'll be able to get this PR done and merged 😂

  ~Also, if requested I could revert the `GetRand(std::numeric_limits<uint64_t>::max()` -> `GetRand<uint64_t>()` related changes if it ends up causing too many conflicts~

ACKs for top commit:
  laanwj:
    Thank you! Code review re-ACK 3ae7791bca

Tree-SHA512: 12375a83b68b288916ba0de81cfcab4aac14389a66a36811ae850427435eb67dd55e47df9ac3ec47db4e214f4330139e548bec815fff8a3f571484ea558dca79
2022-04-21 16:38:04 +02:00
Hennadii Stepanov
ab73d5985d
Do not pass WalletModel* to queued connection
Passing a `WalletModel*` object to a queued connection when the
`ENABLE_WALLET` macro is undefined make code flawed.
2022-04-21 14:04:56 +02:00
Hennadii Stepanov
fdf7285950
refactor: Make RPCExecutor* a member of the RPCConsole class 2022-04-21 13:35:59 +02:00
Hennadii Stepanov
61457c179a
refactor: Guard RPCConsole::{add,remove}Wallet() with ENABLE_WALLET 2022-04-20 16:57:47 +02:00
John Newbery
36f814c0e8 [netgroupman] Remove NetGroupManager::GetAsmap()
asmap no longer needs to be exposed anywhere outside NetGroupManager.
2022-04-20 14:35:53 +01:00
John Newbery
4709fc2019 [netgroupman] Move asmap checksum calculation to NetGroupManager 2022-04-20 14:35:53 +01:00
John Newbery
1b978a7e8c [netgroupman] Move GetMappedAS() and GetGroup() logic to NetGroupManager
Reviewer hint: use:

`git diff --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space`
2022-04-20 14:35:52 +01:00
John Newbery
ddb4101e63 [net] Only use public CNetAddr functions and data in GetMappedAS() and GetGroup()
Also change parameter/variable names. This makes the next commit mostly
move-only.
2022-04-20 14:35:52 +01:00
John Newbery
6b2268162e [netgroupman] Add GetMappedAS() and GetGroup()
These currently call through to the CNetAddr methods. The logic will be moved in a future commit.
2022-04-20 14:35:52 +01:00
John Newbery
19431560e3 [net] Move asmap into NetGroupManager 2022-04-20 14:29:29 +01:00