Commit graph

33982 commits

Author SHA1 Message Date
Carl Dong
faa52387e8 style-only: Rearrange using decls after scripted-diff 2022-05-23 14:53:35 -04:00
Carl Dong
f329a9298c scripted-diff: Move src/kernel/coinstats to kernel::
Introduces a new kernel:: namespace and move all of src/kernel/coinstats
under it.

In the verify script, lines like:

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

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

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

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

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

things='(CCoinsStats|CoinStatsHashType|GetBogoSize|TxOutSer|ComputeUTXOStats)'
git grep -lE 'node::'"$things" | xargs sed -E -i 's@node::'"$things"'@kernel::\1@g'
sed -E -i 's@'"$things"'@kernel::\1@g' -- src/node/coinstats.cpp src/node/coinstats.h
sed -E -i 's@BlockManager@node::\0@g' -- src/kernel/coinstats.cpp
-END VERIFY SCRIPT-
2022-05-23 14:53:35 -04:00
Carl Dong
0e54456f04 Use only kernel/coinstats.h in index/coinstatsindex.h
Removes a circular dependency, horray!
2022-05-23 14:53:35 -04:00
Carl Dong
80970985c9 coinstats: Split node/coinstats.h to kernel/coinstats.h
Most of this commit is pure-move.

After this change:

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

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

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

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

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

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

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

In rpc/blockchain.cpp, we discover that GetUTXOStats' status bool when
getting UTXO stats for pprev was not checked for error. We fix this as
well.
2022-05-23 14:50:35 -04:00
Carl Dong
46eb9fc56a coinstats: Extract index_requested in-member to in-param
This change removes CCoinsStats' index_requested in-param member and
adds it to the relevant functions instead.
2022-05-20 16:33:24 -04:00
Carl Dong
a789f3f2b8 coinstats: Extract hash_type in-member to in-param
Currently, CCoinsStats is a struct with both in-params and out-params
where the hash_type and index_requested members are the only in-params.

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

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

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

There is no point to fuzzing this deterministic logic.

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

Pull request description:

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

  This is important for libbitcoinkernel as:

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

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

Top commit has no ACKs.

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

Pull request description:

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

  See details in the commit messages.

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

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

Pull request description:

  Three new tests have been added.

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

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

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

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

This is important for libbitcoinkernel as:

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

See the src/Makefile.am changes for some satisfying removals.
2022-05-20 11:57:51 -04:00
Carl Dong
dbe45c34f8 Add ChainstateManagerOpts, using as ::Options
[META] Although it seems like we don't need it for just one option,
       we're going to introduce another member to this struct *in the
       next commit*. In future patchsets for libbitcoinkernel decoupling
       it from ArgsManager, even more members will be added here.
2022-05-20 11:54:18 -04:00
MacroFake
4d0c00dffd
Merge bitcoin/bitcoin#25168: refactor: Avoid passing params where not needed
fa1b76aeb0 Do not call global Params() when chainman is in scope (MacroFake)
fa30234be8 Do not pass CChainParams& to PeerManager::make (MacroFake)
fafe5c0ca2 Do not pass CChainParams& to BlockAssembler constructor (MacroFake)
faf012b438 Do not pass Consensus::Params& to Chainstate helpers (MacroFake)
fa4ee53dca Do not pass time getter to Chainstate helpers (MacroFake)

Pull request description:

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

  Fix this by:

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

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

Tree-SHA512: 1abff5cba4b4871d97f17dbcdf67bc9255ff21fa4150a79a74e39b28f0610eab3e7dee24d56872dd6e111f003b55e288958cdd467e6218368d896f191e4ec9cd
2022-05-20 13:35:15 +01:00
Hennadii Stepanov
2b3373c152
refactor: Propagate negative !m_tx_relay_mutex capability
Could be verified with
$ ./configure CC=clang CXX=clang++ CXXFLAGS='-Wthread-safety -Wthread-safety-negative'
$ make clean
$ make 2>&1 | grep m_tx_relay_mutex
2022-05-20 13:31:08 +02:00
Hennadii Stepanov
5a6e3c1db3
refactor: Propagate negative !m_most_recent_block_mutex capability
Could be verified with
$ ./configure CC=clang CXX=clang++ CXXFLAGS='-Wthread-safety -Wthread-safety-negative'
$ make clean
$ make 2>&1 | grep m_most_recent_block_mutex
2022-05-20 13:25:45 +02:00
Hennadii Stepanov
8c61374ba7
Merge bitcoin-core/gui#581: refactor: Revamp ClientModel code to handle core signals
bcbf982553 qt, doc: Remove unneeded comments (Hennadii Stepanov)
9bd1565f65 qt: Revamp ClientModel code to handle {Block|Header}Tip core signals (Hennadii Stepanov)
48f6d39659 qt: Revamp ClientModel code to handle BannedListChanged core signal (Hennadii Stepanov)
36b12af7ee qt: Revamp ClientModel code to handle AlertChanged core signal (Hennadii Stepanov)
bfe5140c50 qt: Revamp ClientModel code to handle NetworkActiveChanged core signal (Hennadii Stepanov)
639563d7fe qt: Revamp ClientModel code to handle NumConnectionsChanged core signal (Hennadii Stepanov)
508e2dca5e qt: Revamp ClientModel code to handle ShowProgress core signal (Hennadii Stepanov)

Pull request description:

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

  Additionally, debug messages have been unified.

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

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

Pull request description:

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

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

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

Pull request description:

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

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

Tree-SHA512: e2329fbdea2e580bd1618caab31f5d0e59c245a028e1236662858e621929818870b76ab6834f7ac6a46d7874dfec63f498380ad99da6efe4218f720a60e859be
2022-05-20 10:47:30 +02:00
MacroFake
a7e3afb221
Merge bitcoin/bitcoin#25171: rpc: wallet: remove -deprecatedrpc=exclude_coinbase logic
a4703ce9d7 doc: add release notes about removal of the `deprecatedrpc=exclude_coinbase` (Sebastian Falbesoner)
ef0aa74836 rpc: wallet: remove `-deprecatedrpc=exclude_coinbase` logic (Sebastian Falbesoner)

Pull request description:

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

ACKs for top commit:
  fanquake:
    ACK a4703ce9d7

Tree-SHA512: 97cd4e78501e64f678c78d2ebb5be5376688c023e34fced71dd24e432d27aa31a74b5483545f49ba0bdf48656d8b8b7bee74e3db26cf6daf112613f1caa4dfa4
2022-05-20 08:48:09 +01:00
fanquake
a39002e0c6
Merge bitcoin/bitcoin#25170: build: Enable RPC_DOC_CHECK on --enable-debug
fafae678f6 build: Enable RPC_DOC_CHECK on --enable-debug (MacroFake)

Pull request description:

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

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

ACKs for top commit:
  vincenzopalazzo:
    utACK fafae678f6

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

Pull request description:

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

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

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

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

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

Pull request description:

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

ACKs for top commit:
  MarcoFalke:
    rACK 055d94d1ab

Tree-SHA512: 01bbb297afff371f6345889fa04117ff195b68f0bbf934878ba446049791fdbd7d2ce119ee4f9b3616cc0a81330d7055507dc81151acf68532c077f3575258e9
2022-05-20 08:18:02 +01:00
fanquake
6407c0e8a3
Merge bitcoin/bitcoin#25101: Add mockable clock type
fa305fd92c Add mockable clock type and TicksSinceEpoch helper (MarcoFalke)

Pull request description:

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

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

Tree-SHA512: da00200126833c1f55b1b1e68f596eab5c9254e82b188ad17779c08ffd685e198a7c5270791b4b69a858dc6ba4e051fe0c8b445d203d356d0c884f6365ee1cfe
2022-05-20 07:48:07 +01:00
brunoerg
055d94d1ab test: add coverage for unknown network in -onlynet 2022-05-19 18:39:23 -03:00
fanquake
0de36941ec
Merge bitcoin/bitcoin#25153: scripted-diff: Use getInt<T> over get_int/get_int64
fa9af21878 scripted-diff: Use getInt<T> over get_int/get_int64 (MacroFake)

Pull request description:

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

ACKs for top commit:
  fanquake:
    ACK fa9af21878

Tree-SHA512: 284aa2527d0f663ca01550115025c9c64c787531d595f866c718f6ad09b9b0cac1e683a7d77f8009b75de990fd37166b44063ffa83fba8a04e9a31600b4c2725
2022-05-19 16:32:56 +01:00
Sebastian Falbesoner
a4703ce9d7 doc: add release notes about removal of the deprecatedrpc=exclude_coinbase 2022-05-19 16:42:50 +02:00
Sebastian Falbesoner
ef0aa74836 rpc: wallet: remove -deprecatedrpc=exclude_coinbase logic 2022-05-19 16:10:59 +02:00
fanquake
e18fd4763e
Merge bitcoin/bitcoin#25074: index: During sync, commit best block after indexing
7171ebc7cb index: Don't commit a best block before indexing it during sync (Martin Zumsande)

Pull request description:

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

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

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

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

Co-authored-by: Luke Dashjr <luke-jr+git@utopios.org>
2022-05-19 13:20:55 +02:00
fanquake
345d860f38
Merge bitcoin/bitcoin#25166: doc: Add link to NetBSD release
174f58c185 Add link to NetBSD release (Marnix)

Pull request description:

  For consistency with other Build Guides, like `doc/build-freebsd.md` & `doc/build-openbsd.md`

ACKs for top commit:
  theStack:
    Code-review ACK 174f58c185
  vincenzopalazzo:
    ACK 174f58c185

Tree-SHA512: 08297aac82ee8fab2bbcb486b13b9c6ca12fb4fba573e9979e94204bd7340c2d13f1e54e07b314498603c291c25e29f2e89141ee150478951f699772538b709c
2022-05-19 09:59:32 +01:00
fanquake
fdb82a30be
Merge bitcoin/bitcoin#25147: Net processing: follow ups to #20799 (removing support for v1 compact blocks)
bf6526f4a0 [test] Remove segwit argument from build_block_on_tip() (John Newbery)
c65bf50b44 Remove fUseWTXID parameter from CBlockHeaderAndShortTxIDs constructor (John Newbery)

Pull request description:

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

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

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

Tree-SHA512: d553791d1364b9e655183755e829b195c9b47f59c62371dbae49d9c0f8d84fec58cf18f4dde89591672ef5658e18c9cf0206c2efd70606980f87e506bc3bd4e5
2022-05-19 09:37:32 +01:00
fanquake
986bae8e72
Merge bitcoin/bitcoin#22778: net processing: Reduce resource usage for inbound block-relay-only connections
9db82f1bca [net processing] Don't initialize TxRelay for non-tx-relay peers. (John Newbery)
b0a4ac9c26 [net processing] Add m_tx_relay_mutex to protect m_tx_relay ptr (John Newbery)
290a8dab02 [net processing] Comment all TxRelay members (John Newbery)
42e3250497 [net processing] [refactor] Move m_next_send_feefilter and m_fee_filter_sent (John Newbery)

Pull request description:

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

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

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

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

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

Tree-SHA512: 83a449a56cd6bf6ad05369f5ab91516e51b8c471c07ae38c886d51461e942d492ca34ae63d329c46e56d96d0baf59a3e34233e4289868f911db3b567072bdc41
2022-05-19 09:27:24 +01:00
MacroFake
fafae678f6
build: Enable RPC_DOC_CHECK on --enable-debug 2022-05-19 07:54:57 +02:00
MacroFake
bb83aba6c9
Merge bitcoin/bitcoin#25161: rpc: Put undocumented JSON failure mode behind a runtime flag
b953ea6cc6 rpc: Put undocumented JSON failure mode behind a runtime flag (Suhail Saqan)

Pull request description:

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

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

Tree-SHA512: 2005ee1b1f3b637918390b2ecd4166f2fd8c86e3c59fba3da8a0cbd5b1dffd03190c92f6dca3c489ecce4276eaf3108b2edcf9cd6224b713adb52f5bb848163b
2022-05-19 06:44:55 +02:00
Suhail Saqan
b953ea6cc6 rpc: Put undocumented JSON failure mode behind a runtime flag
rpc: Put undocumented JSON failure mode behind a runtime flag
2022-05-18 10:50:59 -07:00
MacroFake
7b3343f300
Merge bitcoin/bitcoin#25108: tidy: add modernize-use-default-member-init
ac6fbf2c83 tidy: use modernize-use-default-member-init (fanquake)
7aa40f5563 refactor: use C++11 default initializers (fanquake)

Pull request description:

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

Top commit has no ACKs.

Tree-SHA512: 536b406f20639f8c588fe9e96175ec60c7bb825506b2670b562370b2f572801c24203c483443be3c199e1b958c0765d4532e57c57a4e78689162a1dd422d844f
2022-05-18 19:19:55 +02:00
MacroFake
fa9af21878
scripted-diff: Use getInt<T> over get_int/get_int64
-BEGIN VERIFY SCRIPT-
 sed -i 's|\<get_int64\>|getInt<int64_t>|g' $(git grep -l get_int ':(exclude)src/univalue')
 sed -i 's|\<get_int\>|getInt<int>|g'       $(git grep -l get_int ':(exclude)src/univalue')
-END VERIFY SCRIPT-
2022-05-18 19:15:03 +02:00
MacroFake
e016c00e98
Merge bitcoin/bitcoin#25126: test: add BIP157 message parsing support (via MESSAGEMAP)
5dc6d92077 test: make BIP157 messages default-constructible (MESSAGEMAP compatibility) (Sebastian Falbesoner)
71e4cfefe7 test: p2p: add missing BIP157 message types to MESSAGEMAP (Sebastian Falbesoner)

Pull request description:

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

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

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

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

Tree-SHA512: d656c4d38a856373f01d7c293ae7d2b27378a9fc248048ebf2a64725ef8b498b3ddf4f420704abdb20d0c68ca548f1777602c5e73b66821a20c97ae618f1d63f
2022-05-18 19:08:48 +02:00
MarcoFalke
fa305fd92c
Add mockable clock type and TicksSinceEpoch helper 2022-05-18 18:58:05 +02:00
MacroFake
fa1b76aeb0
Do not call global Params() when chainman is in scope 2022-05-18 18:46:48 +02:00
MacroFake
fa30234be8
Do not pass CChainParams& to PeerManager::make 2022-05-18 18:46:27 +02:00
MacroFake
fafe5c0ca2
Do not pass CChainParams& to BlockAssembler constructor 2022-05-18 18:46:07 +02:00
MacroFake
faf012b438
Do not pass Consensus::Params& to Chainstate helpers 2022-05-18 18:45:30 +02:00