Commit graph

17941 commits

Author SHA1 Message Date
John Newbery
06fa85cd50 [net] InactivityCheck() takes a CNode reference 2021-01-13 16:18:12 +00:00
Wladimir J. van der Laan
e7eb37128c
Merge #20913: doc: Add manual page generation for bitcoin-util
bc99ae77e4 scripted-diff: Fix typo in stub manual pages (Wladimir J. van der Laan)
b5e93f873a doc: Add manual page generation for bitcoin-util (Wladimir J. van der Laan)

Pull request description:

  - Add `-version` option to `bitcoin-util`
  - Add `bitcoin-util` call to `gen-manpages.sh`
  - Add stub manual page `bitcoin-util.1`
  - Add install of `bitcoin-util.1` to build system

ACKs for top commit:
  fanquake:
    ACK bc99ae77e4

Tree-SHA512: 948df66c62bbca1cf6da26845dfa63f8f5d036a3d5744add468dd1ce7f442c123d7b0db7011c2e8e3ee6539fd391c7ee2c21b706ec81b21b02821c9501cd077d
2021-01-13 10:16:09 +01:00
Wladimir J. van der Laan
60427ee35f
Merge #20811: refactor: move net_processing implementation details out of header
c97f70c861 net_processing: move Peer definition to .cpp (Anthony Towns)
e0f2e6d2df net_processing: move PeerManagerImpl into cpp file (Anthony Towns)
a568b82feb net_processing: split PeerManager into interface and implementation classes (Anthony Towns)
0df3d3fd6b net_processing: make more of PeerManager private (Anthony Towns)
0d246a59b6 net, net_processing: move NetEventsInterface method docs to net.h (Anthony Towns)

Pull request description:

  Moves the implementation details of `PeerManager` and all of `struct Peer` into net_processing.cpp.

ACKs for top commit:
  jnewbery:
    ACK c97f70c861
  Sjors:
    ACK c97f70c861
  laanwj:
    Code review ACK c97f70c861
  vasild:
    ACK c97f70c861

Tree-SHA512: 2e081e491d981c61bd78436a6a6c2eb41d3c2d86a1a8ef9d4d6f801b82cb64a8bf707a96db3429418d1704cffb60a657d1037a0336cbc8173fb79aef9eb72001
2021-01-13 09:48:06 +01:00
Wladimir J. van der Laan
8ffaf5c2f5
Merge #19935: Move SaltedHashers to separate file and add some new ones
281fd1a4a0 Replace KeyIDHasher with SaltedSipHasher (Andrew Chow)
210b693db6 Add generic SaltedSipHasher (Andrew Chow)
95e61c1cf2 Move Hashers to util/hasher.{cpp/h} (Andrew Chow)

Pull request description:

  There are existing `SaltedOutPointHasher` and `SaltedTxidHasher` classes used for `std::unordered_map` and `std::unordered_set` that could be useful in other places in the codebase. So we these to their own `saltedhash.{cpp/h}` file. An existing `KeyIDHasher` is moved there too. Additionally, `ScriptIDHasher`, `SaltedPubkeyHasher`, and `SaltedScriptHasher` are added so that they can be used in future work.

  `KeyIDHasher` and `ScriptIDHasher` are not salted so that equality comparisons of maps and sets keyed by `CKeyID` and `CScriptID` will actually work.

  Split from #19602 (and a few other PRs/branches I have).

ACKs for top commit:
  laanwj:
    Code review ACK 281fd1a4a0
  jonatack:
    ACK 281fd1a4a0, code review, debug build and ran bitcoind after rebasing to master @ dff0f6f753
  fjahr:
    utACK 281fd1a4a0

Tree-SHA512: bb03b231ccf3c9ecefc997b8da9c3770af4819f9be5b0a72997a103864e84046a2ac39b8eadf0dc9247bdccd53f86f433642e3a098882e6748341a9e7736271b
2021-01-13 08:49:17 +01:00
MarcoFalke
fa0a864b38
fuzz: Use mocktime in process_message* fuzz targets 2021-01-13 07:48:41 +01:00
sinetek
2a39ccf133 Add include for std::bind. 2021-01-13 02:05:00 +01:00
MarcoFalke
fa0aa87071
rpc: Return wtxid from testmempoolaccept 2021-01-12 18:43:43 +01:00
Sebastian Falbesoner
fc726e0138 doc, rpc: add missing signet mentions in network name lists 2021-01-12 18:43:31 +01:00
Wladimir J. van der Laan
b5e93f873a doc: Add manual page generation for bitcoin-util
- Add `-version` option to `bitcoin-util`
- Add `bitcoin-util` call to `gen-manpages.sh`
- Add stub manual page `bitcoin-util.1`
- Add install of `bitcoin-util.1` to build system
2021-01-12 14:09:21 +01:00
Wladimir J. van der Laan
7b975639ef
Merge #19937: signet mining utility
595a34dbea contrib/signet: Document miner script in README.md (Anthony Towns)
ff7dbdc08a contrib/signet: Add script for generating a signet chain (Anthony Towns)
13762bcc96 Add bitcoin-util command line utility (Anthony Towns)
95d5d5e625 rpc: allow getblocktemplate for test chains when unconnected or in IBD (Anthony Towns)
81c54dec20 rpc: update getblocktemplate with signet rule, include signet_challenge (Anthony Towns)

Pull request description:

  Adds `contrib/signet/miner` for mining signet blocks.

  Adds `bitcoin-util` cli utility, with the idea being it can provide bitcoin related functionality that does not rely on the ability to access a running node. Only subcommand currently is "grind" which takes a hex-encoded header and grinds its nonce until its nBits is satisfied.

  Updates `getblocktemplate` to include `signet_challenge` field, and makes `getblocktemplate` require the signet rule when invoked on the signet change. Removes connectivity and IBD checks from `getblocktemplate` when applied to a test chain (regtest, testnet, signet).

ACKs for top commit:
  laanwj:
    code review ACK 595a34dbea

Tree-SHA512: 8d43297710fdc1edc58acd9b53e1bd1671e5724f7097b40ab73653715dc8becc70534c4496cbba9290f4dd6538a7a3d5830eb85f83391ea31a3bb5b9d3378cc3
2021-01-12 12:53:45 +01:00
gzhao408
2f463f57e3 [doc] for CheckInputsFromMempoolAndCache 2021-01-12 02:27:09 -08:00
gzhao408
85cc6bed64 lock annotations for MemPoolAccept functions
We should already have the mempool lock when entering
CheckInputsFromMempoolAndCache
2021-01-12 02:27:09 -08:00
Anthony Towns
13762bcc96 Add bitcoin-util command line utility 2021-01-12 18:34:25 +10:00
fanquake
7838db141b
Merge #20495: sync: Use decltype(auto) return type for WITH_LOCK
3eb94ec81b sync: Use decltype(auto) return type for WITH_LOCK (Carl Dong)

Pull request description:

  > Now that we're using C++17, we can use the decltype(auto) return type
  > for functions and lambda expressions.
  >
  > As demonstrated in this commit, this can simplify cases where previously
  > the compiler failed to deduce the correct return type.
  >
  > Just for reference, for the "assign to ref" cases fixed here, there are
  > 3 possible solutions:
  >
  > - Return a pointer and immediately deref as used before this commit
  > - Make sure the function/lambda returns declspec(auto) as used after
  >   this commit
  > - Class& i = WITH_LOCK(..., return std::ref(...));
  >
  > -----
  >
  > References:
  > 1. https://en.cppreference.com/w/cpp/language/function#Return_type_deduction
  > 2. https://en.cppreference.com/w/cpp/language/template_argument_deduction#Other_contexts
  > 3. https://en.cppreference.com/w/cpp/language/auto
  > 4. https://en.cppreference.com/w/cpp/language/decltype
  >
  > Explanations:
  > 1. https://stackoverflow.com/a/21369192
  > 2. https://stackoverflow.com/a/21369170

  Thanks to sipa and ryanofsky for helping me understand this

ACKs for top commit:
  jnewbery:
    utACK 3eb94ec81b
  hebasto:
    ACK 3eb94ec81b, I have reviewed the code and it looks OK, I agree it can be merged. I have verified possible warnings:
  ryanofsky:
    Code review ACK 3eb94ec81b

Tree-SHA512: 5f55c7722aeca8ea70e5c1a8db93e93ba0e356e8967e7f607ada38003df4b153d73c29bd2cea8d7ec1344720d37d857ea7dbfd2a88da1d92e0e9cbb9abd287df
2021-01-12 15:56:19 +08:00
MarcoFalke
6af013792f
Merge #19315: [tests] Allow outbound & block-relay-only connections in functional tests.
b4dd2ef800 [test] Test the add_outbound_p2p_connection functionality (Amiti Uttarwar)
602e69e427 [test] P2PBlocksOnly - Test block-relay-only connections. (Amiti Uttarwar)
8bb6beacb1 [test/refactor] P2PBlocksOnly - Extract transaction violation test into helper. (Amiti Uttarwar)
99791e7560 [test/refactor] P2PBlocksOnly - simplify transaction creation using blocktool helper. (Amiti Uttarwar)
3997ab9154 [test] Add test framework support to create outbound connections. (Amiti Uttarwar)
5bc04e8837 [rpc/net] Introduce addconnection to test outbounds & blockrelay (Amiti Uttarwar)

Pull request description:

  The existing functional test framework uses the `addnode` RPC to spin up manual connections between bitcoind nodes. This limits our ability to add integration tests for our networking code, which often executes different code paths for different connection types.

  **This PR enables creating `outbound` & `block-relay-only` P2P connections in the functional tests.** This allows us to increase our p2p test coverage, since we can now verify expectations around these connection types.

  This builds out the [prototype](https://github.com/bitcoin/bitcoin/issues/14210#issuecomment-527421978) proposed by ajtowns in #14210. 🙌🏽

  An overview of this branch:
  - introduces a new test-only RPC function `addconnection` which initiates opening an `outbound` or `block-relay-only` connection. (conceptually similar to `addnode` but for different connection types & restricted to regtest)
  - adds `test_framework` support so a mininode can open an `outbound`/`block-relay-only` connection to a `P2PInterface`/`P2PConnection`.
  - updates `p2p_blocksonly` tests to create a `block-relay-only` connection & verify expectations around transaction relay.
  - introduces `p2p_add_connections` test that checks the behaviors of the newly introduced `add_outbound_p2p_connection` test framework function.

  With these changes, there are many more behaviors that we can add integration tests for. The blocksonly updates is just one example.

  Huge props to ajtowns for conceiving the approach & providing me feedback as I've built out this branch. Also thank you to jnewbery for lots of thoughtful input along the way.

ACKs for top commit:
  troygiorshev:
    reACK b4dd2ef800
  jnewbery:
    utACK b4dd2ef800
  MarcoFalke:
    Approach ACK b4dd2ef800 🍢

Tree-SHA512: d1cba768c19c9c80e6a38b1c340cc86a90701b14772c4a0791c458f9097f6a4574b4a4acc7d13d6790c7b1f1f197e2c3d87996270f177402145f084ef8519a6b
2021-01-11 21:06:57 +01:00
fanquake
6d81d7aa87
Merge #20787: Use C++17 std::array deduction for OUTPUT_TYPES, ALL_FEE_ESTIMATE_HORIZONS
aaaa987840 refactor: Use C++17 std::array deduction for ALL_FEE_ESTIMATE_HORIZONS (MarcoFalke)
fa39cdd072 refactor: Use C++17 std::array deduction for OUTPUT_TYPES (MarcoFalke)

Pull request description:

  With the new C++17 array deduction rules, an array encompassing all values in an enum can be specified in the same header file that specifies the enum. This is useful to avoid having to repeatedly enumerate all enum values in the code. E.g. the RPC code, but also the fuzz code.

ACKs for top commit:
  theStack:
    cr ACK aaaa987840 ⚙️
  fanquake:
    ACK aaaa987840

Tree-SHA512: b71bd98f3ca07ddfec385735538ce89a4952e418b52dc990fb160187ccef1fc7ebc139d42988b6f7b48df24823af61f803b83d47fb7a3b82475f0c0b109bffb7
2021-01-11 21:46:09 +08:00
MarcoFalke
5cce607105
Merge #20373: refactor, net: Increase CNode data member encapsulation
3642b2ed34 refactor, net: Increase CNode data member encapsulation (Hennadii Stepanov)
acebb79d3f refactor, move-only: Relocate CNode private members (Hennadii Stepanov)

Pull request description:

  All protected `CNode` data members could be private.

ACKs for top commit:
  jnewbery:
    utACK 3642b2ed34
  MarcoFalke:
    review ACK 3642b2ed34 🏛

Tree-SHA512: 8435e3c43c3b7a3107d58cb809b8b5e1a1c0068677e249bdf0fc6ed24140ac4fc4efe2a280a1ee86df180d738c0c9e10772308690607954db6713000cf6e728d
2021-01-11 13:19:43 +01:00
Wladimir J. van der Laan
675af2a515
Merge #20852: net: allow CSubNet of non-IP networks
39b43298d9 test: add test for banning of non-IP addresses (Vasil Dimov)
94d335da7f net: allow CSubNet of non-IP networks (Vasil Dimov)

Pull request description:

  Allow creation of valid `CSubNet` objects of non-IP networks and only
  match the single address they were created from (like /32 for IPv4 or
  /128 for IPv6).

  This fixes a deficiency in `CConnman::DisconnectNode(const CNetAddr& addr)`
  and in `BanMan` which assume that creating a subnet from any address
  using the `CSubNet(CNetAddr)` constructor would later match that address
  only. Before this change a non-IP subnet would be invalid and would not
  match any address.

ACKs for top commit:
  jonatack:
    Code review re-ACK 39b43298d9 per `git diff 5e95ce6 39b4329`; only change since last review is improvements to the functional test; verified the test fails on master @ 616eace0 where expected (`assert(self.is_banned(node, tor_addr))` fails and unban unfails)
  laanwj:
    code review ACK 39b43298d9

Tree-SHA512: 3239b26d0f2fa2d1388b4fdbc1d05ce4ac1980be699c6ec46049409baefcb2006b1e72b889871e2210e897f6725c48e873f68457eea7e6e4958ab4f959d20297
2021-01-11 11:27:47 +01:00
MarcoFalke
fa75d40ef8
fuzz: Introduce CallOneOf helper to replace switch-case
Can be reviewed with --ignore-all-space
2021-01-11 10:37:16 +01:00
Jonas Schnelli
616eace02a
Merge bitcoin-core/gui#161: Add PeerTableModel::StatsRole to prevent data layer violation
b3e9bcaac8 qt, refactor: Drop no longer used PeerTableModel::getNodeStats function (Hennadii Stepanov)
49c604077c qt: Use PeerTableModel::StatsRole (Hennadii Stepanov)
35007edf9c qt: Add PeerTableModel::StatsRole (Hennadii Stepanov)

Pull request description:

  This PR allows to access to the `CNodeCombinedStats` instance directly from any view object.

  The `PeerTableModel::getNodeStats` member function removed as a kind of layer violation.

  No behavior changes.

  Also other pulls (bugfixes) are based on this one: #18 and #164.

ACKs for top commit:
  jonatack:
    Tested re-ACK b3e9bcaac8 per `git range-diff ae8f797 4c05fe0 b3e9bca`
  promag:
    Code review ACK b3e9bcaac8.
  jonasschnelli:
    utACK b3e9bcaac8

Tree-SHA512: 6ba50d5dd2c0373655d491ce8b130c47d598da2db5ff4b00633f447404c7e70f8562ead53ddf166e851384d9632ff9146a770c99845c2cdd3ff7250677e4c130
2021-01-11 09:06:21 +01:00
fanquake
bd6af53e1f
Merge #20480: Replace boost::variant with std::variant
faa8f68943 Replace boost::variant with std::variant (MarcoFalke)

Pull request description:

  Now that we can use std::variant from the vanilla standard library, drop the third-party boost variant dependency

ACKs for top commit:
  fjahr:
    Code review ACK faa8f68943
  fanquake:
    ACK faa8f68943

Tree-SHA512: 6e3aecd33b00c2e31a763f999247944d5b2ce5e3018f1965c516c1000cd08ff6703a8d50fb0be64883153da2925ae72986b8a6b96586db74057bd05d6f4986e6
2021-01-11 12:05:46 +08:00
fanquake
c4458cc3a1
Merge #18819: net: Replace cs_feeFilter with simple std::atomic
fad1f0fd33 net: Remove unused cs_feeFilter (MarcoFalke)

Pull request description:

  A `RecursiveMutex` is overkill for setting or reading a plain integer. Even a `Mutex` is overkill, when a plain `std::atomic` can be used.

  This removes 11 lines of code. Also, it is cutting down on the number of locks put on the stack at the same time, which complicates review looking out for potential lock contention.

ACKs for top commit:
  jnewbery:
    utACK fad1f0fd33
  practicalswift:
    cr ACK fad1f0fd33: patch looks correct

Tree-SHA512: 647f9b954fbf52e138d3e710937eb9131b390fef0deae03fd6a162d5a18b9f194010800bbddc8f89208d91be2802dff11c3884d04b3dd233865abd12aa3cde06
2021-01-11 10:14:11 +08:00
Jon Atack
79a2576af1
doc: update ConnectionType Doxygen documentation 2021-01-10 21:34:17 +01:00
Jon Atack
f3153dc08f
gui: improve markup handling of connection type tooltip
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2021-01-10 21:34:15 +01:00
Jon Atack
4f09615733
gui: return inbound {full, block} relay type in peer details 2021-01-10 21:33:10 +01:00
Vasil Dimov
94d335da7f
net: allow CSubNet of non-IP networks
Allow creation of valid `CSubNet` objects of non-IP networks and only
match the single address they were created from (like /32 for IPv4 or
/128 for IPv6).

This fixes a deficiency in `CConnman::DisconnectNode(const CNetAddr& addr)`
and in `BanMan` which assume that creating a subnet from any address
using the `CSubNet(CNetAddr)` constructor would later match that address
only. Before this change a non-IP subnet would be invalid and would not
match any address.
2021-01-10 15:51:15 +01:00
Hennadii Stepanov
3642b2ed34
refactor, net: Increase CNode data member encapsulation
All protected CNode data members could be private.
2021-01-10 12:00:46 +02:00
Hennadii Stepanov
acebb79d3f
refactor, move-only: Relocate CNode private members 2021-01-10 12:00:44 +02:00
MarcoFalke
0944024309
Merge bitcoin-core/gui#163: Peer details: replace Direction with Connection Type
06ba9b3008 rpc: move getpeerinfo connection_type help to correct place (Jon Atack)
c95fe6e38f gui: improve connection type tooltip (Hennadii Stepanov)
2c19ba2e1d gui: replace Direction with Connection Type in peer details (Jon Atack)
7e2beab2d2 gui: create GUIUtil::ConnectionTypeToQString utility function (Jon Atack)

Pull request description:

  ![Screenshot from 2021-01-09 11-23-17](https://user-images.githubusercontent.com/2415484/104089297-c5e18d80-5265-11eb-9251-49afcfdb562b.png)

  Closes #159.

ACKs for top commit:
  hebasto:
    re-ACK 06ba9b3008, the tooltip content is organized as unordered list.
  jarolrod:
    re-ACK 06ba9b3008

Tree-SHA512: 24f46494ceb42ed308e4a4f2a543dbc4f4e6409a6f738c145a9f16e175bf69d411cbc944a4fd969f1829d57644dfbc194182fa8d4e9e6bce82acbeca8c673748
2021-01-10 10:42:50 +01:00
MarcoFalke
555fc0789d
Merge #20881: fuzz: net permission flags in net processing
fad327ca65 fuzz: net permission flags in net processing (MarcoFalke)

Pull request description:

  to increase coverage

ACKs for top commit:
  Crypt-iQ:
    cr ACK fad327c
  practicalswift:
    ACK fad327ca65

Tree-SHA512: f8643d1774ff13524ab97ab228ad070489e080435e5742af26e6e325fd002e4c1fd78b9887e11622e79d6fe0c4daaddce5e033e6cd4b32e50fd68b434aab7333
2021-01-10 10:33:57 +01:00
Anthony Towns
c97f70c861 net_processing: move Peer definition to .cpp 2021-01-09 23:27:45 +10:00
Anthony Towns
e0f2e6d2df net_processing: move PeerManagerImpl into cpp file 2021-01-09 23:27:45 +10:00
Anthony Towns
a568b82feb net_processing: split PeerManager into interface and implementation classes 2021-01-09 23:27:45 +10:00
Anthony Towns
0df3d3fd6b net_processing: make more of PeerManager private 2021-01-09 23:27:45 +10:00
Anthony Towns
0d246a59b6 net, net_processing: move NetEventsInterface method docs to net.h 2021-01-09 23:27:45 +10:00
Jon Atack
06ba9b3008
rpc: move getpeerinfo connection_type help to correct place
per review feedback
2021-01-09 13:50:00 +01:00
Hennadii Stepanov
c95fe6e38f
gui: improve connection type tooltip
- remove RPC and option names from the translatable string
- use non-breaking hyphens
2021-01-09 13:49:51 +01:00
Jon Atack
2c19ba2e1d
gui: replace Direction with Connection Type in peer details 2021-01-09 13:49:20 +01:00
Andrew Chow
ea0a7ec949 Remove deprecated bumpfee behavior 2021-01-08 18:58:58 -05:00
Hennadii Stepanov
af58f5b12c
qt: Stop the effect of hidden widgets on the size of QStackedWidget
Layouts of the hidden widgets, those are children of QStackedWidget,
could prevent to adjust the size of the parent widget in the
WalletFrame widget.
2021-01-08 16:53:20 +02:00
Jon Atack
7e2beab2d2
gui: create GUIUtil::ConnectionTypeToQString utility function 2021-01-08 15:24:31 +01:00
Hennadii Stepanov
4e1154dfd1
qt: Use "fusion" style on macOS Big Sur with old Qt
The "macintosh" style is broken on macOS Big Sur at least for Qt 5.9.8.
2021-01-08 16:20:49 +02:00
MarcoFalke
9158d6f341
Merge #20786: net: [refactor] Prefer integral types in CNodeStats
faecb74562 Expose integral m_conn_type in CNodeStats, remove m_conn_type_string (Jon Atack)

Pull request description:

  Currently, strings are stored for what are actually integral (strong) enum types. This is fine, because the strings are only used as-is for the debug log and RPC. However, it complicates using them in the GUI. User facing strings in the GUI should be translated and only string literals can be picked up for translation, not runtime `std::string`s.

  Fix that by removing the `std::string` members and replace them by strong enum integral types.

ACKs for top commit:
  jonatack:
    Code review ACK faecb74562
  theStack:
    Code review ACK faecb74562 🌲

Tree-SHA512: 24df2bd0645432060e393eb44b8abaf20fe296457d07a867b0e735c3e2e75af7b03fc6bfeca734ec33ab816a7c8e1f8591a5ec342f3afe3098a4e41f5c2cfebb
2021-01-08 15:14:53 +01:00
MarcoFalke
fa44417fcb
fuzz: Add missing muhash registration 2021-01-08 09:40:50 +01:00
Wladimir J. van der Laan
86a8b35f32
Merge #14501: Fix possible data race when committing block files
ef712298c3 util: Check for file being NULL in DirectoryCommit (Luke Dashjr)
4574904038 Fix possible data race when committing block files (Evan Klitzke)
220bb16cbe util: Introduce DirectoryCommit commit function to sync a directory (Evan Klitzke)
ce5cbaea63 util.h: Document FileCommit function (Evan Klitzke)
844d650eea util: Prefer Mac-specific F_FULLSYNC over fdatasync in FileCommit (Evan Klitzke)
f6cec0bcaf util: Refactor FileCommit from an #if sequence nested in #else, to a sequence of #elif (Evan Klitzke)

Pull request description:

  Reviving #12696

ACKs for top commit:
  laanwj:
    Code review ACK ef712298c3

Tree-SHA512: 07d650990ef4c18d645dee3f9a199a940683ad17557d79d93979a76c4e710d8d70e6eae01d1a5991494a24a7654eb7db868be0c34a31e70b2509945d95bc9cce
2021-01-07 22:07:33 +01:00
Wladimir J. van der Laan
d7e2401c62
Merge #18077: net: Add NAT-PMP port forwarding support
a191e23b8e doc: Add release notes (Hennadii Stepanov)
ae749d12dd doc: Add libnatpmp stuff (Hennadii Stepanov)
e28f9be87a ci: Add libnatpmp-dev package to some builds (Hennadii Stepanov)
5a0185b6c9 gui: Add NAT-PMP network option (Hennadii Stepanov)
a39f7336a3 net: Add -natpmp command line option (Hennadii Stepanov)
28acffd9d5 net: Add NAT-PMP to port mapping loop (Hennadii Stepanov)
a8d9f275d0 net: Add libnatpmp support (Hennadii Stepanov)
58e8364dcd gui: Apply port mapping changes on dialog exit (Hennadii Stepanov)
cf151cc68c scripted-diff: Rename UPnP stuff (Hennadii Stepanov)
4e91b1e24d net: Add flags for port mapping protocols (Hennadii Stepanov)
8b50d1b5bb net: Keep trying to use UPnP when -upnp=1 (Hennadii Stepanov)
28e2961fd6 refactor: Replace magic number with named constant (Hennadii Stepanov)
02ccf69dd6 refactor: Move port mapping code to its own module (Hennadii Stepanov)

Pull request description:

  Close #11902
  This PR is an alternative to:
  - #12288
  - #15717

  To compile with NAT-PMP support on Ubuntu [`libnatpmp-dev`](https://packages.ubuntu.com/source/bionic/libnatpmp) should be available.

  Log excerpt:
  ```
  2020-02-05T20:12:28Z [mapport] NAT-PMP: public address = 95.164.65.194
  2020-02-05T20:12:28Z [mapport] AddLocal(95.164.65.194:18333,3)
  2020-02-05T20:12:28Z [mapport] NAT-PMP: port mapping successful.
  ```

  See: [`libnatpmp`](https://miniupnp.tuxfamily.org/libnatpmp.html)

  ---

  Some follow-ups are out of this PR's scope:
  - mention NAT-PMP library in the version message
  - ~integrate NAT-PMP into the GUI~ (already [added](https://github.com/bitcoin/bitcoin/pull/18077#issuecomment-589405068))

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

Tree-SHA512: 10e19267c21bf30f20ff1abfc882d526049f0e790b95e12f109dc2bed7c0aef45de03eaf967f4e667e7509be04f1873a5c508087393d947205f3aab2ad6d7cf1
2021-01-07 19:41:55 +01:00
Amiti Uttarwar
5bc04e8837 [rpc/net] Introduce addconnection to test outbounds & blockrelay
Add a new RPC endpoint to enable opening outbound connections from
the tests. The functional test framework currently uses the addnode RPC, which
has different behavior than general outbound peers. These changes enable
creating both full-relay and block-relay-only connections. The new RPC
endpoint calls through to a newly introduced AddConnection method on
CConnman that ensures we stay within the allocated max.
2021-01-07 10:15:56 -08:00
MarcoFalke
fad327ca65
fuzz: net permission flags in net processing 2021-01-07 19:07:02 +01:00
Wladimir J. van der Laan
b6a71b80d2
Merge #19055: Add MuHash3072 implementation
9815332d51 test: Change MuHash Python implementation to match cpp version again (Fabian Jahr)
01297fb3ca fuzz: Add MuHash consistency fuzz test (Fabian Jahr)
b111410914 test: Add MuHash3072 fuzz test (Fabian Jahr)
c122527385 bench: Add Muhash benchmarks (Fabian Jahr)
7b1242229d test: Add MuHash3072 unit tests (Fabian Jahr)
adc708c98d crypto: Add MuHash3072 implementation (Fabian Jahr)
0b4d290bf5 crypto: Add Num3072 implementation (Fabian Jahr)
589f958662 build: Check for 128 bit integer support (Fabian Jahr)

Pull request description:

  This is the first split of #18000 which implements the Muhash algorithm and uses it to calculate the UTXO set hash in `gettxoutsetinfo`.

ACKs for top commit:
  laanwj:
    Code review ACK 9815332d51

Tree-SHA512: 4bc090738f0e3d80b74bdd8122e24a8ce80121120fd37c7e4335a73e7ba4fcd7643f2a2d559e2eebf54b8e3a3bd5f12cfb27ba61ded135fda210a07a233eae45
2021-01-07 17:57:17 +01:00
Hennadii Stepanov
5a0185b6c9
gui: Add NAT-PMP network option 2021-01-07 18:07:10 +02:00
Hennadii Stepanov
a39f7336a3
net: Add -natpmp command line option 2021-01-07 18:07:09 +02:00
Hennadii Stepanov
28acffd9d5
net: Add NAT-PMP to port mapping loop 2021-01-07 18:07:09 +02:00
Hennadii Stepanov
a8d9f275d0
net: Add libnatpmp support 2021-01-07 18:07:09 +02:00
Hennadii Stepanov
58e8364dcd
gui: Apply port mapping changes on dialog exit
This commit does not change behavior. It is a prerequisite for NAT-PMP
support adding.
2021-01-07 18:07:08 +02:00
Hennadii Stepanov
cf151cc68c
scripted-diff: Rename UPnP stuff
-BEGIN VERIFY SCRIPT-
sed -i 's/g_upnp_interrupt/g_mapport_interrupt/' src/mapport.cpp
sed -i 's/if(g_upnp_thread/if (g_mapport_thread/' src/mapport.cpp
sed -i 's/g_upnp_thread/g_mapport_thread/' src/mapport.cpp
sed -i 's/LOCAL_UPNP/LOCAL_MAPPED/' src/mapport.cpp
sed -i 's/\bupnp\b/mapport/' src/mapport.cpp
sed -i 's/LOCAL_UPNP,  /LOCAL_MAPPED,/' src/net.h
-END VERIFY SCRIPT-
2021-01-07 18:07:08 +02:00
Hennadii Stepanov
4e91b1e24d
net: Add flags for port mapping protocols 2021-01-07 18:07:08 +02:00
Hennadii Stepanov
8b50d1b5bb
net: Keep trying to use UPnP when -upnp=1 2021-01-07 18:07:07 +02:00
Hennadii Stepanov
28e2961fd6
refactor: Replace magic number with named constant 2021-01-07 18:07:07 +02:00
Hennadii Stepanov
02ccf69dd6
refactor: Move port mapping code to its own module
This commit does not change behavior.
2021-01-07 18:06:58 +02:00
MarcoFalke
3a6acd1772
Merge #20789: fuzz: Rework strong and weak net enum fuzzing
eeee43bc48 fuzz: Use ConsumeWeakEnum for ServiceFlags (MarcoFalke)
fa9949b914 fuzz: Add ConsumeWeakEnum helper, Extract ALL_NET_PERMISSION_FLAGS (MarcoFalke)
faaef9434c fuzz: [refactor] Extract ALL_CONNECTION_TYPES constant (MarcoFalke)
fa42da2d54 fuzz: Use ConsumeNode in process_message target (MarcoFalke)
fa121f058f fuzz: Use ConsumeNode in process_messages target (MarcoFalke)

Pull request description:

  The fuzz tests have several problems:
  * The array passed to the fuzz engine to pick `net_permission_flags` is outdated
  * The process_message* targets has the service flags as well as connection type hardcoded, limiting potential coverage
  * The service flags deserialization from the fuzz engine doesn't allow for easy "exact matches". The fuzz engine has to explore a 64-bit space to hit an "exact match" (only one bit set)

  Fix all issues in the commits in this pull

ACKs for top commit:
  mzumsande:
    ACK eeee43bc48 after rebase.

Tree-SHA512: 1ad9520c7e708b7f4994ae8f77886ffca33d7c542756e2a3e07dbbbe59e360f9fcaccf2e2fb57d9bc731d4aeb4938fb1c5c546e9d2744b007af5626f5cb377fe
2021-01-07 17:04:56 +01:00
MarcoFalke
fad1f0fd33
net: Remove unused cs_feeFilter 2021-01-07 15:25:47 +01:00
Jon Atack
faecb74562
Expose integral m_conn_type in CNodeStats, remove m_conn_type_string 2021-01-07 15:18:44 +01:00
MarcoFalke
4b8b71e630
Merge bitcoin-core/gui#173: Follow Qt docs when implementing rowCount and columnCount
195fcb53a0 qt: Follow Qt docs when implementing rowCount and columnCount (Hennadii Stepanov)

Pull request description:

  [`QAbstractItemModel::rowCount`](https://doc.qt.io/qt-5/qabstractitemmodel.html#rowCount):
  > **Note:** When implementing a table based model, `rowCount()` should return 0 when the parent is valid.

  [`QAbstractItemModel::columnCount`](https://doc.qt.io/qt-5/qabstractitemmodel.html#columnCount):
  > **Note:** When implementing a table based model, `columnCount()` should return 0 when the parent is valid.

ACKs for top commit:
  jarolrod:
    Tested ACK 195fcb53a0. Compiled and ran on macOS (Big Sur 11.1 and Catalina 10.15.7), Arch Linux, and FreeBSD. visually verified no weird effects with the `Address`, `Ban`, `Peer`, and `Transaction` tables. As already stated, the code change brings us inline with what the QT Docs recommend.

Tree-SHA512: 179a3430e68e77b22cdf642964cd96c023a2286ee256bbeb25b43df3d2eef6f59978c8d92173c6be5071d127fdcd6aa338142f6eaf003ff08e4abd65172d20ca
2021-01-07 14:59:15 +01:00
MarcoFalke
42675e7833
Merge #20864: net: Move SocketSendData lock annotation to header
fa210689e2 net: Move SocketSendData lock annotation to header (MarcoFalke)
fa0a71781a net: Move CConnman/NetEventsInterface after CNode in header file (MarcoFalke)

Pull request description:

  Lock annotations must be in the header, otherwise the will have limited or no effect

ACKs for top commit:
  jnewbery:
    utACK fa210689e2

Tree-SHA512: c25aac793662227f2bb163e2f98cd38e89b43a03bad925d192d6166dee76a456110eaf55be5e4b4f2ddcf20bde7e3fc82a7a4338670a1f2d027d01b4a8908303
2021-01-07 14:57:47 +01:00
MarcoFalke
fa210689e2
net: Move SocketSendData lock annotation to header
Also, add lock annotation to SendMessages

Can be reviewed with "--word-diff-regex=."
2021-01-07 09:41:34 +01:00
MarcoFalke
fa0a71781a
net: Move CConnman/NetEventsInterface after CNode in header file
Can be reviewed with --color-moved=dimmed-zebra --patience
2021-01-07 09:40:49 +01:00
MarcoFalke
8a720ced5f
Merge bitcoin-core/gui#165: Save QSplitter state in QSettings
90f9fc274b qt: Save QSplitter state in QSettings (Hennadii Stepanov)

Pull request description:

  This PR adds the ability to save the `QSplitter` widget state in `QSettings` during shutdown, and restore it on startup.

  A user no longer needs to adjust the splitter every time :)
  ![DeepinScreenshot_select-area_20201225211422](https://user-images.githubusercontent.com/32963518/103141024-046c3980-46f7-11eb-9a8c-83613527ffe1.png)

ACKs for top commit:
  jonasschnelli:
    utACK 90f9fc274b
  jonatack:
    ACK 90f9fc274b this sets the "PeersTabSplitterSizes" value in the RPCConsole dtor and restores it in the RPCConsole ctor; tested in Debian with various split settings, tab open/close sequences, and shutdown methods, and the Peers window split state was faithfully maintained.

Tree-SHA512: efbd6a4cee512982944955d36775e75a8a217b1dc49e62d42c6e402d2710dd44324b2c3c1edeb5fe38d9229e0e4a39734d1f4e63405ade8694762e1bbf72020b
2021-01-07 09:09:16 +01:00
MarcoFalke
f13e03cda2
Merge #20584: Declare de facto const reference variables/member functions as const
31b136e580 Don't declare de facto const reference variables as non-const (practicalswift)
1c65c075ee Don't declare de facto const member functions as non-const (practicalswift)

Pull request description:

  _Meta: This is the second and final part of the `const` refactoring series (part one: #20581). **I promise: no more refactoring PRs from me in a while! :)** I'll now go back to focusing on fuzzing/hardening!_

  Changes in this PR:
  * Don't declare de facto const member functions as non-const
  * Don't declare de facto const reference variables as non-const

  Awards for finding candidates for the above changes go to:
  * `clang-tidy`'s [`readability-make-member-function-const`](https://clang.llvm.org/extra/clang-tidy/checks/readability-make-member-function-const.html)  check ([list of `clang-tidy` checks](https://clang.llvm.org/extra/clang-tidy/checks/list.html))
  * `cppcheck`'s `constVariable` check ([list of `cppcheck` checks](https://sourceforge.net/p/cppcheck/wiki/ListOfChecks/))

  See #18920 for instructions on how to analyse Bitcoin Core using Clang Static Analysis, `clang-tidy` and `cppcheck`.

ACKs for top commit:
  ajtowns:
    ACK 31b136e580
  jonatack:
    ACK 31b136e580
  theStack:
    ACK 31b136e580 ❄️

Tree-SHA512: f58f8f00744219426874379e9f3e9331132b9b48e954d24f3a85cbb858fdcc98009ed42ef7e7b4619ae8af9fc240a6d8bfc1c438db2e97b0ecd722a80dcfeffe
2021-01-07 09:05:09 +01:00
Hennadii Stepanov
d4feb6812a
qt: Use layout manager for Create Wallet dialog 2021-01-06 23:35:24 +02:00
Wladimir J. van der Laan
3b6d1b61d3
Merge #20829: doc: add -netinfo help
6f2c4fd077 netinfo: add user help documentation (Jon Atack)

Pull request description:

  This is the help doc commit of #20764 without the rest of the PR or anything new since the 0.21.0 branch-off in order to target giving users a -netinfo help doc for 0.21.

  - to test the new help
  ```
  $ ./src/bitcoin-cli -netinfo help
  ```
  - to see the updated short help
  ```
  $ ./src/bitcoin-cli -help | grep -A4 netinfo
  ```

  <details><summary><code>-netinfo</code> help doc</summary><p>

  ```
  $ ./src/bitcoin-cli -netinfo help
  -netinfo level "help"

  Returns a network peer connections dashboard with information from the remote server.
  Under the hood, -netinfo fetches the data by calling getpeerinfo and getnetworkinfo.
  An optional integer argument from 0 to 4 can be passed for different peers listings.
  Pass "help" to see this detailed help documentation.
  If more than one argument is passed, only the first one is read and parsed.
  Suggestion: use with the Linux watch(1) command for a live dashboard; see example below.

  Arguments:
  1. level (integer 0-4, optional)  Specify the info level of the peers dashboard (default 0):
                                    0 - Connection counts and local addresses
                                    1 - Like 0 but with a peers listing (without address or version columns)
                                    2 - Like 1 but with an address column
                                    3 - Like 1 but with a version column
                                    4 - Like 1 but with both address and version columns
  2. help (string "help", optional) Print this help documentation instead of the dashboard.

  Result:

  * The peers listing in levels 1-4 displays all of the peers sorted by direction and minimum ping time:

    Column   Description
    ------   -----------
    <->      Direction
             "in"  - inbound connections are those initiated by the peer
             "out" - outbound connections are those initiated by us
    type     Type of peer connection
             "full"   - full relay, the default
             "block"  - block relay; like full relay but does not relay transactions or addresses
    net      Network the peer connected through ("ipv4", "ipv6", "onion", "i2p", or "cjdns")
    mping    Minimum observed ping time, in milliseconds (ms)
    ping     Last observed ping time, in milliseconds (ms)
    send     Time since last message sent to the peer, in seconds
    recv     Time since last message received from the peer, in seconds
    txn      Time since last novel transaction received from the peer and accepted into our mempool, in minutes
    blk      Time since last novel block passing initial validity checks received from the peer, in minutes
    age      Duration of connection to the peer, in minutes
    asmap    Mapped AS (Autonomous System) number in the BGP route to the peer, used for diversifying
             peer selection (only displayed if the -asmap config option is set)
    id       Peer index, in increasing order of peer connections since node startup
    address  IP address and port of the peer
    version  Peer version and subversion concatenated, e.g. "70016/Satoshi:21.0.0/"

  * The connection counts table displays the number of peers by direction, network, and the totals
    for each, as well as a column for block relay peers.

  * The local addresses table lists each local address broadcast by the node, the port, and the score.

  Examples:

  Connection counts and local addresses only
  > bitcoin-cli -netinfo

  Compact peers listing
  > bitcoin-cli -netinfo 1

  Full dashboard
  > bitcoin-cli -netinfo 4

  Full live dashboard, adjust --interval or --no-title as needed (Linux)
  > watch --interval 1 --no-title ./src/bitcoin-cli -netinfo 4

  See this help
  > bitcoin-cli -netinfo help

  ```
  </p></details>

ACKs for top commit:
  laanwj:
    ACK 6f2c4fd077

Tree-SHA512: dd49b1ce65546dacfb8ba9f9d57de0eae55560fd05533cf26c0b5d6ec65bf1de789c3287e90a0e2f47707532fab2fe62919a4192a7ffd58ac8eec18293e9aaeb
2021-01-06 16:11:09 +01:00
MarcoFalke
4eada5d8b1
Merge #20816: net: Move RecordBytesSent() call out of cs_vSend lock
378aedc452 [net] Add cs_vSend lock annotations (John Newbery)
673254515a [net] Move RecordBytesSent() call out of cs_vSend lock (John Newbery)

Pull request description:

  RecordBytesSent() does not require cs_vSend to be locked, so reduce the scope of cs_vSend.

  Also correctly annotate the CNode data members that are guarded by cs_vSend.

  This is a simpler alternative to #19673.

ACKs for top commit:
  jnewbery:
    ok, reverting to commit 378aedc which has two ACKs already. Any style issues can be fixed up in future PRs.
  troygiorshev:
    ACK 378aedc452
  theStack:
    re-ACK 378aedc452
  MarcoFalke:
    review ACK 378aedc452 🔌

Tree-SHA512: e9cd6c472b7e1479120c1bf2d1c640cf6d18c7d589a5f9b7dfc4875e5790adaab403a7a1b945a47e79e7249a614b8583270e4549f89b22e8a9edb2e4818b0d07
2021-01-06 07:07:35 +01:00
Hennadii Stepanov
f0d04795e2
qt: Fix TxViewDelegate layout
This change (1) prevents overlapping date and amount strings,
and (2) guaranties that "eye" sign at the end of the watch-only
address/label is always visible.
2021-01-05 22:47:12 +02:00
Jon Atack
6f2c4fd077
netinfo: add user help documentation
and drop no longer needed sort description header to save screen space
2021-01-05 21:31:48 +01:00
Hennadii Stepanov
d439921406
qt: Add TransactionOverviewWidget class 2021-01-05 22:10:10 +02:00
MarcoFalke
417f95fa45
Merge #19915: p2p, refactor: Use Mutex type for some mutexes in CNode class
0e51a35512 refactor: Use Mutex type for some mutexes in CNode class (Hennadii Stepanov)

Pull request description:

  No need the `RecursiveMutex` type for the `CNode::cs_vSend`, `CNode::cs_hSocket` and `CNode::cs_vRecv`.

  Related to #19303.

ACKs for top commit:
  jnewbery:
    utACK 0e51a35512
  MarcoFalke:
    review ACK 0e51a35512 🔊

Tree-SHA512: 678ee5e3c15ad21a41cb86ec7179741bd505a138638fdc07f41d6d677c38fbf2208219bfc0509e3675e721fc8d8816e858070db7b87c5d72ad93aae81f7e1636
2021-01-05 12:19:08 +01:00
MarcoFalke
fafd725a7c
Merge #19846: build: enable unused member function diagnostic
819d03b932 refactor: took out unused member functions (Zero)
ed69213c2b build: enable unused member function diagnostic (Zero)

Pull request description:

  This PR enables the `-Wunused-member-function` compiler diagnostic, as discussed in #19702.

  > **Notice**: The `unused-member-function` diagnostic is only available on clang. Therefore, clang should be used to test this PR.

  - [x] Include the `-Wunused-member-function`diagnostic in `./configure.ac`. (ed69213c2b)
  - [x] Resolve the reported warnings. (819d03b932)

  Currently, enabling this flag no longer reports the following warnings:

  > **Note**: output from `make 2>&1 | grep "warning: unused member function" | sort | uniq -c`

  ```
  1 index/blockfilterindex.cpp:54:5: warning: unused member function 'DBHeightKey' [-Wunused-member-function]
  2 script/bitcoinconsensus.cpp:50:9: warning: unused member function 'GetType' [-Wunused-member-function]
  1 test/util_tests.cpp:1975:14: warning: unused member function 'operator=' [-Wunused-member-function]
  ```

  All tests have passed locally (from `make check` & `src/test/test_bitcoin`).

  This PR closes #19702.

ACKs for top commit:
  practicalswift:
    ACK 819d03b932 - patch still looks correct :)
  MarcoFalke:
    ACK 819d03b932
  pox:
    Tested ACK 819d03b932 with clang after `make clean`. No unused member function warnings.
  theStack:
    tested ACK 819d03b932

Tree-SHA512: 5fdfbbb02b3dc618a90a874a5caa5e01e596fc1d14a209e75a6981f01b253f9bca0cfac8fdd758dd7151986609fb76571c3745124a29cfd4f8cbb8d82a07272e
2021-01-05 12:06:40 +01:00
MarcoFalke
34322b7f5c
Merge #20842: docs: consolidate typo & url fixing
1112035d32 doc: fix various typos (Ikko Ashimine)
e8640849c7 doc: Use https URLs where possible (Sawyer Billings)

Pull request description:

  Consolidates / fixes the changes from #20762, #20836, #20810. There is no output when  `test/lint/lint-all.sh` is run.

  Closes #20807.

ACKs for top commit:
  MarcoFalke:
    ACK 1112035d32

Tree-SHA512: 22ca824688758281a74e5ebc6a84a358142351434e34c88c6b36045d2d241ab95fd0958565fd2060f98317e62e683323b5320cc7ec13592bf340e6922294ed78
2021-01-05 11:53:20 +01:00
MarcoFalke
faa8f68943
Replace boost::variant with std::variant 2021-01-05 10:10:50 +01:00
Amiti Uttarwar
7ff05358a9 [mempool] Remove error suppression on upgrade
In 0.21, we added unbroadcast txids to mempool.dat. Commit 9c8a55d
added a try-block to prevent throwing a "failed to deserialize mempool data"
error when a user upgrades from 0.21 to 0.22. This exception handling is no
longer useful, so now we can remove it.
2021-01-04 12:02:29 -08:00
MarcoFalke
bc8ada1c15
Merge #20736: rpc: Replace boost::variant with std::variant for RPCArg.m_fallback
fa749fbea3 rpc: Replace boost::variant with std::variant for RPCArg.m_fallback (MarcoFalke)

Pull request description:

  Now that we can use std::variant from the vanilla standard library, drop the third-party boost variant dependency.

  Patch is split out from #20480. A step-by-step replacement is possible because we don't have our own `Variant` wrapper and the source code specifies `boost::variant` explicitly.
  I think a step-by-step replacement should be preferred, because it simplifies review.

ACKs for top commit:
  fjahr:
    re-ACK fa749fbea3
  Sjors:
    re-ACK fa749fbea3

Tree-SHA512: 5e3c12b7d535f73065b4afa8df0a488f78fb25d2234f5ecbf740e624db03a34c35fea100eb7d37e84741721310e6450b7fb4296a2207a7ed1fa24485b3650981
2021-01-04 09:07:38 +01:00
Ikko Ashimine
1112035d32
doc: fix various typos
Co-authored-by: Peter Yordanov <ppyordanov@yahoo.com>
2021-01-04 12:31:31 +08:00
Sawyer Billings
e8640849c7
doc: Use https URLs where possible 2021-01-04 12:23:16 +08:00
MarcoFalke
9a2400b575
Merge #20760: test: Set correct nValue for multi-op-return policy check
fad140e311 test: Set correct nValue for multi-op-return policy check (MarcoFalke)

Pull request description:

  `CTxOut::nValue` is default-initialized to `-1`. The dust-threshold for `OP_RETURN` outputs is `0`. Thus, the policy failure would be `dust` instead of `multi-op-return`. The test only passes because the dust check is currently not run.

  Avoid that confusion by setting the value to `0`, to ensure the dust check passes.

ACKs for top commit:
  theStack:
    ACK fad140e311

Tree-SHA512: f0c7a68eb2c573d6595b2b129fa8fa2a34fa35c17691f448bf1c54ccf66059c37562e7480cde7b51c4de677038d7717873da4257147a5f60acc8bbcd25fb7e3f
2021-01-03 19:04:41 +01:00
MarcoFalke
aaaa987840
refactor: Use C++17 std::array deduction for ALL_FEE_ESTIMATE_HORIZONS 2021-01-03 18:38:31 +01:00
MarcoFalke
fa39cdd072
refactor: Use C++17 std::array deduction for OUTPUT_TYPES 2021-01-03 18:37:59 +01:00
MarcoFalke
2dab2d239a
Merge #20765: fuzz: check that certain script TxoutType are nonstandard
efaf80e9bb fuzz: check that certain script TxoutType are nonstandard (Michael Dietz)

Pull request description:

  - Every transaction of type NONSTANDARD must not be a standard script
  - The only know types of nonstandard scripts are NONSTANDARD and certain NULL_DATA and MULTISIG scripts

  When reviewing https://github.com/bitcoin/bitcoin/pull/20761 I figured this is very similar and might also be good to have

ACKs for top commit:
  MarcoFalke:
    ACK efaf80e9bb

Tree-SHA512: 6f563ee3104ea9d2633aad95f1d003474bea759d0f22636c37aa91b5536a6ff0800c42447285ca8ed12f1b3699bf781dae1e5e0a3362da578749cd3164a06ea4
2021-01-03 18:28:45 +01:00
Hennadii Stepanov
195fcb53a0
qt: Follow Qt docs when implementing rowCount and columnCount 2021-01-02 21:40:53 +02:00
John Newbery
378aedc452 [net] Add cs_vSend lock annotations 2021-01-02 16:51:44 +00:00
John Newbery
673254515a [net] Move RecordBytesSent() call out of cs_vSend lock 2021-01-02 16:51:42 +00:00
MarcoFalke
eeee43bc48
fuzz: Use ConsumeWeakEnum for ServiceFlags 2021-01-02 15:07:29 +01:00
MarcoFalke
fa9949b914
fuzz: Add ConsumeWeakEnum helper, Extract ALL_NET_PERMISSION_FLAGS 2021-01-02 15:07:07 +01:00
MarcoFalke
faaef9434c
fuzz: [refactor] Extract ALL_CONNECTION_TYPES constant 2021-01-02 15:06:36 +01:00
MarcoFalke
fa42da2d54
fuzz: Use ConsumeNode in process_message target 2021-01-02 15:05:24 +01:00
MarcoFalke
fa121f058f
fuzz: Use ConsumeNode in process_messages target 2021-01-02 15:05:21 +01:00
MarcoFalke
faaa4f2b6a
refactor: Remove nMyStartingHeight from CNode/Connman 2021-01-02 10:24:45 +01:00
MarcoFalke
ae8f797135
Merge #20210: net: assert CNode::m_inbound_onion is inbound in ctor, add getter, unit tests
86c495223f net: add CNode::IsInboundOnion() public getter and unit tests (Jon Atack)
6609eb8cb5 net: assert CNode::m_inbound_onion is inbound in ctor (Jon Atack)
993d1ecd19 test, fuzz: fix constructing CNode with invalid inbound_onion (Jon Atack)

Pull request description:

  The goal of this PR is to be able to depend on `m_inbound_onion` in AttemptToEvictConnection in #20197:

  - asserts `CNode::m_inbound_onion` is inbound in the CNode ctor to have a validity check at the class boundary
  - fixes a unit test and a fuzz utility that were passing invalid inbound onion values to the CNode ctor
  - drops an unneeded check in `CNode::ConnectedThroughNetwork()` for its inbound status
  - adds a public getter `IsInboundOnion()` that also allows unit testing it
  - adds unit test coverage

ACKs for top commit:
  sipa:
    utACK 86c495223f
  LarryRuane:
    ACK 86c495223f
  vasild:
    ACK 86c495223f
  MarcoFalke:
    review ACK 86c495223f 🐍

Tree-SHA512: 21109105bc4e5e03076fadd489204be00eac710c9de0127708ca2d0a10a048ff81f640f589a7429967ac3eb51d35fe24bb2b12e53e7aa3efbc47aaff6396d204
2021-01-02 09:54:01 +01:00
MarcoFalke
fa749fbea3
rpc: Replace boost::variant with std::variant for RPCArg.m_fallback 2021-01-01 15:08:07 +01:00
MarcoFalke
4a540683ec
Merge #20813: scripted-diff: Bump copyright headers
fa0074e2d8 scripted-diff: Bump copyright headers (MarcoFalke)

Pull request description:

  Needs to be done because no one has removed the years yet

ACKs for top commit:
  practicalswift:
    ACK fa0074e2d8

Tree-SHA512: 210e92acd7d400b556cf8259c3ec9967797420cfd19f0c2a4fa54cb2b3d32ad9ae27e771269201e7d554c0f4cd73a8b1c1a42c9f65d8685ca4d52e5134b071a3
2020-12-31 18:50:19 +01:00
MarcoFalke
fa0074e2d8
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-
2020-12-31 09:45:41 +01:00
MarcoFalke
fa29272459
Remove redundant MakeUCharSpan wrappers 2020-12-31 09:06:00 +01:00
MarcoFalke
faf4aa2f47
Remove CDataStream::Init in favor of C++11 member initialization 2020-12-31 09:05:51 +01:00
MarcoFalke
fa5b935840
fuzz: Remove duplicate ALL_OUTPUT_TYPE array 2020-12-31 08:51:42 +01:00
MarcoFalke
fafce49336
fuzz: Bump FuzzedDataProvider.h
Latest version from https://raw.githubusercontent.com/llvm/llvm-project/70de7e0d9a95b7fcd7c105b06bd90fdf4e01f563/compiler-rt/include/fuzzer/FuzzedDataProvider.h
2020-12-31 08:49:10 +01:00
Hennadii Stepanov
b3e9bcaac8
qt, refactor: Drop no longer used PeerTableModel::getNodeStats function 2020-12-30 21:01:20 +02:00
Hennadii Stepanov
49c604077c
qt: Use PeerTableModel::StatsRole
This change prevents direct calls to the PeerTableModel object that is a
layer violation.
2020-12-30 20:59:56 +02:00
Hennadii Stepanov
35007edf9c
qt: Add PeerTableModel::StatsRole
This change allows access to CNodeCombinedStats instance directly from
any view object.
2020-12-30 20:54:47 +02:00
MarcoFalke
f1f26b8d5b
Merge #20377: fuzz: Fill various small fuzzing gaps
4ddbcd0d9a fuzz: Add coverage for CDataStream consumer (practicalswift)
546a0764f3 fuzz: Fill various small fuzzing gaps (practicalswift)

Pull request description:

  Fill various small fuzzing gaps.

  See [`doc/fuzzing.md`](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md) for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the [Bitcoin Core fuzzing corpus repo](https://github.com/bitcoin-core/qa-assets).

  Happy fuzzing :)

ACKs for top commit:
  MarcoFalke:
    review ACK 4ddbcd0d9a

Tree-SHA512: d20f2cc0172f39948673846d088121782f39b4556df8b38fa14859cfa062c1519d18ee9601d4503ef1ba9613976cc5349c1fc0f0b9601a3d68127ffce1b1854e
2020-12-29 09:27:29 +01:00
Michael Dietz
efaf80e9bb
fuzz: check that certain script TxoutType are nonstandard 2020-12-28 19:31:23 -06:00
Jon Atack
8f9ca31782
p2p: remove unused legacyWhitelisted variable 2020-12-29 00:53:57 +01:00
Wladimir J. van der Laan
d875bcc8f9
Merge #162: Add network to peers window and peer details
e262a19b0b gui: display network in peer details (Jon Atack)
9136953073 gui: rename peer tab column headers, initialize in .h (Hennadii Stepanov)
05c08c696a gui: add network column in peers tab/window (Jon Atack)
e0e55060bf gui: fix broken doxygen formatting in src/qt/guiutil.h (Jon Atack)
0d5613f9de gui: create GUIUtil::NetworkToQString() utility function (Jon Atack)
af9103cc79 net, rpc: change CNodeStats::m_network from string to Network (Jon Atack)

Pull request description:

  and rename peers window column headers from NodeId and Node/Service to Peer Id and Address.

  ![Screenshot from 2020-12-27 14-45-31](https://user-images.githubusercontent.com/2415484/103172228-efec8600-4849-11eb-8cee-04a3d2ab1273.png)

ACKs for top commit:
  laanwj:
    ACK e262a19b0b

Tree-SHA512: 709c2a805c109c2dd033aca7b6b6dc94ebe2ce7a0168c71249e1e661c9c57d1f1c781a5b9ccf3b776bedeb83ae2fb5c505637337c45b1eb9a418cb1693a89761
2020-12-28 23:56:23 +01:00
MarcoFalke
e3dd0a56cf
Merge #20755: [rpc] Remove deprecated fields from getpeerinfo
454a4088a8 [doc] Add release notes for removed getpeerinfo fields. (Amiti Uttarwar)
b1a936d4ae [rpc] Remove deprecated "whitelisted" field from getpeerinfo (Amiti Uttarwar)
094c3beaa4 [rpc] Remove deprecated "banscore" field from getpeerinfo (Amiti Uttarwar)
537053336f [rpc] Remove deprecated "addnode" field from getpeerinfo (Amiti Uttarwar)

Pull request description:

  This PR removes support for 3 fields on the `getpeerinfo` RPC that were deprecated in v0.21- `addnode`, `banscore` & `whitelisted`.

ACKs for top commit:
  sipa:
    utACK 454a4088a8
  jnewbery:
    ACK 454a4088a8.

Tree-SHA512: ccc0e90c0763eeb8529cf0c46162dbaca3f7773981b3b52d9925166ea7421aed086795d56b320e16c9340f68862388785f52a9b78314865070917b33180d7cd6
2020-12-28 22:40:39 +01:00
fanquake
4a8f4ac4fc
Merge #20771: refactor: Enable -Wswitch for FeeEstimateHorizon
faccf8b1e1 refactor: Enable -Wswitch for FeeEstimateHorizon (MarcoFalke)

Pull request description:

  This enables the `-Wswitch` compiler warning for `FeeEstimateHorizon` by removing the `default` case in `switch` statements.

ACKs for top commit:
  practicalswift:
    cr ACK faccf8b1e1
  jonatack:
    ACK faccf8b1e1
  hebasto:
    ACK faccf8b1e1, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 63a8dff6e8dead149ec2fa8319e7ff41022c9534d423d3086fd8f22be073dc4915f74c7fe9139ee681a8204730cf58c80ef40c93fb33032d586e68b4f78f557d
2020-12-28 14:14:20 +08:00
practicalswift
4ddbcd0d9a fuzz: Add coverage for CDataStream consumer 2020-12-27 19:27:41 +00:00
Jon Atack
e262a19b0b
gui: display network in peer details 2020-12-27 14:38:16 +01:00
Hennadii Stepanov
9136953073
gui: rename peer tab column headers, initialize in .h 2020-12-27 14:30:33 +01:00
Jon Atack
05c08c696a
gui: add network column in peers tab/window 2020-12-27 14:30:24 +01:00
Jon Atack
e0e55060bf
gui: fix broken doxygen formatting in src/qt/guiutil.h 2020-12-27 14:29:26 +01:00
Jon Atack
0d5613f9de
gui: create GUIUtil::NetworkToQString() utility function 2020-12-27 14:29:24 +01:00
Jon Atack
af9103cc79
net, rpc: change CNodeStats::m_network from string to Network 2020-12-27 14:28:31 +01:00
fanquake
31e511658a
Merge #20674: fuzz: Call SendMessages after ProcessMessage to increase coverage
fa09f97bea fuzz: Call SendMessages after ProcessMessage to increase coverage (MarcoFalke)

Pull request description:

ACKs for top commit:
  practicalswift:
    Tested ACK fa09f97bea
  dhruv:
    tACK fa09f97
  Crypt-iQ:
    cr ACK fa09f97bea
  sipa:
    utACK fa09f97bea

Tree-SHA512: 87c52aa38f902c4f6c9c2380f486a3ab21edc0e21e48bb619cdb67cfd698154cc57b170eef31fc940c0bb2c878e155847de03fc6e4cd85bed25f10c4f80c747b
2020-12-27 17:37:32 +08:00
Amiti Uttarwar
b1a936d4ae [rpc] Remove deprecated "whitelisted" field from getpeerinfo 2020-12-26 13:30:54 -08:00
Amiti Uttarwar
094c3beaa4 [rpc] Remove deprecated "banscore" field from getpeerinfo 2020-12-26 13:30:08 -08:00
Amiti Uttarwar
537053336f [rpc] Remove deprecated "addnode" field from getpeerinfo 2020-12-26 13:30:08 -08:00
MarcoFalke
02cf20b9f5
Merge #20756: [doc] Add missing field (permissions) to the getpeerinfo help
667d203687 [doc] Add permissions to the getpeerinfo help. (Amiti Uttarwar)

Pull request description:

  This field was previously being returned, but missing from the RPCHelpMan. This PR uses the existing `NET_PERMISSIONS_DOC` to inform RPC users about this field.

  ```
     "permissions" : [                 (json array) Any special permissions that have been granted to this peer
        "str",                          (string) bloomfilter (allow requesting BIP37 filtered blocks and transactions),
                                        noban (do not ban for misbehavior; implies download),
                                        forcerelay (relay transactions that are already in the mempool; implies relay),
                                        relay (relay even in -blocksonly mode, and unlimited transaction announcements),
                                        mempool (allow requesting BIP35 mempool contents),
                                        download (allow getheaders during IBD, no disconnect after maxuploadtarget limit),
                                        addr (responses to GETADDR avoid hitting the cache and contain random records with the most up-to-date info).

        ...
      ],

  ```

ACKs for top commit:
  Sjors:
    tACK 667d203687

Tree-SHA512: 973631b41d35d6333e3cb06b35277de869110f6ad6498c7e74f00c75202e8de1788a48755c21ac964903e5e6050a5e769a63866211aec9004cd665a727a54a3c
2020-12-26 21:26:12 +01:00
MarcoFalke
faccf8b1e1
refactor: Enable -Wswitch for FeeEstimateHorizon 2020-12-26 17:32:14 +01:00
Hennadii Stepanov
90f9fc274b
qt: Save QSplitter state in QSettings 2020-12-25 21:12:18 +02:00
MarcoFalke
43fc7a569c
Merge #19972: fuzz: Add fuzzing harness for node eviction logic
5a9ee0869b tests: Add fuzzing harness for node eviction logic (practicalswift)

Pull request description:

  Add fuzzing harness for node eviction logic.

  See [`doc/fuzzing.md`](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md) for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the [Bitcoin Core fuzzing corpus repo](https://github.com/bitcoin-core/qa-assets).

  Happy fuzzing :)

ACKs for top commit:
  MarcoFalke:
    cr ACK 5a9ee0869b

Tree-SHA512: c2401d22134867e23dab1ba94ae7ef36fdf52aa0588fdc4705d9cb765ddf979fd775fdf153ce2359f1bc1787cf60bf0ebcd47c7aa29c672e6a253fa58cac292d
2020-12-25 13:32:31 +01:00
MarcoFalke
762cbd287f
Merge #15451: [doc] clarify getdata limit after #14897
c119ba3c9b [doc] clarify getdata limit after #14897 (Michael Polzer)

Pull request description:

  GETDATA is limited to blocks and transactions now and can't be used for other non-block data

ACKs for top commit:
  laanwj:
    ACK c119ba3c9b
  theStack:
    ACK c119ba3c9b
  benthecarman:
    ACK c119ba3c9b

Tree-SHA512: d6e9c109bcce4ef004ec83a9ec591163279476524dec97ed5f5c34e322dca35af66a168f0878ff972bbcec79d81623903f3619fedf8f88cdced3f3f66a779173
2020-12-25 09:43:25 +01:00
MarcoFalke
443988d406
Merge #20761: fuzz: Check that NULL_DATA is unspendable
fa26303286 fuzz: Check that NULL_DATA is unspendable (MarcoFalke)

Pull request description:

  * Every script of type NULL_DATA must be unspendable
  * The only know types of unspendable scripts are NULL_DATA and certain NONSTANDARD scripts

ACKs for top commit:
  sipa:
    utACK fa26303286

Tree-SHA512: 8297fbacf32b4868b12accc1c052d352d02d96540a1fc883de9d04a3df8734116deecc33046495c9a3af6d79fec7f8d63afbfa5e401a2ca8d7c70f0f13735c0d
2020-12-25 07:41:43 +01:00
MarcoFalke
f656165e9c
Merge #18772: rpc: calculate fees in getblock using BlockUndo data
66d012ad7f test: RPC: getblock fee calculations (Elliott Jin)
bf7d6e31b1 RPC: getblock: tx fee calculation for verbosity 2 via Undo data (Elliott Jin)

Pull request description:

  This change is progress towards #18771 .  It adapts the fee calculation part of #16083 and addresses some feedback.  The additional "verbosity level 3" features are planned for a future PR.

  **Original PR description:**

  > Using block undo data (like in #14802) we can now show fee information for each transaction in a block without the need for additional -txindex and/or a ton of costly lookups. For a start we'll add transaction fee information to getblock verbosity level 2. This comes at a negligible speed penalty (<1%).

ACKs for top commit:
  luke-jr:
    tACK 66d012ad7f
  fjahr:
    tACK 66d012ad7f
  MarcoFalke:
    review ACK 66d012ad7f 🗜

Tree-SHA512: be1fe4b866946a8dc36427f7dc72a20e10860e320a28fa49bc85bd2a93a0d699768179be29fa52e18b2ed8505d3ec272e586753ef2239b4230e0aefd233acaa2
2020-12-24 15:32:10 +01:00
MarcoFalke
fa26303286
fuzz: Check that NULL_DATA is unspendable 2020-12-24 14:16:59 +01:00
MarcoFalke
fad140e311
test: Set correct nValue for multi-op-return policy check 2020-12-24 13:43:25 +01:00
Hennadii Stepanov
957895c715
util: Log static plugins meta data and style 2020-12-23 22:30:32 +02:00
Amiti Uttarwar
667d203687 [doc] Add permissions to the getpeerinfo help.
This field was already being returned, but the RPCHelpMan did not indicate
this. So, this PR updates the help text to match.
2020-12-23 11:38:59 -08:00
John Newbery
176325a5a4 [net processing] Remove dropmessagestest
-dropmessagestest is a command line option that causes 1 in n received
messages to be dropped. The Bitcoin P2P protocol is stateful and in
general cannot handle messages being dropped. Dropped
version/verack/ping/pong messages will cause the connection to time out
and be torn down. Other dropped messages may also cause the peer to
believe that the peer has stalled and tear down the connection.

It seems difficult to uncover any actual issues with -dropmessagestest,
and any coverage that could be generated would probably be easier to
trigger with fuzz testing.
2020-12-22 17:48:31 +00:00
MarcoFalke
df127ecede
Merge #19829: net processing: Move block inventory state to net_processing
3002b4af2b [net processing] Guard m_continuation_block with m_block_inv_mutex (John Newbery)
184557e8e0 [net processing] Move hashContinue to net processing (John Newbery)
c853ef002e scripted-diff: rename vBlockHashesToAnnounce and vInventoryBlockToSend (John Newbery)
53b7ac1b7d [net processing] Move block inventory data to Peer (John Newbery)
78040f9168 [net processing] Rename nStartingHeight to m_starting_height (John Newbery)
77a2c2f8f9 [net processing] Move nStartingHeight to Peer (John Newbery)
717a374e74 [net processing] Improve documentation for Peer destruction/locking (John Newbery)

Pull request description:

  This continues the work of moving application layer data into net_processing, by moving all block inventory state into the new Peer object added in #19607.

  For motivation, see #19398.

ACKs for top commit:
  jonatack:
    re-ACK 3002b4af2b per `git diff 9aad3e4 3002b4a`
  Sjors:
    Code review re-ACK 3002b4af2b
  MarcoFalke:
    re-ACK 3002b4af2b 🌓

Tree-SHA512: eb2b474b73b025791ee3e6e41809926b332b48468763219f31638ca390f427632f05902dfc6a2c6bdc1ce47b215782f67874ddbf05b97d77d5897b7e2abfe4d9
2020-12-22 12:44:19 +01:00
Fabian Jahr
01297fb3ca
fuzz: Add MuHash consistency fuzz test 2020-12-22 01:48:30 +01:00
practicalswift
e3d2ba7c70 fuzz: Update FuzzedDataProvider.h from upstream (LLVM)
Upstream revision: 6d0488f75b/compiler-rt/include/fuzzer/FuzzedDataProvider.h

Changes:
* [compiler-rt] FuzzedDataProvider: add ConsumeData and method.
* [compiler-rt] Fix a typo in a comment in FuzzedDataProvider.h.
* [compiler-rt] Add ConsumeRandomLengthString() version without arguments.
* [compiler-rt] Refactor FuzzedDataProvider for better readability.
* [compiler-rt] FuzzedDataProvider: make linter happy.
* [compiler-rt] Mark FDP non-template methods inline to avoid ODR violations.
2020-12-21 23:19:33 +00:00
MarcoFalke
2556a973ed
Merge #20731: rpc: Add missing description of vout in getrawtransaction help text
b23349b880 rpc: Add missing description of vout in getrawtransaction help text (Ben Carman)

Pull request description:

  In `getrawtransaction` the vout did not have a description. I gave it the same description as the one used in `decoderawtransaction`.

ACKs for top commit:
  MarcoFalke:
    ACK b23349b880 🏯

Tree-SHA512: 3833b97c82a46dfeb7ac825d4b2514b4b05ce54ac41f2144a8e2f2093b3411fe1d090c1e5b0c3d09200a2ea164c8d17ece12cdb43bbaeaeccc51a9da6dd7b7a3
2020-12-21 19:57:38 +01:00
Fabian Jahr
b111410914
test: Add MuHash3072 fuzz test 2020-12-21 19:57:33 +01:00
Fabian Jahr
c122527385
bench: Add Muhash benchmarks
Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
2020-12-21 19:57:33 +01:00
Fabian Jahr
7b1242229d
test: Add MuHash3072 unit tests
Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2020-12-21 19:57:28 +01:00
Fabian Jahr
adc708c98d
crypto: Add MuHash3072 implementation
Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
2020-12-21 19:57:04 +01:00
Ben Carman
b23349b880
rpc: Add missing description of vout in getrawtransaction help text 2020-12-21 09:57:06 -06:00
Wladimir J. van der Laan
68c7acf6bb
Merge #20671: Replace boost::optional with std::optional
fa4435e22f Replace boost::optional with std::optional (MarcoFalke)
fa7e803f3e Remove unused MakeOptional (MarcoFalke)
fadd4029dc psbt: Assert that tx has a value in UpdatePSBTOutput (MarcoFalke)

Pull request description:

  Now that we can use std::optional from the vanilla standard library, drop the third-party boost dependency

ACKs for top commit:
  practicalswift:
    cr ACK fa4435e22f: patch looks correct!
  laanwj:
    code review ACK fa4435e22f
  hebasto:
    ACK fa4435e22f, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 50c5a1a130cac65e043e0177ba5b009fc2ba09343af4e23322ff2eb32184a55f8f2dea66e7a1b9d9acf56bc164eef4e47448750549a07f3b661199ac9bf9afef
2020-12-21 13:12:16 +01:00
Patrick Strateman
d8b9cec25b inline non-member functions with body in fuzzing headers 2020-12-20 18:19:43 -05:00
Fabian Jahr
0b4d290bf5
crypto: Add Num3072 implementation
Num3072 is a specialized bignum implementation used in MuHash3072.

Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
2020-12-20 23:27:58 +01:00
John Newbery
3002b4af2b [net processing] Guard m_continuation_block with m_block_inv_mutex 2020-12-20 10:06:14 +00:00
John Newbery
184557e8e0 [net processing] Move hashContinue to net processing
Also rename to m_continuation_block to better communicate meaning.
2020-12-20 10:03:38 +00:00
John Newbery
c853ef002e scripted-diff: rename vBlockHashesToAnnounce and vInventoryBlockToSend
-BEGIN VERIFY SCRIPT-
sed -i 's/vBlockHashesToAnnounce/m_blocks_for_headers_relay/g' src/net_processing.*
sed -i 's/vInventoryBlockToSend/m_blocks_for_inv_relay/g' src/net_processing.*
-END VERIFY SCRIPT-
2020-12-20 10:01:48 +00:00
John Newbery
53b7ac1b7d [net processing] Move block inventory data to Peer 2020-12-20 10:01:48 +00:00
John Newbery
78040f9168 [net processing] Rename nStartingHeight to m_starting_height
Not done as a scripted diff to avoid misnaming the local variable in
ProcessMessage().
2020-12-20 10:01:46 +00:00
John Newbery
77a2c2f8f9 [net processing] Move nStartingHeight to Peer 2020-12-20 10:01:26 +00:00
John Newbery
717a374e74 [net processing] Improve documentation for Peer destruction/locking
Suggested here:

- https://github.com/bitcoin/bitcoin/pull/19607#discussion_r467071878
- https://github.com/bitcoin/bitcoin/pull/19829#discussion_r546116786
2020-12-19 14:49:03 +00:00
MarcoFalke
fa4435e22f
Replace boost::optional with std::optional 2020-12-19 09:46:55 +01:00
MarcoFalke
fa7e803f3e
Remove unused MakeOptional
The only use was to work around a compiler warning in an ancient
compiler, which we no longer support.
2020-12-19 09:45:58 +01:00
MarcoFalke
fadd4029dc
psbt: Assert that tx has a value in UpdatePSBTOutput
This was previously done implicitly in boost::optional by BOOST_ASSERT.
Also, it was checked at runtime by valgrind if for some reason the
assert was disabled.

std::optional dereference won't assert, so add the Assert here
explicitly.

The explicit Assert also helps to document the code better.
2020-12-19 09:45:39 +01:00
Wladimir J. van der Laan
f1dbf92ff0
Merge #20434: contrib: Parse ELF directly for symbol and security checks
a0a771843f contrib: Changes to checks for PowerPC64 (Luke Dashjr)
634f6ec4eb contrib: Parse ELF directly for symbol and security checks (Wladimir J. van der Laan)

Pull request description:

  Instead of the ever-messier text parsing of the output of the readelf tool (which is clearly meant for human consumption not to be machine parseable), parse the ELF binaries directly.

  Add a small dependency-less ELF parser specific to the checks.

  This is slightly more secure, too, because it removes potential ambiguity due to misparsing and changes in the output format of `elfread`. It also allows for stricter and more specific ELF format checks in the future.

  This removes the build-time dependency for `readelf`.

  It passes the test-security-check for me locally, ~~though I haven't checked on all platforms~~. I've checked that this works on the cross-compile output for all ELF platforms supported by Bitcoin Core at the moment, as well as PPC64 LE and BE.

Top commit has no ACKs.

Tree-SHA512: 7f9241fec83ee512642fecf5afd90546964561efd8c8c0f99826dcf6660604a4db2b7255e1afb1e9bb0211fd06f5dbad18a6175dfc03e39761a40025118e7bfc
2020-12-18 12:16:40 +01:00
MarcoFalke
83e4670fd7
Merge #20690: Clean up logging of outbound connection type
6d1e85f475 Clean up logging of outbound connection type (Suhas Daftuar)

Pull request description:

  We have a function that converts `ConnectionType` enums to strings, so use it.

  Suggested by ajtowns in https://github.com/bitcoin/bitcoin/pull/19858#discussion_r540791588

ACKs for top commit:
  amitiuttarwar:
    ACK 6d1e85f475
  naumenkogs:
    ACK 6d1e85f

Tree-SHA512: f5084d8b5257380696d9fde86a8873e190cd4553feb07fa49df39bbd9510bf5832d190a3bca1571c48370d16a17c7a34900857b21b27bec0777bfa710211d7bb
2020-12-18 10:02:55 +01:00
MarcoFalke
3dd3f7c0af
Merge bitcoin-core/gui#155: Fix checkbox layout in Create Wallet dialog
e71b656f31 qt: Align layout of checkboxes (Hennadii Stepanov)

Pull request description:

  From https://github.com/bitcoin/bitcoin/issues/20555#issuecomment-747742627:
  > 0.21.0rc3 compiled from source, Ubuntu 20.04 + i3: tested mainnet, testnet, and signet. created a descriptor wallet in qt, tested torv3 with addnode, and checked if anchors.dat is created on shutdown and removed on startup.
  >
  > I've noticed the "Advanced options" label being cut-off in the wallet creation dialog.

  This PR should fix this issue.

ACKs for top commit:
  MarcoFalke:
    review ACK e71b656f31

Tree-SHA512: dcc997a440a96fc936296323afaf9f4040ac06cf5ad32724a88c2e2e16c726c35b1b2bacbb3e081839d8a69b5a6086b2570d6b2e98976f29b5427db2d434eee9
2020-12-18 08:53:38 +01:00
MarcoFalke
b27104dc52
Merge #20687: wallet: Add missing check for -descriptors wallet tool option
fae32f295c wallet: Add missing check for -descriptors wallet tool option (MarcoFalke)
faf8f61368 test: Add missing check for is_sqlite_compiled (MarcoFalke)
fa7dde1c41 wallet: Pass ArgsManager into ExecuteWalletToolFunc instead of using global (MarcoFalke)

Pull request description:

  Also, fix a test failure when compiled without sqlite

ACKs for top commit:
  ryanofsky:
    Code review ACK fae32f295c. Thanks for implementing the -descriptors check and dealing with the test failure!
  jonatack:
    Code review utACK fae32f295c

Tree-SHA512: 3d7710694085822739a8316e4abc6db270799ca6ff6b0f9e5563ae240da65ae6a9cab7ba2647feae6ba540dac40b55b38ed41c8f6ed0bf02a3d1536284448927
2020-12-18 07:56:15 +01:00
Hennadii Stepanov
e71b656f31
qt: Align layout of checkboxes 2020-12-18 01:36:21 +02:00
MarcoFalke
fae32f295c
wallet: Add missing check for -descriptors wallet tool option 2020-12-17 20:36:41 +01:00
Suhas Daftuar
6d1e85f475 Clean up logging of outbound connection type 2020-12-17 14:00:42 -05:00
Jon Atack
86c495223f
net: add CNode::IsInboundOnion() public getter and unit tests 2020-12-17 19:56:12 +01:00
Jon Atack
6609eb8cb5
net: assert CNode::m_inbound_onion is inbound in ctor
and drop an unneeded check in CNode::ConnectedThroughNetwork()
2020-12-17 19:56:10 +01:00
Jon Atack
993d1ecd19
test, fuzz: fix constructing CNode with invalid inbound_onion
as CNode ctor should only be passed inbound_onion = true
when the connection is inbound
2020-12-17 19:56:00 +01:00
MarcoFalke
fa7dde1c41
wallet: Pass ArgsManager into ExecuteWalletToolFunc instead of using global 2020-12-17 19:16:00 +01:00
Jon Atack
23d8f34689
fuzz: replace CNode code with fuzz/util.h::ConsumeNode() 2020-12-17 18:49:30 +01:00
MarcoFalke
143bd108ed
Merge #19137: wallettool: Add dump and createfromdump commands
23cac24dd3 tests: Test bitcoin-wallet dump and createfromdump (Andrew Chow)
a88c320041 wallettool: Add createfromdump command (Andrew Chow)
e1e7a90d5f wallettool: Add dump command (Andrew Chow)

Pull request description:

  Adds two commands to the `bitcoin-wallet` tool: `dump` and `createfromdump`. These commands will be useful for a wallet storage migration in the future. It is also generally useful to have a storage agnostic dump like this. These commands are similar to BDB's `db_dump` and `db_load` tools. This can also be useful for manual construction of a wallet file for tests.

  `dump` outputs every key-value pair from the wallet as comma separated hex. Each key-value pair is on its own line with the key and value in hex separated by a comma. This is output to the file specified by the new `-dumpfile` option.

  `createfromdump` takes a file produced by `dump` and creates a new wallet file with exactly the records specified in that file.

  A new option `-dumpfile` is added to the wallet tool. When used with `dump`, the records will be written to the specified file. When used with `createfromdump`, the file is read and the key-value pairs constructed from it. `createfromdump` requires `-dumpfile`.

  A simple round-trip test is added to the `tool_wallet.py`.

  This PR is based on #19334,

ACKs for top commit:
  Sjors:
    re-utACK 23cac24
  MarcoFalke:
    re review ACK 23cac24dd3 only change is rebase and removing useless shared_ptr wrapper 🎼
  ryanofsky:
    Code review ACK 23cac24dd3. Only changes since last review rebase and changing a pointer to a reference

Tree-SHA512: 2d63cf62baca3d16495aa698dc02f7d889c81b41015e9c92c23c275bb4a690fc176d351c3fd7f310bd6b17f5a936cc9be694cbecd702af741b96c0f530e72fa2
2020-12-17 15:18:37 +01:00
Wladimir J. van der Laan
af4ce674da
Merge #20635: fix misleading comment about call to non-existing function
cc3044ccdb fix misleading comment about call to non-existing function (pox)

Pull request description:

  The comment seems to be describing the subsequent call to `SyncTransaction` but refers to it as `SyncNotifications`, which is not any function currently in the codebase.

  It's best to just remove the "what" aspect of the comment and focus on the "why", which also reduces the risk of similar documentation errors in the future, in case the function ever gets renamed, for example.

ACKs for top commit:
  laanwj:
    ACK cc3044ccdb

Tree-SHA512: 882ff17836ef585a603dc504f3dd21f56f682e49b28a0998f23fd16025826fbb083b7978db3ee70d0e0ff2c86fd6c3fd99a2361e5d45c765fdc5822c5f14c0a7
2020-12-17 15:06:01 +01:00
Wladimir J. van der Laan
cfbfd389f6
Merge #20668: doc: warn that incoming conns are unlikely when not using default ports
010eed3ce0 doc: warn that incoming conns are unlikely when not using default ports (Adam Jonas)

Pull request description:

  Closes #5150.

  This was mostly copied from #5285 by sulks, who has since quit GitHub.

  The issue has remained open for 6 years, but the extra explanation still seems useful.

ACKs for top commit:
  laanwj:
    re-ACK 010eed3ce0

Tree-SHA512: d240fb06bba41ad8898ced59356c10adefc09f3abb33e277f8e2c5980b40678f2d237f286b476451bb29d2b94032a7dee2ada3b2efe004ed1c2509e70b48e40f
2020-12-17 12:10:00 +01:00
Wladimir J. van der Laan
f0913f2f95
Merge #20677: doc: Remove shouty enums in net_processing comments
0c41c10830 doc: Remove shouty enums in net_processing comments (Suhas Daftuar)

Pull request description:

  This uses the `CNode::ConnectionTypeAsString()` strings in place of the all-caps enums in a couple of comments in `net_processing`, as suggested by ajtowns in https://github.com/bitcoin/bitcoin/pull/19858#discussion_r540821050.

ACKs for top commit:
  practicalswift:
    ACK 0c41c10830
  jnewbery:
    ACK 0c41c10830
  laanwj:
    ACK 0c41c10830

Tree-SHA512: c8ab905e151ebb144c3f878277dc59d77591e4b39632658407b69b80b80d65825d5a391b01e2aea6af2fdf174c143dfe7d2f3eba84a020a58d7926458fdcd0a5
2020-12-17 11:59:58 +01:00
MarcoFalke
d0e76b5050
Merge bitcoin-core/gui#153: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::format
198fff88f3 GUI: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::format (Luke Dashjr)

Pull request description:

  A magic number snuck in with https://github.com/bitcoin/bitcoin/pull/16432

ACKs for top commit:
  hebasto:
    ACK 198fff88f3, I have reviewed the code and it looks OK, I agree it can be merged.
  kristapsk:
    utACK 198fff88f3

Tree-SHA512: 78dc23c2ae61bac41e5e34eebf57274599cb2ebb0b18d46e8a3228d42b256a1bc9bb17091c748f0f692ef1c4c241cfbd3e30a12bcd12222a234c1a9547ebe786
2020-12-17 10:53:34 +01:00
Wladimir J. van der Laan
1811e488d5
Merge #20575: Do not run functions with necessary side-effects in assert()
5021810650 Make CanFlushToDisk a const member function (practicalswift)
281cf99554 Do not run functions with necessary side-effects in assert() (practicalswift)

Pull request description:

  Do not run functions with necessary side-effects in `assert()`.

ACKs for top commit:
  laanwj:
    Code review ACK 5021810650
  sipa:
    utACK 5021810650
  theStack:
    Code Review ACK 5021810650 🟢

Tree-SHA512: 38b7faccc2f16a499f9b7b1b962b49eb58580b2a2bbf63ea49dcc418a5ecc8f21a0972fa953f66db9509c7239af67cfa2f9266423fd220963d091034d7332b96
2020-12-16 23:14:53 +01:00
Suhas Daftuar
0c41c10830 doc: Remove shouty enums in net_processing comments 2020-12-16 14:36:09 -05:00
MarcoFalke
ae9ee5bdb1
Merge #20651: net: Make p2p recv buffer timeout 20 minutes for all peers
ea36a453e3 [net] Make p2p recv buffer timeout 20 minutes for all peers (John Newbery)

Pull request description:

  The timeout interval for the send and recv buffers was changed from 90
  minutes to 20 minutes in commit f1920e86 in 2013, except for peers that
  did not support the pong message (where the recv buffer timeout remained
  at 90 minutes). A few observations:

  - for peers that support BIP 31 (pong messages), this recv buffer
    timeout is almost redundant with the ping timeout. We send a ping
    message every two minutes, and set a timeout of twenty minutes to
    receive the pong response. If the recv buffer was really timing out,
    then the pong response would also time out.
  - BIP 31 is supported by all nodes of p2p version 60000 and higher, and
    has been in widespread use since 2013. I'd be very surprised if there
    are many nodes on the network that don't support pong messages.
  - The recv buffer timeout is not specified in any p2p BIP. We're free to
    set it at any value we want.
  - A peer that doesn't support BIP 31 and hasn't sent any message to us
    at all in 90 minutes is unlikely to be useful for us, and is more likely
    to be evicted AttemptToEvictConnection() since it'll have the worst
    possible ping time and isn't providing blocks/transactions.

  Therefore, we remove this check, and set the recv buffer timeout to 20
  minutes for all peers. This removes the final p2p version dependent
  logic from the net layer, so all p2p version data can move into the
  net_processing layer.

  Alternative approaches:

  - Set the recv buffer timeout to 90 minutes for all peers. This almost
    wouldn't be a behaviour change at all (pre-BIP 31 peers would still
    have the same recv buffer timeout, and we can't ever reach a recv buffer
    timeout higher than 21 minutes for post-BIP31 peers, because the pong
    timeout would be hit first).
  - Stop supporting peers that don't support BIP 31. BIP 31 has been in
    use since 2012, and implementing it is trivial.

ACKs for top commit:
  MarcoFalke:
    review ACK ea36a453e3
  promag:
    Code review ACK ea36a453e3.
  practicalswift:
    cr ACK ea36a453e3: patch looks correct
  ajtowns:
    ACK ea36a453e3
  sipa:
    utACK ea36a453e3
  jonatack:
    Code review ACK ea36a453e3

Tree-SHA512: df290bb32d2b5d9e59a0125bb215baa92787f9d01542a7437245f1c478c7f9b9831e5f170d3cd0db2811e1b11b857b3e8b2e03376476b8302148e480d81aab19
2020-12-16 20:29:31 +01:00
Wladimir J. van der Laan
427f8c2cff
Merge #20248: test: fix length of R check in key_signature_tests
89895773b7 Fix length of R check in test/key_tests.cpp:key_signature_tests (Dmitry Petukhov)

Pull request description:

  The code before the fix only checked the length of R value of the last
  signature in the loop, and only for equality (but the length can be
  less than 32)

  The fixed code checks that length of the R value is less than or equal
  to 32 on each iteration of the loop

ACKs for top commit:
  laanwj:
    ACK 89895773b7

Tree-SHA512: 73eb2bb4a6c1c5fc11dd16851b28b43037ac06ef8cfc3b1f957429a1fca295c9422d67ec6c73c0e4bb4919f92e22dc5d733e84840b0d01ad1a529aa20d906ebf
2020-12-16 19:45:16 +01:00
Andrew Chow
a88c320041 wallettool: Add createfromdump command
Creates a new wallet file using the dump file produced by the dump
command
2020-12-16 12:33:06 -05:00
Andrew Chow
e1e7a90d5f wallettool: Add dump command
Adds a new dump command to bitcoin-wallet which prints out all of the
wallet's records in hex.
2020-12-16 12:32:47 -05:00
Wladimir J. van der Laan
ad3d4b3929
Merge #20661: Only select from addrv2-capable peers for torv3 address relay
37fe80e626 Only consider addrv2 peers for relay of non-addrv1 addresses (Pieter Wuille)
83f8821a6f refactor: add IsAddrCompatible() to CNode (Pieter Wuille)

Pull request description:

  When selecting peers to relay an address to, only pick addrv2-capable ones if the address cannot be represented in addr(v1).

  Without this I expect that propagation of torv3 addresses over the cleartext network will be very hard for a while.

ACKs for top commit:
  jonatack:
    ACK 37fe80e626
  vasild:
    ACK 37fe80e626

Tree-SHA512: 18a854ea43ad473cf89b9c5193b524109d7af75c26f7aa7e26cd72ad0db52f19c8001d566c607a7e6772bc314f770f09b6c3e07282d110c5daea193edc592cd2
2020-12-16 18:09:06 +01:00
MarcoFalke
69f1ee1922
Merge #20365: wallettool: add parameter to create descriptors wallet
173cc9b7be test: walettool create descriptors (Ivan Metlushko)
345e88eecf wallettool: add param to create descriptors wallet (Ivan Metlushko)
6d3af3ab62 wallettool: pass in DatabaseOptions into MakeWallet (Ivan Metlushko)

Pull request description:

  Rationale: expose and promote descriptor wallets in more places; make cli tool more consistent with `createwallet` rpc.

  Add `-descriptors` parameter which is off by default. When specified it will create a new descriptors wallet with sqlite backend, which is consistent with `createwallet` rpc.

  This PR is based on a suggestion from **ryanofsky** https://github.com/bitcoin/bitcoin/pull/19137#discussion_r516779603

  Example:
  ```
  $ ./src/bitcoin-wallet  -wallet=fewty -descriptors create
  Topping up keypool...
  Wallet info
  ===========
  Name: fewty
  Format: sqlite
  Descriptors: yes
  Encrypted: no
  HD (hd seed available): yes
  Keypool Size: 6000
  Transactions: 0
  Address Book: 0
  ```
  ```
  $ ./src/bitcoin-wallet  -wallet=fewty create
  Topping up keypool...
  Wallet info
  ===========
  Name: fewty
  Format: bdb
  Descriptors: no
  Encrypted: no
  HD (hd seed available): yes
  Keypool Size: 2000
  Transactions: 0
  Address Book: 0
  ```

ACKs for top commit:
  achow101:
    ACK 173cc9b7be
  ryanofsky:
    Code review ACK 173cc9b7be. This seems pretty nicely implemented now, with opportunities to clean up more and dedup later
  MarcoFalke:
    Concept ACK 173cc9b7be 🌠

Tree-SHA512: cc32ba336ff709de2707ee15f495b4617908e8700ede8401a58e894f44cda485c544d644023c9a6604d88a62db9d92152383ee2e8abf691688c25cf6e222c622
2020-12-16 17:43:20 +01:00
Wladimir J. van der Laan
3f205808a5
Merge #20605: init: Signal-safe instant shutdown
cd03513dc2 init: Signal-safe instant shutdown (Wladimir J. van der Laan)

Pull request description:

  Replace the 200ms polling loop with a faster and more efficient waiting operation. This should speed up short RPC tests.

  This change has been tried a few times before, but abandoned every time because solutions used a condition variable which is not safe for use in signals, as they need to be reentrant.

  On UNIX-ish OSes, use a safe way: a pipe. When shutdown is requested write a dummy byte to the pipe. Waiting for shutdown is a matter of a blocking read from the pipe.

  On Windows, there are no signals so using a condition variable is safe.

  This only affects bitcoind. The GUI is unaffected by this change, and keeps polling as before in `BitcoinGUI::detectShutdown()`. It might be possible to listen to a pipe there, too, but I'm not sure, and it's complicated by the GUI-node abstraction.

ACKs for top commit:
  jonatack:
    ACK cd03513dc2 tested on Debian 5.9.11-1 (2020-11-27) x86_64 GNU/Linux

Tree-SHA512: ed2f532f69fec4855c17bf7b8f3d0eb96e78ee2a3c13d374dd2c6add06e3ad6a190da8ed8f9d7a76532cf998222d67f57e35b206aec29675e96437448ae7e13c
2020-12-16 16:43:51 +01:00
practicalswift
546a0764f3 fuzz: Fill various small fuzzing gaps 2020-12-16 14:24:16 +00:00
Adam Jonas
010eed3ce0 doc: warn that incoming conns are unlikely when not using default ports 2020-12-16 09:24:03 -05:00
MarcoFalke
fa09f97bea
fuzz: Call SendMessages after ProcessMessage to increase coverage 2020-12-16 15:08:27 +01:00
practicalswift
5a9ee0869b tests: Add fuzzing harness for node eviction logic 2020-12-16 13:00:47 +00:00
MarcoFalke
b440c33179
Merge #20477: net: Add unit testing of node eviction logic
fee88237e0 Assert eviction at >= 29 candidates. Assert non-eviction at <= 20 candidates. (practicalswift)
685c428de0 test: Add unit testing of node eviction logic (practicalswift)
ed73f8cee0 net: Move eviction node selection logic to SelectNodeToEvict(...) (practicalswift)

Pull request description:

  Add unit testing of node eviction logic.

  Closes #19966.

ACKs for top commit:
  jonatack:
    ACK fee88237e0
  MarcoFalke:
    ACK fee88237e0 🐼

Tree-SHA512: 0827c35609122ca42bfabb17feaaee35c191ab4dc2e428282af425a6c176eaeaff2789b74a4f7eb4ca6b8cb10603068e90ca800e6ef3bc3904d50e76616f7a2b
2020-12-16 13:30:55 +01:00
practicalswift
fee88237e0 Assert eviction at >= 29 candidates. Assert non-eviction at <= 20 candidates. 2020-12-16 12:00:15 +00:00
practicalswift
685c428de0 test: Add unit testing of node eviction logic 2020-12-16 12:00:15 +00:00
practicalswift
ed73f8cee0 net: Move eviction node selection logic to SelectNodeToEvict(...) 2020-12-16 12:00:15 +00:00
Luke Dashjr
198fff88f3 GUI: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::format 2020-12-15 22:21:26 +00:00
Wladimir J. van der Laan
dff0f6f753
Merge #20611: Move TX_MAX_STANDARD_VERSION to policy
fade6195b1 Move TX_MAX_STANDARD_VERSION to policy (MarcoFalke)

Pull request description:

  `primitives` should only be used for the raw datastructures (parsing and format). It is not the right place to document relay policy.

ACKs for top commit:
  laanwj:
    Code review ACK fade6195b1
  lontivero:
    Concept ACK fade6195b1

Tree-SHA512: f809c4aecd14d7e9feaa7b50b9c0697232991eef36190cd960bcfb0ad6e20c71a4f6aab48c7747cf8a681eb14feda60c55b09a37f128673d519567224f29cd97
2020-12-15 22:46:49 +01:00
Pieter Wuille
37fe80e626 Only consider addrv2 peers for relay of non-addrv1 addresses 2020-12-15 12:45:41 -08:00
Pieter Wuille
83f8821a6f refactor: add IsAddrCompatible() to CNode 2020-12-15 12:45:32 -08:00
Wladimir J. van der Laan
d9a4738c9d
Merge #20660: Move signet onion seed from v2 to v3
3e6657a14d Move signet onion seed from v2 to v3 (Sjors Provoost)

Pull request description:

  Since v0.21 hidden services use the longer v3 address format.

  It may make sense to backport this to the v0.21 branch, although onion nodes can always use the non-onion seeds.

ACKs for top commit:
  MarcoFalke:
    Concept ACK 3e6657a14d
  laanwj:
    ACK 3e6657a14d
  Saibato:
    tACK 3e6657a14d  👍

Tree-SHA512: 9bb4d82345ab25d6ea971f8f106c30778ade2ba11a292e8d7449ea39581b91e51c4b34851b5c06f5dfbe07e7b04e5dc92c48c98c47a1c7ef3d5f350c3a3ad4f7
2020-12-15 21:38:33 +01:00
MarcoFalke
8bb40d5f56
Merge #20560: fuzz: Link all targets once
fa13e1b0c5 build: Add option --enable-danger-fuzz-link-all (MarcoFalke)
44444ba759 fuzz: Link all targets once (MarcoFalke)

Pull request description:

  Currently the linker is invoked more than 150 times when compiling with `--enable-fuzz`. This is problematic for several reasons:

  * It wastes disk space north of 20 GB, as all libraries and sanitizers are linked more than 150 times
  * It wastes CPU time, as the link step can practically not be cached (similar to ccache for object files)
  * It makes it a blocker to compile the fuzz tests by default for non-fuzz builds #19388, for the aforementioned reasons
  * The build file is several thousand lines of code, without doing anything meaningful except listing each fuzz target in a highly verbose manner
  * It makes writing new fuzz tests unnecessarily hard, as build system knowledge is required; Compare that to boost unit tests, which can be added by simply editing an existing cpp file
  * It encourages fuzz tests that re-use the `buffer` or assume the `buffer` to be concatenations of seeds, which increases complexity of seeds and complexity for the fuzz engine to explore; Thus reducing the effectiveness of the affected fuzz targets

  Fixes #20088

ACKs for top commit:
  practicalswift:
    Tested ACK fa13e1b0c5
  sipa:
    ACK fa13e1b0c5. Reviewed the code changes, and tested the 3 different test_runner.py modes (run once, merge, generate). I also tested building with the new --enable-danger-fuzz-link-all

Tree-SHA512: 962ab33269ebd51810924c51266ecc62edd6ddf2fcd9a8c359ed906766f58c3f73c223f8d3cc49f2c60f0053f65e8bdd86ce9c19e673f8c2b3cd676e913f2642
2020-12-15 19:00:36 +01:00
MarcoFalke
a35a3466ef
Merge #20653: doc: Move addr relay comment in net to correct place
fa86217e97 doc: Move add relay comment in net to correct place (MarcoFalke)

Pull request description:

  The comment was previously attached to `m_addr_known`, but now it is attached to `id`, which is wrong.

  Fix that by moving the comment to `RelayAddrsWithConn`.

ACKs for top commit:
  practicalswift:
    cr ACK fa86217e97: patch looks correct
  jnewbery:
    ACK fa86217e97
  theStack:
    Code review ACK fa86217e97 🌳

Tree-SHA512: ec3d5f1996aded38947d2a5fd0bb63539e88f83964cd3254984002edfd51abb4dde813c7c81619a8a3a5c55b7e9ae83c8c5be8ad6c84b4593ed3bbf463fe8979
2020-12-15 17:56:11 +01:00
Wladimir J. van der Laan
ec6149c01e
Merge #20616: Check CJDNS address is valid
f7264fff0a Check if Cjdns address is valid (Lucas Ontivero)

Pull request description:

  CJDNS addresses start with 0xFC and for that reason if a netaddr was unserialized with network type cjdns but its address prefix is not 0xFC then that netaddr should be considered invalid.

ACKs for top commit:
  jonatack:
    ACK f7264fff0a
  practicalswift:
    cr ACK f7264fff0a: patch looks correct
  theStack:
    ACK f7264fff0a ✔️

Tree-SHA512: 5300df2ffbbd69c40271b6d8df96cca98eb3e1ee76aba62c9c76025d083788ab1f1332775890c63b06e02ca593863a867cd53956bce5962383e8450487898669
2020-12-15 17:51:41 +01:00
Wladimir J. van der Laan
cd03513dc2 init: Signal-safe instant shutdown
Replace the 200ms polling loop with a faster and more efficient waiting
operation.

This was tried a few times before, but given up every time because
solutions use a condition variable which is not safe for use in signals
as they need to be reentrant.

On UNIX-ish OSes, use a safe way: a pipe. When shutdown is requested
write a dummy byte to the pipe. Waiting for shutdown is a matter of a
blocking read from the pipe.

On Windows, there are no signals so using a condition variable is safe.
2020-12-15 17:21:06 +01:00
MarcoFalke
70150824dc
Merge #20437: fuzz: Avoid time-based "non-determinism" in fuzzing harnesses by using mocked GetTime()
8c09c0c1d1 fuzz: Avoid time-based "non-determinism" in fuzzing harnesses by using mocked GetTime() (practicalswift)

Pull request description:

  Avoid time-based "non-determinism" in fuzzing harnesses by using mocked `GetTime()`.

  Prior to this commit the fuzzing harnesses `banman`, `connman`, `net` and `rbf` had time-based "non-determinism". `addrman` is fixed in #20425. `process_message` and `process_messages` are left to fix: simply using mock time is not enough for them due to interaction with `IsInitialBlockDownload()`.

  See [`doc/fuzzing.md`](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md) for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the [Bitcoin Core fuzzing corpus repo](https://github.com/bitcoin-core/qa-assets).

  Happy fuzzing :)

ACKs for top commit:
  MarcoFalke:
    review ACK 8c09c0c1d1
  practicalswift:
    > review ACK [8c09c0c](8c09c0c1d1)

Tree-SHA512: 32dfbead3dfd18cf4ff56dc2ea341aa977441b4e19a54879cf54fa5820c7e2b14b92c7e238d32fd785654f3b28cc82826ae66c03e94c292633c63c41196ba9a8
2020-12-15 17:11:59 +01:00
Sjors Provoost
3e6657a14d
Move signet onion seed from v2 to v3 2020-12-15 14:12:01 +01:00
fanquake
f1f2418433
Merge #20253: net: use std::chrono throughout maxOutbound logic
0475c8ba4d net: use std::chrono throughout maxOutbound logic (fanquake)
f805933e70 init: set nMaxOutboundLimit connection option directly (fanquake)
173d0d35f1 net: remove nMaxOutboundTimeframe from connection options (fanquake)
b117eb1486 net: remove SetMaxOutboundTimeframe (fanquake)
2f3f1aec1f net: remove SetMaxOutboundTarget (fanquake)

Pull request description:

  Switch to using `std::chrono` types for the max outbound related logic.
  Removes some unnecessary code from init.

ACKs for top commit:
  jnewbery:
    utACK 0475c8ba4d
  MarcoFalke:
    review ACK 0475c8ba4d 🎭

Tree-SHA512: 5a6d5b61e0d4c08a235cfc0257dae65d09a5df019d8d230b1a58a3e2483ddf4a31efdefc885c4a02e4715e4180b0ed92ebc0a1c08b2bf476a391945114593514
2020-12-15 20:48:21 +08:00
Jonas Schnelli
33d6337269
Merge bitcoin-core/gui#115: Replace "Hide tray icon" option with positive "Show tray icon" one
03edb52eee qt: Remove redundant BitcoinGUI::setTrayIconVisible (Hennadii Stepanov)
17174f8328 gui: Replace "Hide tray icon" option with positive "Show tray icon" one (Hennadii Stepanov)

Pull request description:

  This change makes easier both (1) using this option, and (2) reasoning about the code.

ACKs for top commit:
  jonasschnelli:
    utACK 03edb52eee

Tree-SHA512: 38e317492210d4fb13302dea383bd1f4f0ae1219d7ff2fdcb78607f15ac61a51969acaadb59b72c3f075b6356ef54368eb46fb49e6e1bd42db6d5804b97e232b
2020-12-15 09:28:50 +01:00
Lucas Ontivero
f7264fff0a Check if Cjdns address is valid 2020-12-14 14:48:52 -03:00
MarcoFalke
fa86217e97
doc: Move add relay comment in net to correct place
Can be reviewed with
--ignore-all-space --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2020-12-14 18:15:51 +01:00
MarcoFalke
fa13e1b0c5
build: Add option --enable-danger-fuzz-link-all 2020-12-14 16:55:56 +01:00
John Newbery
b316dcb758 [net processing] Tolerate sendheaders and sendcmpct messages before verack
BIP 130 (sendheaders) and BIP 152 (compact blocks) do not specify at
which stage the `sendheaders` or `sendcmpct` messages should be sent.
Therefore we should tolerate them being sent before the version-verack
handshake is complete.
2020-12-14 13:23:43 +00:00
John Newbery
ea36a453e3 [net] Make p2p recv buffer timeout 20 minutes for all peers
The timeout interval for the send and recv buffers was changed from 90
minutes to 20 minutes in commit f1920e86 in 2013, except for peers that
did not support the pong message (where the recv buffer timeout remained
at 90 minutes). A few observations:

- for peers that support BIP 31 (pong messages), this recv buffer
  timeout is almost redundant with the ping timeout. We send a ping
  message every two minutes, and set a timeout of twenty minutes to
  receive the pong response. If the recv buffer was really timing out,
  then the pong response would also time out.
- BIP 31 is supported by all nodes of p2p version 60000 and higher, and
  has been in widespread use since 2013. I'd be very surprised if there
  are many nodes on the network that don't support pong messages.
- The recv buffer timeout is not specified in any p2p BIP. We're free to
  set it at any value we want.
- A peer that doesn't support BIP 31 and hasn't sent any message to us
  at all in 90 minutes is unlikely to be useful for us, and is more likely
  to be evicted AttemptToEvictConnection() since it'll have the worst
  possible ping time and isn't providing blocks/transactions.

Therefore, we remove this check, and sent the recv buffer timeout to 20
minutes for all peers. This removes the final p2p version dependent
logic from the net layer, so all p2p version data can move into the
net_processing layer.

Alternative approaches:

- Set the recv buffer timeout to 90 minutes for all peers. This almost
  wouldn't be a behaviour change at all (pre-BIP 31 peers would still
  have the same recv buffer timeout, and we can't ever reach a recv buffer
  timeout higher than 21 minutes for post-BIP31 peers, because the pong
  timeout would be hit first).
- Stop supporting peers that don't support BIP 31. BIP 31 has been in
  use since 2012, and implementing it is trivial.
2020-12-14 12:59:30 +00:00
MarcoFalke
b103fdcb3b
Merge #19763: net: don't try to relay to the address' originator
7fabe0f359 net: don't relay to the address' originator (Vasil Dimov)

Pull request description:

  For each address to be relayed we "randomly" pick 2 nodes to send the
  address to (in `RelayAddress()`). However we do not take into
  consideration that it does not make sense to relay the address back to
  its originator (`CNode::PushAddress()` will do nothing in that case).

  This means that if the originator is among the "randomly" picked nodes,
  then we will relay to one node less than intended.

  Fix this by skipping the originating node when choosing candidates to
  relay to.

ACKs for top commit:
  sdaftuar:
    ACK 7fabe0f359 (this time I looked at the test, and verified the test breaks in expected ways if I break the code).
  jnewbery:
    utACK 7fabe0f359 (only net_processing changes. I haven't reviewed the test changes)
  jonatack:
    re-ACK 7fabe0f359 per `git range-diff b76abae fd897f8 7fabe0f`, change since last review is rebase and more readable Doxygen documentation

Tree-SHA512: c6a9d11c7afc97ab4e8960513f6416648d4a8c0c64b713c145a7482a7b9e54946f81386a3351e3ec0011e5594ba5ccff4d10c6f656bb80680d9f0d0a63366165
2020-12-14 13:37:21 +01:00
MarcoFalke
eec9366f7d
Merge #20624: net processing: Remove nStartingHeight check from block relay
f6360088de [net processing] Clarify UpdatedBlockTip() (John Newbery)
94d2cc35be [net processing] Remove unnecesary nNewHeight variable in UpdatedBlockTip() (John Newbery)
8b57013473 [net processing] Remove nStartingHeight check from block relay (John Newbery)

Pull request description:

  nStartingHeight was introduced in commit 7a47324c7 (Bitcoin version
  0.2.9, P2P version 209) with the comment "better prevention of inventory
  relaying during initial download". At that time, there was no function
  to determine whether the node was still in Initial Block Download, so to
  prevent syncing nodes from relaying old blocks to their peers, a check
  was added to never relay a block to a peer where the height was lower
  than 2000 less than the peer's best block. That check was updated
  several times in later commits to ensure that we weren't relaying blocks
  before the latest checkpoint if the peer didn't provide a
  startingheight. The checkpoint comparison was changed to compare with an
  estimate of the highest block in commit eae82d8e.

  In commit 202e0194, all block relay was gated on being out of Initial
  Block Download. In commit 0278fb5f, the comparison to nBlockEstimate was
  removed since "we already checked IsIBD()".

  We can remove the check against nStartingHeight entirely. If the node is
  out of Initial Block Download, then its tip height must have been within
  24 hours of current time, so should not be more than ~144 blocks behind
  the most work tip.

  This simplifies moving block inventory state into the `Peer` object (#19829).

ACKs for top commit:
  Sjors:
    utACK f636008
  jonatack:
    ACK f6360088de
  MarcoFalke:
    ACK f6360088de 💽
  ariard:
    Code Review ACK f636008

Tree-SHA512: 4959cf35f1dcde46f34bffec1375729a157e1b2a1fd8a8ca33da9771c3c89a6c43e7050cdeeab8d90bb507b0795703db8c8bc304a1a5065ef00aae7a6992ca4f
2020-12-14 11:01:01 +01:00
MarcoFalke
096bd374da
Merge #20592: doc: update wtxidrelay documentation per BIP339
4b7b58b3fe Update net_processing WTXID documentation per BIP339 (Jon Atack)

Pull request description:

  BIP339 currently states:

  *The wtxidrelay message MUST be sent in response to a version message from a peer whose protocol version is >= 70016 and prior to sending a verack. A wtxidrelay message received after a verack message MUST be ignored or treated as invalid.*

ACKs for top commit:
  MarcoFalke:
    ACK 4b7b58b3fe
  practicalswift:
    ACK 4b7b58b3fe
  RiccardoMasutti:
    ACK 4b7b58b

Tree-SHA512: 58ca6b197618cc73c70aa5de0a2d9d89a68b4cad9d5a708278ef17a9d6854d4362bcc384b6d29696642924977204a8fc120b31e91e2d97b6072b7b0d41c9f2dc
2020-12-14 10:52:28 +01:00
Anthony Towns
95d5d5e625 rpc: allow getblocktemplate for test chains when unconnected or in IBD 2020-12-14 18:32:57 +10:00
Anthony Towns
81c54dec20 rpc: update getblocktemplate with signet rule, include signet_challenge 2020-12-14 18:32:57 +10:00
fanquake
25bc840e03
Merge #20617: p2p: Remove m_is_manual_connection from CNodeState
a33442fdc7 Remove m_is_manual_connection from CNodeState (Antoine Riard)

Pull request description:

  Currently, this member is only used to exclude MANUAL peers from discouragement
  in MaybePunishNodeForBlock(). Manual connections are already protected in
  MaybeDiscourageAndDisconnect(), independently from their network
  processing behaviors.

ACKs for top commit:
  MarcoFalke:
    cr ACK a33442fdc7
  promag:
    Code review ACK a33442fdc7.
  jnewbery:
    utACK a33442fdc7
  amitiuttarwar:
    code review ACK a33442fdc7

Tree-SHA512: cfe3f3dfa131373e3299002d34ae9e22ca6e1a966831bab32fcf06ff1d08f06095b4ab020cc4d267f3ec05ae23fbdc22373382ab828b999c0db11b8c842a4f0c
2020-12-14 10:37:19 +08:00
fanquake
0475c8ba4d
net: use std::chrono throughout maxOutbound logic 2020-12-13 11:41:33 +08:00
fanquake
f805933e70
init: set nMaxOutboundLimit connection option directly
DEFAULT_MAX_UPLOAD_TARGET is a compile time constant.
2020-12-13 11:12:05 +08:00
fanquake
173d0d35f1
net: remove nMaxOutboundTimeframe from connection options
It's not actually possible to change this value, so remove the
indirection of it being a conn option.

DEFAULT_MAX_UPLOAD_TIMEFRAME is a compile time constant.
2020-12-13 11:10:40 +08:00
fanquake
b117eb1486
net: remove SetMaxOutboundTimeframe
This was introduced in 872fee3fcc and it's unclear
if it's ever been used.
2020-12-13 10:38:24 +08:00
fanquake
2f3f1aec1f
net: remove SetMaxOutboundTarget
This has been unused since f3552da813.
2020-12-13 10:38:24 +08:00
fanquake
ade38b6ee8
Merge #20588: Remove unused and confusing CTransaction constructor
fac39c1983 wallet: document that tx in CreateTransaction is purely an out-param (MarcoFalke)
faac31521b Remove unused and confusing CTransaction constructor (MarcoFalke)

Pull request description:

  The constructor is confusing and dangerous (as explained in the TODO), fix that by removing it.

ACKs for top commit:
  laanwj:
    Code review ACK fac39c1983
  promag:
    Code review ACK fac39c1983.
  theStack:
    Code review ACK fac39c1983

Tree-SHA512: e0c8cffce8d8ee0166b8e1cbfe85ed0657611e26e2af0d69fde70eceaa5d75cbde3eb489af0428fe4fc431360b4c791fb1cc21b8dee7d4c7a4f17df00836229d
2020-12-13 10:36:22 +08:00
MarcoFalke
b18978066d
Merge #20079: p2p: Treat handshake misbehavior like unknown message
faaad1bbac p2p: Ignore version msgs after initial version msg (MarcoFalke)
fad68afcff p2p: Ignore non-version msgs before version msg (MarcoFalke)

Pull request description:

  Handshake misbehaviour doesn't cost us more than any other unknown message, so it seems odd to treat it differently

ACKs for top commit:
  jnewbery:
    utACK faaad1bbac
  practicalswift:
    ACK faaad1bbac: patch looks correct

Tree-SHA512: 9f30c3b5c1f6604fd02cff878f10999956152419a3dd9825f8267cbdeff7d06787418b41c7fde8a00a5e557fe89204546e05d5689042dbf7b07fbb7eb95cddff
2020-12-12 12:32:46 +01:00
MarcoFalke
ffc4d04990
Merge #20275: wallet: List all wallets in non-SQLite and non-BDB builds
f3d870fc22 wallet: List all wallets in non-SQLite or non-BDB builds (Russell Yanofsky)
d70dc89e78 refactor: Consolidate redundant wallet database path and exists functions (Russell Yanofsky)
6a7a63644c refactor: Drop call to GetWalletEnv in wallet salvage code (Russell Yanofsky)
6ee9cbdd18 refactor: Replace ListWalletDir() function with ListDatabases() (Russell Yanofsky)
5aaeb6cf87 MOVEONLY: Move IsBDBFile, IsSQLiteFile, and ListWalletDir (Russell Yanofsky)

Pull request description:

  This PR does not change behavior when bitcoin is built normally with both the SQLite and BDB libraries. It just makes non-SQLite and non-BDB builds more similar to the normal build. Specifically:

  - It makes wallet directory lists always include all wallets so wallets don't appear missing depending on the build.

  - It now triggers specific "Build does not support SQLite database format" and "Build does not support Berkeley DB database format" errors if a wallet can't be loaded instead of the more ambiguous and scary "Data is not in recognized format" error.

  Both changes are implemented in the last commit. The previous commits are just refactoring cleanups that make the last commit possible and consolidate and reduce code.

ACKs for top commit:
  achow101:
    ACK f3d870fc22
  promag:
    Tested ACK f3d870fc22. Tested a --without-sqlite build with sqlite wallets.

Tree-SHA512: 029ad21559dbc338b5f351d05113c51bc25bce830f4f4e18bcd82287bc528275347a60249da65b91d252632aeb70b25d057bd59c704bfcaafb9f790bc5b59762
2020-12-12 09:20:11 +01:00
pox
cc3044ccdb fix misleading comment about call to non-existing function 2020-12-12 07:01:38 +02:00
John Newbery
f6360088de [net processing] Clarify UpdatedBlockTip() 2020-12-11 10:40:19 +00:00
John Newbery
94d2cc35be [net processing] Remove unnecesary nNewHeight variable in UpdatedBlockTip() 2020-12-11 10:35:32 +00:00
John Newbery
8b57013473 [net processing] Remove nStartingHeight check from block relay
nStartingHeight was introduced in commit 7a47324c7 (Bitcoin version
0.2.9, P2P version 209) with the comment "better prevention of inventory
relaying during initial download". At that time, there was no function
to determine whether the node was still in Initial Block Download, so to
prevent syncing nodes from relaying old blocks to their peers, a check
was added to never relay a block to a peer where the height was lower
than 2000 less than the peer's best block. That check was updated
several times in later commits to ensure that we weren't relaying blocks
before the latest checkpoint if the peer didn't provide a
startingheight. The checkpoint comparison was changed to compare with an
estimate of the highest block in commit eae82d8e.

In commit 202e0194, all block relay was gated on being out of Initial
Block Download. In commit 0278fb5f, the comparison to nBlockEstimate was
removed since "we already checked IsIBD()".

We can remove the check against nStartingHeight entirely. If the node is
out of Initial Block Download, then its tip height must have been within
24 hours of current time, so should not be more than ~144 blocks behind
the most work tip.
2020-12-11 10:08:37 +00:00
MarcoFalke
6a48063671
Merge #19858: Periodically make block-relay connections and sync headers
b3a515c0be Clarify comments around outbound peer eviction (Suhas Daftuar)
daffaf03fb Periodically make block-relay connections and sync headers (Suhas Daftuar)
3cc8a7a0f5 Use conn_type to identify block-relay peers, rather than m_tx_relay == nullptr (Suhas Daftuar)
91d61952a8 Simplify and clarify extra outbound peer counting (Suhas Daftuar)

Pull request description:

  To make eclipse attacks more difficult, regularly initiate outbound connections
  and stay connected long enough to sync headers and potentially learn of new
  blocks. If we learn a new block, rotate out an existing block-relay peer in
  favor of the new peer.

  This augments the existing outbound peer rotation that exists -- currently we
  make new full-relay connections when our tip is stale, which we disconnect
  after waiting a small time to see if we learn a new block.  As block-relay
  connections use minimal bandwidth, we can make these connections regularly and
  not just when our tip is stale.

  Like feeler connections, these connections are not aggressive; whenever our
  timer fires (once every 5 minutes on average), we'll try to initiate a new
  block-relay connection as described, but if we fail to connect we just wait for
  our timer to fire again before repeating with a new peer.

ACKs for top commit:
  ariard:
    Code Review ACK b3a515c, only change since last time is dropping a useless `cs_main` taking. I manually tested a previous version of the PR, and not substantial change has been introduced since then which would alter behavior IMO.
  jonatack:
    Tested ACK b3a515c0be over several weeks, though this change and behavior could benefit from test coverage and other follow-ups (refactoring, etc.) described in the review feedback. I did not verify the behavior of `m_start_extra_block_relay_peers` only being enabled after initial chain sync. Since my last review, one unneeded `cs_main` lock was removed.

Tree-SHA512: 75fc6f8e8003e88e93f86b845caf2d30b8b9c0dbb0a6b8aabe4e24ea4f6327351f736a068a3b2720a8a581b789942a3a47f921e2afdb47e88bc50d078aa37b6f
2020-12-11 10:20:01 +01:00
Hennadii Stepanov
e1e68b6305
test: Fix inconsistent lock order in wallet_tests/CreateWallet 2020-12-10 20:49:06 +02:00
Hennadii Stepanov
cb23fe01c1
[skip ci] sync: Check precondition in LEAVE_CRITICAL_SECTION() macro
This change reveals a bug in the wallet_tests/CreateWalletFromFile test,
that will be fixed in the following commit.
2020-12-10 20:46:39 +02:00
Hennadii Stepanov
c5e3e74f70
sync: Improve CheckLastCritical()
This commit adds actual lock stack logging if check fails.
2020-12-10 20:46:29 +02:00
Antoine Riard
a33442fdc7 Remove m_is_manual_connection from CNodeState
Currently, this member is only used to exclude MANUAL peers from discouragement
in MaybePunishNodeForBlock(). Manual connections are already protected in
MaybeDiscourageAndDisconnect(), independently from their network
processing behaviors.
2020-12-10 12:53:02 -05:00
Suhas Daftuar
b3a515c0be Clarify comments around outbound peer eviction 2020-12-10 08:46:51 -05:00
Suhas Daftuar
daffaf03fb Periodically make block-relay connections and sync headers
To make eclipse attacks more difficult, regularly initiate outbound connections
and stay connected long enough to sync headers and potentially learn of new
blocks. If we learn a new block, rotate out an existing block-relay peer in
favor of the new peer.

This augments the existing outbound peer rotation that exists -- currently we
make new full-relay connections when our tip is stale, which we disconnect
after waiting a small time to see if we learn a new block.  As block-relay
connections use minimal bandwidth, we can make these connections regularly and
not just when our tip is stale.

Like feeler connections, these connections are not aggressive; whenever our
timer fires (once every 5 minutes on average), we'll try to initiate a new
block-relay connection as described, but if we fail to connect we just wait for
our timer to fire again before repeating with a new peer.
2020-12-10 08:46:39 -05:00
Suhas Daftuar
3cc8a7a0f5 Use conn_type to identify block-relay peers, rather than m_tx_relay == nullptr 2020-12-10 08:41:57 -05:00
Suhas Daftuar
91d61952a8 Simplify and clarify extra outbound peer counting 2020-12-10 08:41:57 -05:00
Vasil Dimov
7fabe0f359
net: don't relay to the address' originator
For each address to be relayed we "randomly" pick 2 nodes to send the
address to (in `RelayAddress()`). However we do not take into
consideration that it does not make sense to relay the address back to
its originator (`CNode::PushAddress()` will do nothing in that case).

This means that if the originator is among the "randomly" picked nodes,
then we will relay to one node less than intended.

Fix this by skipping the originating node when choosing candidates to
relay to.
2020-12-10 14:41:41 +01:00
Wladimir J. van der Laan
dcff2ee1fb
Merge #20589: log: Clarify that failure to read/write fee_estimates.dat is non-fatal
fa0d8359b3 log: Clarify that failure to read fee_estimates.dat is non-fatal (MarcoFalke)
faefa5db5f log: Clarify that failure to write fee_estimates.dat is non-fatal (MarcoFalke)

Pull request description:

  two minor logging fixups

ACKs for top commit:
  practicalswift:
    ACK fa0d8359b3: patch looks correct
  laanwj:
    Code review ACK fa0d8359b3

Tree-SHA512: d1e7e595d3b4a5e497ee7ab70f3be5783dafec2726ef8e012db836c15e8e622022859a4472d6b516fe19d327737b25fdfb509cd9aeb022ca847b13c54e55800a
2020-12-10 12:00:18 +01:00
Wladimir J. van der Laan
eb53c03b36
Merge #20595: Improve heuristic hex transaction decoding
0f949cde3d Add regression test for incorrect decoding (Pieter Wuille)
39c42c4420 Improve heuristic hex transaction decoding (Pieter Wuille)

Pull request description:

  The current hex tx decoding logic will refuse to decode valid extended-encoded transactions if the result fails the heuristic sanity check, even when the legacy-encoding fails. Fix this.

  Fixes #20579

ACKs for top commit:
  achow101:
    Code review ACK 0f949cde3d
  jonatack:
    Tested ACK 0f949cde3d
  laanwj:
    Code review ACK 0f949cde3d

Tree-SHA512: bd6dc80d824eb9a87026a623be910cac92173f8ce1c8b040c2246348c3cf0c6d64bcc40127b859e5e4da1efe88cf02a6945f7ebb91079799395145cb09d9c7a5
2020-12-10 11:22:10 +01:00
MarcoFalke
fade6195b1
Move TX_MAX_STANDARD_VERSION to policy
Also remove extraneous whitespace, should be reviewed with --ignore-all-space
2020-12-10 11:12:08 +01:00
MarcoFalke
38176dc665
Merge #20573: wallet, bugfix: allow send with string fee_rate amounts
6fa72ceb80 test: add coverage for passing fee rate as a string (Jon Atack)
ce207d6b93 wallet, bugfix: allow send to take string fee rate values (Jon Atack)

Pull request description:

  RPC send currently only accepts fee rates as numbers, which is a user-facing bug. It should accept fee rates as an amount, e.g. a string or a number, as documented in its help and like sendtoaddress, sendmany, fundrawtransaction, walletcreatefundedpsbt, and bumpfee. Provide a fix and regression test coverage.

ACKs for top commit:
  MarcoFalke:
    review ACK 6fa72ceb80
  achow101:
    Code review ACK 6fa72ceb80
  promag:
    Code review ACK 6fa72ceb80.

Tree-SHA512: 735f9269cb1b81953764b5283449c0b154bd62de034225be5bcedc515c84faf767fe8fe0741008679fe412922c847b00d116cb11aab775236b779c847ba87167
2020-12-10 08:46:01 +01:00
MarcoFalke
22f13c1e08
Merge #19776: net, rpc: expose high bandwidth mode state via getpeerinfo
343dc4760f test: add test for high-bandwidth mode states in getpeerinfo (Sebastian Falbesoner)
dab6583307 doc: release note for new getpeerinfo fields "bip152_hb_{from,to}" (Sebastian Falbesoner)
a7ed00f8bb rpc: expose high-bandwidth mode states via getpeerinfo (Sebastian Falbesoner)
30bc8fab68 net: save high-bandwidth mode states in CNodeStats (Sebastian Falbesoner)

Pull request description:

  Fixes #19676, "_For every peer expose through getpeerinfo RPC whether or not we selected them as HB peers, and whether or not they selected us as HB peers._" See [BIP152](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki), in particular the [protocol flow diagram](https://github.com/bitcoin/bips/raw/master/bip-0152/protocol-flow.png).  The newly introduced states are changed on the following places in the code:
  * on reception of a `SENDCMPCT` message with valid version, the field `m_highbandwidth_from` is changed depending on the first integer parameter in the message (1=high bandwidth, 0=low bandwidth), i.e. it just mirrors the field `CNodeState.fPreferHeaderAndIDs`.
  * after adding a `SENDCMPCT` message to the send queue, the field `m_highbandwidth_to` is changed depending on how the first integer parameter is set (same as above)

  Note that after receiving `VERACK`, the node also sends `SENDCMPCT`, but that is only to announce the preferred version and never selects high-bandwidth mode, hence there is no need to change the state variables there, which are initialized to `false` anyways.

ACKs for top commit:
  naumenkogs:
    reACK 343dc4760f
  jonatack:
    re-ACK 343dc4760f per `git range-diff 7ea6499 4df1d12 343dc47`

Tree-SHA512: f4999e6a935266812c2259a9b5dc459710037d3c9e938006d282557cc225e56128f72965faffb207fc60c6531fab1206db976dd8729a69e8ca29d4835317b99f
2020-12-10 08:21:36 +01:00
MarcoFalke
f5b2ea3e59
Merge #20217: net: Remove g_relay_txes
34e33ab859 Remove g_relay_txes (John Newbery)
68334b3944 [net processing] Add m_ignores_incoming_txs to PeerManager and use internally (John Newbery)
4d510aa055 [init] Use MakeUnique<> to construct peerman (John Newbery)
f3f61d0eb9 [net processing] Add IgnoresIncomingTxs() function to PeerManager (John Newbery)
5805b8299f [net processing] Move PushNodeVersion into PeerManager (John Newbery)

Pull request description:

  `g_relay_txes` is only required inside net_processing and is set only once at startup. Instead of having a global, move it to be a const member of PeerManager.

  This requires moving `PushNodeVersion()` into `PeerManager`, which also allows us to remove the `connman` argument.

ACKs for top commit:
  narula:
    utACK 34e33ab859
  MarcoFalke:
    re-ACK 34e33ab85 💐

Tree-SHA512: 33f75b522e5f34b243731932eb96cd6c8ce9db69b5186395e3718858bc715cec1711a663c6afc5880462812cbc15040930e2dc648b2acad6bc6502ad1397c5e3
2020-12-10 07:29:12 +01:00
MarcoFalke
44444ba759
fuzz: Link all targets once 2020-12-10 07:15:42 +01:00
Andrew Chow
5d4597666d Rewrite OutputGroups to be clearer and to use scriptPubKeys
Rewrite OutputGroups so that the logic is easier to follow and
understand.

There is a slight behavior change as OutputGroups will be grouped by
scriptPubKey rather than CTxDestination as before. This should have no
effect on users as all addresses are a CTxDestination. However by using
scriptPubKeys, we can correctly group outputs which fall into the
NoDestination case. But we also shouldn't have any NoDestination
outputs.
2020-12-09 20:18:05 -05:00
Luke Dashjr
8775691383 Bugfix: GUI: Restore SendConfirmationDialog button default to "Yes"
The SendConfirmationDialog is used for bumping the fee, where "Send" doesn't really make sense
2020-12-09 22:53:03 +00:00
Wladimir J. van der Laan
0038ce9758
Merge #20603: build: Update crc32c subtree
90c0f267bd Squashed 'src/crc32c/' changes from 224988680f..b5ef9be675 (MarcoFalke)

Pull request description:

  Except for the ARM64 darwin fix this is just code-shuffling in files/functions we don't use

ACKs for top commit:
  jonasschnelli:
    Tested ACK fa7c8d136f - Tested this on an ARM Mac. Linking issue went away (successful depends compilation). Also tested that the ARM64 hardware acceleration code part was used.
  laanwj:
    Code review ACK fa7c8d136f

Tree-SHA512: 1fa156d72c75d22ead2677b165e566978331f795d52a637e478d83d1cf2adddd84eed259d617df6d11270af2e4e57ae6991aec3bc4c0bdf5dec959f44daa14eb
2020-12-09 21:37:23 +01:00
John Newbery
34e33ab859 Remove g_relay_txes
Also remove vestigial commend in init.cpp
2020-12-09 18:13:37 +00:00
John Newbery
68334b3944 [net processing] Add m_ignores_incoming_txs to PeerManager and use internally 2020-12-09 18:13:37 +00:00
John Newbery
4d510aa055 [init] Use MakeUnique<> to construct peerman 2020-12-09 18:10:38 +00:00
John Newbery
f3f61d0eb9 [net processing] Add IgnoresIncomingTxs() function to PeerManager 2020-12-09 18:10:38 +00:00
John Newbery
5805b8299f [net processing] Move PushNodeVersion into PeerManager 2020-12-09 18:09:42 +00:00
MarcoFalke
7212db4d2a
Merge #20602: util: Allow use of C++14 chrono literals
fa11110bff util: Allow use of C++14 chrono literals (MarcoFalke)

Pull request description:

  I think we should allow the use of chrono literals for new code to make it less verbose. Obviously old code can stay as-is.

  This patch pulls in the needed namespace and replaces some lines for illustrative purposes.

ACKs for top commit:
  vasild:
    ACK fa11110bff
  jonatack:
    ACK fa11110bff

Tree-SHA512: ee2b72c8f28dee07b33b9a8ee8f7c87c0bc43b05c56a17b786cf9803ef204c7628e01b02de1af1a4eb01f5cdf6fc336f69c2833e17acd606ebda20ac6917e6bb
2020-12-09 17:15:11 +01:00
Wladimir J. van der Laan
42ed7f51fa
Merge #20606: Remove unused bits from service flags enum
fa40168ab3 Remove unused bits from service flags enum (MarcoFalke)

Pull request description:

  Remove service bits that haven't been observed on the active network for years and won't ever be observed on the network with this meaning. Keeping this dead assignment in our source code forever doesn't add any value.

  I somehow forgot to do this in commit fa0d0ff6e1.

ACKs for top commit:
  laanwj:
    Code review ACK fa40168ab3
  practicalswift:
    cr ACK fa40168ab3
  fanquake:
    ACK fa40168ab3

Tree-SHA512: 376e5ac05940493cf2209fea60515c843e978c4b476f2524f6bf7a37a646d237c3ddcf6c0fa23641f9ba550f625609703d9b51b4be631a7f2a90e1092b557232
2020-12-09 16:37:56 +01:00
fanquake
795afe6e63
Merge #19910: net processing: Move peer_map to PeerManager
3025ca9e77 [net processing] Add RemovePeer() (John Newbery)
a20ab22786 [net processing] Make GetPeerRef const (John Newbery)
ed7e469cee [net_processing] Move peer_map to PeerManager (John Newbery)
a529fd3e3f [net processing] Move GetNodeStateStats into PeerManager (John Newbery)

Pull request description:

  This moves `g_peer_map` from a global in net_processing.cpp's unnamed namespace to being a member `m_peer_map` of `PeerManager`.

ACKs for top commit:
  theuni:
    Re-ACK 3025ca9e77.
  dongcarl:
    Re-ACK 3025ca9
  hebasto:
    re-ACK 3025ca9e77, since my [previous](https://github.com/bitcoin/bitcoin/pull/19910#pullrequestreview-545574237) review only reverted the change that introduced NRVO in `PeerManager::GetPeerRef`, and comments are fixed in the proper commits.

Tree-SHA512: 6369eb3c688ac5b84f89f7674115f78ff02edbed76063ac2ebb1759894c9e973883e10821a35dab92bd3d738280acc095bd5368f552a060b83cd309330387d47
2020-12-09 21:56:17 +08:00
MarcoFalke
a3586d5920
Merge #20323: tests: Create or use existing properly initialized NodeContexts
81137c60fe test: Add new ChainTestingSetup and use it (Carl Dong)
7e9e7fe567 qt/test: [FIX] Add forgotten Context setting in RPCNestedTests (Carl Dong)

Pull request description:

  This is part 1/n of the effort to [de-globalize `ChainstateManager`](https://github.com/bitcoin/bitcoin/pull/20158)

  Reviewers: Looking for tested/Code-Review/plain-ACKs

  ### Context

  In many of our tests, we manually instantiate `NodeContext`s or `ChainstateManager`s in the test code, which is error prone. Instead, we should create or use existing references because:
  1. Before we [de-globalize `ChainstateManager`](https://github.com/bitcoin/bitcoin/pull/20158), much of our code still acts on `g_chainman` (our global `ChainstateManager`), sometimes even when you're calling a method on a specific instance of `ChainstateManager`! This means that we may act on two instances of `ChainstateManager`, which is most likely not what we want.
  2. Using existing references (initialized by the `{Basic,}TestingSetup` constructors) means that you're acting on objects which are properly initialized, instead of "just initialized enough for this dang test to pass". Also, they're already there! It's free!
  3. By acting on the right object, we also allow the review-only assertions in future commits of [de-globalize `ChainstateManager`](https://github.com/bitcoin/bitcoin/pull/20158) to work and demonstrate correctness.

  Some more detailed debugging notes can be found in the first commit, reproduced below:
  ```
  Previously, the validation_chainstatemanager_tests test suite
  instantiated its own duplicate ChainstateManager on which tests were
  performed.

  This wasn't a problem for the specific actions performed in
  that suite. However, the existence of this duplicate ChainstateManager
  and the fact that many of our validation static functions reach for
  g_chainman, ::Chain(state|)Active means we may end up acting on two
  different CChainStates should we write more extensive tests in the
  future.

  This change adds a new ChainTestingSetup which performs all
  initialization previously done by TestingSetup except:

  1. Mempool sanity check frequency setting
  2. ChainState initialization
  3. Genesis Activation
  4. {Ban,Conn,Peer}Man initialization

  Means that we will no longer need to initialize a duplicate
  ChainstateManger in order to test the initialization codepaths of
  CChainState and ChainstateManager.

  Lastly, this change has the additional benefit of allowing for
  review-only assertions meant to show correctness to work in future work
  de-globalizing g_chainman.

  In the test chainstatemanager_rebalance_caches, an additional
  LoadGenesisBlock call is added as MaybeReblanaceCaches eventually calls
  FlushBlockFile, which tries to access vinfoBlockFile[nLastBlockFile],
  which is out of bounds when LoadGenesisBlock hasn't been called yet.

  -----

  Note for the future:

  In a previous version of this change, I put ChainTestingSetup between
  BasicTestingSetup and TestingSetup such that TestingSetup inherited from
  ChainTestingSetup.

  This was suboptimal, and showed how the class con/destructor inheritance
  structure we have for these TestingSetup classes is probably not the
  most suitable abstraction. In particular, for both TestingSetup and
  ChainTestingSetup, we need to stop the scheduler first before anything
  else. Otherwise classes depending on the scheduler may be referenced
  by the scheduler after said classes are freed. This means that there's
  no clear parallel between our teardown code and C++'s destructuring
  order for class hierarchies.

  Future work should strive to coalesce (as much as possible) test and
  non-test init codepaths and perhaps structure it in a more fail-proof
  way.
  ```

ACKs for top commit:
  MarcoFalke:
    ACK 81137c60fe looking excellent now 🐩
  jnewbery:
    ACK 81137c60fe
  ryanofsky:
    Code review ACK 81137c60fe. This change is simpler after the rebase because wallet & bench commits are dropped.

Tree-SHA512: a8d84f08f2db6428b0b88449bdc814c9db35b7559156d536dfebd3225c2707dba65959e76d2152e3f8c96eacbf1e0b0000f745edf1e196deddb97ff1ef360953
2020-12-09 10:22:10 +01:00
MarcoFalke
90ef622ab5
Merge #20564: Don't send 'sendaddrv2' to pre-70016 software, and send before 'verack'
1583498fb6 Send and require SENDADDRV2 before VERACK (Pieter Wuille)
c5a8919660 Don't send 'sendaddrv2' to pre-70016 software (Pieter Wuille)

Pull request description:

  BIP155 defines addrv2 and sendaddrv2 for all protocol versions, but some implementations reject messages they don't know. As a courtesy, don't send it to nodes with a version before 70016, as no software is known to support BIP155 that doesn't announce at least that protocol version number.

  Also move the sending of sendaddrv2 earlier (before sending verack), as proposed in https://github.com/bitcoin/bips/pull/1043. This has the side effect that local address broadcast of torv3 will work (as it'll only trigger after we know whether or not the peer supports addrv2).

ACKs for top commit:
  MarcoFalke:
    ACK 1583498fb6
  jnewbery:
    ACK 1583498fb6
  jonatack:
    ACK 1583498fb6
  vasild:
    ACK 1583498

Tree-SHA512: 3bd5833fa8c8567b6dedd99e4a9b6bb71c127aa66d5284b217503c86d597dc59aa7382c41f3a4bf561bb658b89db81d1a7703a700eef4ffc17cb916660e23a82
2020-12-09 07:01:57 +01:00
Carl Dong
81137c60fe test: Add new ChainTestingSetup and use it
Previously, the validation_chainstatemanager_tests test suite
instantiated its own duplicate ChainstateManager on which tests were
performed.

This wasn't a problem for the specific actions performed in
that suite. However, the existence of this duplicate ChainstateManager
and the fact that many of our validation static functions reach for
g_chainman, ::Chain(state|)Active means we may end up acting on two
different CChainStates should we write more extensive tests in the
future.

This change adds a new ChainTestingSetup which performs all
initialization previously done by TestingSetup except:

1. RPC command registration
2. ChainState initialization
3. Genesis Activation
4. {Ban,Conn,Peer}Man initialization

Means that we will no longer need to initialize a duplicate
ChainstateManger in order to test the initialization codepaths of
CChainState and ChainstateManager.

Lastly, this change has the additional benefit of allowing for
review-only assertions meant to show correctness to work in future work
de-globalizing g_chainman.

In the test chainstatemanager_rebalance_caches, an additional
LoadGenesisBlock call is added as MaybeReblanaceCaches eventually calls
FlushBlockFile, which tries to access vinfoBlockFile[nLastBlockFile],
which is out of bounds when LoadGenesisBlock hasn't been called yet.

-----

Note for the future:

The class con/destructor inheritance structure we have for these
TestingSetup classes is probably not the most suitable abstraction. In
particular, for both TestingSetup and ChainTestingSetup, we need to stop
the scheduler first before anything else. Otherwise classes depending on
the scheduler may be referenced by the scheduler after said classes are
freed. This means that there's no clear parallel between our teardown
code and C++'s destructuring order for class hierarchies.

Future work should strive to coalesce (as much as possible) test and
non-test init codepaths and perhaps structure it in a more fail-proof
way.
2020-12-08 15:00:25 -05:00
Carl Dong
7e9e7fe567 qt/test: [FIX] Add forgotten Context setting in RPCNestedTests 2020-12-08 14:22:43 -05:00
MarcoFalke
fa7c8d136f
build: Update crc32c subtree 2020-12-08 19:26:30 +01:00
Pieter Wuille
39c42c4420 Improve heuristic hex transaction decoding
Whenever both encodings are permitted, try both, and if only one succeeds,
return that one. Otherwise prefer the one for which the heuristic sanity
check passes. If that is the case for neither or for both, return the
extended-permitting deserialization.
2020-12-08 10:11:02 -08:00
MarcoFalke
e98d1d6740
Merge #19425: refactor: Get rid of more redundant chain methods
5baa88fd38 test: Remove no longer needed MakeChain calls (Russell Yanofsky)
6965f1352d refactor: Replace uses ChainActive() in interfaces/chain.cpp (Russell Yanofsky)
3fbbb9a640 refactor: Get rid of more redundant chain methods (Russell Yanofsky)

Pull request description:

  This just drops three interfaces::Chain methods replacing them with other calls.

  Motivation for removing these chain methods:

  - Need to get rid of findFirstBlockWithTimeAndHeight for #10102, which doesn't support overloaded methods
  - Followup from https://github.com/bitcoin/bitcoin/pull/16426#discussion_r412487403
  - phantomcircuit comments about findNextBlock test http://www.erisian.com.au/bitcoin-core-dev/log-2020-06-06.html#l-214

  Behavior is not changing in any way here. A TODO comment in ScanForWalletTransactions was removed, but just because it was invalid (see https://github.com/bitcoin/bitcoin/pull/19195#discussion_r448020762), not because it was implemented.

ACKs for top commit:
  MarcoFalke:
    re-ACK 5baa88fd38 🕶
  dongcarl:
    ACK 5baa88fd38

Tree-SHA512: d20a2a8cf8742e6100c6d3a4871ed67f184925712cf9e55d301abee60353bf3f74cd0d46a13be1715d1c2faef72102bb321654d08a128c2ef6880f72b72a6687
2020-12-08 18:49:02 +01:00
Pieter Wuille
1583498fb6 Send and require SENDADDRV2 before VERACK
See the corresponding BIP change: https://github.com/bitcoin/bips/pull/1043
2020-12-08 09:40:10 -08:00
MarcoFalke
fa40168ab3
Remove unused bits from service flags enum 2020-12-08 18:36:51 +01:00
MarcoFalke
90c0f267bd Squashed 'src/crc32c/' changes from 224988680f..b5ef9be675
b5ef9be675 Merge #1: Merge changes from upstream
9e7f512430 Merge remote-tracking branch 'origin/master' into bitcoin-fork
1f85030246 Add support for ARM64 darwin (#43)
3bb959c982 Remove unnecessary reinterpret_cast (#42)
2e97ab26b1 Fix (unused) ReadUint64LE for BE machines (#41)
47b40d2209 Bump dependencies. (#40)
ba74185625 Move CI to Visual Studio 2019.
efa301a7e5 Allow different C/C++ standards when this is used as a subproject.
cc6d71465e CMake: Use configure_package_config_file()

git-subtree-dir: src/crc32c
git-subtree-split: b5ef9be6755a2e61e2988bb238f13d1c0ee1fa0a
2020-12-08 17:08:07 +01:00
MarcoFalke
fa11110bff
util: Allow use of C++14 chrono literals 2020-12-08 16:47:36 +01:00
Russell Yanofsky
5baa88fd38 test: Remove no longer needed MakeChain calls
These calls are no longer needed after edc316020e
from #19098 which started instantiating BasicTestingSetup.m_node.chain

Patch from MarcoFalke <falke.marco@gmail.com> in
https://github.com/bitcoin/bitcoin/pull/19425#discussion_r526701954

Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2020-12-07 20:46:03 -05:00
Wladimir J. van der Laan
1a9fa4c5ba
Merge #20561: p2p: periodically clear m_addr_known
65273fa0e7 Clear m_addr_known before our periodic self-advertisement (Suhas Daftuar)

Pull request description:

  We use a rolling bloom filter to track which addresses we've previously sent a peer, but after #7125 we no longer clear it every day before our own announcement.  This looks to me like an oversight which has the effect of reducing the frequency with which we actually self-announce our own address, so this reintroduces resetting that filter.

ACKs for top commit:
  naumenkogs:
    ACK 65273fa0e7
  laanwj:
    Code review ACK 65273fa0e7
  sipa:
    utACK 65273fa0e7

Tree-SHA512: 602c155fb6d2249b054fcb6f1c0dd17143605ceb87132286bbd90babf26d258ff6c41f9925482c17e2be41805d33f9b83926cb447f394969ffecd4bccfa0a64f
2020-12-07 23:57:55 +01:00
Jon Atack
4b7b58b3fe
Update net_processing WTXID documentation per BIP339
as BIP339 currently states:

"The wtxidrelay message MUST be sent in response to a version
message from a peer whose protocol version is >= 70016 and
prior to sending a verack. A wtxidrelay message received after
a verack message MUST be ignored or treated as invalid."
2020-12-07 19:27:00 +01:00
Pieter Wuille
c5a8919660 Don't send 'sendaddrv2' to pre-70016 software 2020-12-07 09:13:57 -08:00
MarcoFalke
fac39c1983
wallet: document that tx in CreateTransaction is purely an out-param 2020-12-07 15:02:55 +01:00
MarcoFalke
faac31521b
Remove unused and confusing CTransaction constructor 2020-12-07 14:59:33 +01:00
MarcoFalke
fa0d8359b3
log: Clarify that failure to read fee_estimates.dat is non-fatal
An uppercase "ERROR" in the log might indicate a fatal error. Though,
all read-failures for fee_estimates.dat are non-fatal, so avoid the
"ERROR".

Before:
ERROR: CBlockPolicyEstimator::Read(): up-version (149900) fee estimate file

After:
CBlockPolicyEstimator::Read(): unable to read policy estimator data (non-fatal): up-version (149900) fee estimate file
2020-12-07 14:13:20 +01:00
Russell Yanofsky
6965f1352d refactor: Replace uses ChainActive() in interfaces/chain.cpp
Suggested https://github.com/bitcoin/bitcoin/pull/19425#discussion_r456236407
2020-12-07 09:09:53 -04:00
Wladimir J. van der Laan
5c4911e7e7
Merge #20568: doc: Use FeeModes doc helper in estimatesmartfee
fa8abdc995 rpc: Use FeeModes doc helper in estimatesmartfee (MarcoFalke)

Pull request description:

  Not sure why this doesn't use the doc helper, probably an oversight?

ACKs for top commit:
  laanwj:
    Code review ACK fa8abdc995

Tree-SHA512: 1f2dc8356e3476ddcf9cafafa7f9865ad95bed1e3067c0edab8e3c483e374bdbdbecc066167554b4a1b479e28f6a52c4ae6a75a70c67ee4e1ff4f3ba36b04001
2020-12-07 14:09:53 +01:00
Russell Yanofsky
3fbbb9a640 refactor: Get rid of more redundant chain methods
This just drops three interfaces::Chain methods replacing them with other calls.

Motivation for removing these chain methods:

- Need to get rid of findFirstBlockWithTimeAndHeight for #10102, which doesn't
  support overloaded methods
- Followup from
  https://github.com/bitcoin/bitcoin/pull/16426#discussion_r412487403
- phantomcircuit comments about findNextBlock test
  http://www.erisian.com.au/bitcoin-core-dev/log-2020-06-06.html#l-214

Behavior is not changing in any way here. A TODO comment in
ScanForWalletTransactions was removed, but just because it was invalid (see
https://github.com/bitcoin/bitcoin/pull/19195#discussion_r448020762), not
because it was implemented.
2020-12-07 09:09:53 -04:00
MarcoFalke
faefa5db5f
log: Clarify that failure to write fee_estimates.dat is non-fatal 2020-12-07 14:03:22 +01:00
MarcoFalke
03b1db6114
Merge #18766: Disable fee estimation in blocksonly mode (by removing the fee estimates global)
4e28753f60 feestimator: encapsulate estimation file logic (Antoine Poinsot)
e8ea6ad9c1 init: don't create a CBlockPolicyEstimator if we don't relay transactions (Antoine Poinsot)
86ff2cf202 Remove the remaining fee estimation globals (Antoine Poinsot)
03bfeee957 interface: remove unused estimateSmartFee method from node (Antoine Poinsot)

Pull request description:

  If the `blocksonly` mode is turned on after running with transaction
  relay enabled for a while, the fee estimation will serve outdated data
  to both the internal wallet and to external applications that might be
  feerate-sensitive and make use of `estimatesmartfee` (for example a
  Lightning Network node).

  This has already caused issues (for example https://github.com/bitcoin/bitcoin/issues/16840 (C-lightning), or https://github.com/lightningnetwork/lnd/issues/2562 (LND)) and it seems prudent to fail rather than to give inaccurate values.

  This fixes #16840, and closes #16890 which tried to fix the symptoms (RPC) but not the cause as mentioned by sdaftuar :
  > If this is a substantial problem, then I would think we should take action to protect our own wallet users as well (rather than hide the results of what our fee estimation would do!).

ACKs for top commit:
  MarcoFalke:
    re-ACK 4e28753f60 👋
  jnewbery:
    utACK 4e28753f60

Tree-SHA512: c869cf03b86d8194002970bbc84662dae76874967949b9be0d9a4511a1eabcb1627c38aca3154da9dcece1a4c49ec02bd4f9fcca2ec310986e07904559e63ba8
2020-12-07 12:59:48 +01:00
John Newbery
3025ca9e77 [net processing] Add RemovePeer()
This allows us to avoid repeated locking in FinalizeNode()
2020-12-07 11:59:24 +00:00
John Newbery
a20ab22786 [net processing] Make GetPeerRef const 2020-12-07 11:57:12 +00:00
John Newbery
ed7e469cee [net_processing] Move peer_map to PeerManager 2020-12-07 11:55:28 +00:00
MarcoFalke
00f4dcd552
Merge #20138: net: Assume that SetCommonVersion is called at most once per peer
fa0f415709 net: Assume that SetCommonVersion is called at most once per peer (MarcoFalke)

Pull request description:

  This restores the check removed in https://github.com/bitcoin/bitcoin/pull/17785#discussion_r503224381

  Instead of using `error`, which was used previously, it uses a newly introduced `Assume()`. `error` had several issues:
  * It logs unconditionally to the debug log
  * It doesn't abort the program when the error is hit in tests

ACKs for top commit:
  practicalswift:
    cr ACK fa0f415709: patch looks correct
  jnewbery:
    utACK fa0f415709

Tree-SHA512: cd7424a9485775e8c7093b725f8f52a90d47485185e79bac80f7810e450d0b3fda608d8805e9239094929f7bad2dca3fe772fb78ae606c2399d15405521e136b
2020-12-07 12:48:55 +01:00
William Casarin
22eb7930a6 tracing: add tracing framework
Signed-off-by: William Casarin <jb55@jb55.com>
2020-12-07 11:55:51 +01:00
Wladimir J. van der Laan
f3e17686b3
Merge #20468: build: warn when generating man pages for binaries built from a dirty branch
6690adba08 Warn when binaries are built from a dirty branch. (Tyler Chambers)

Pull request description:

  - Adjusted `--version` flag behavior in bitcoind and bitcoin-wallet to have the same behavior.
  - Added `--version` flag to bitcoin-tx to match.
  - Added functionality in gen-manpages.sh to error when attempting to generate man pages for binaries built from a dirty branch.

  mitigates problem with  issue #20412

ACKs for top commit:
  laanwj:
    Tested ACK 6690adba08

Tree-SHA512: b5ca509f1a57f66808c2bebc4b710ca00c6fec7b5ebd7eef58018e28e716f5f2358e36551b8a4df571bf3204baed565a297aeefb93990e7a99add502b97ee1b8
2020-12-07 10:51:45 +01:00
MarcoFalke
fa8abdc995
rpc: Use FeeModes doc helper in estimatesmartfee
Can be reviewed with --ignore-all-space
2020-12-07 09:28:47 +01:00
Jonas Schnelli
eab63b971d
Merge #19847: rpc, refactor: Avoid duplicate set lookup in gettxoutproof
52fc39917f rpc: Reject empty txids in gettxoutproof (João Barbosa)
73dc19a330 rpc, refactor: Avoid duplicate set lookup in gettxoutproof (João Barbosa)

Pull request description:

ACKs for top commit:
  jonasschnelli:
    code review ACK 52fc39917f

Tree-SHA512: 76b18e5235e8b2d394685515a4a60335666eeb0f6b31c1d397f7db2fbe681bc817b8cd3e8f6708b9dacd6113e4e1d94837072cae27834b8a1a22d2717db8191e
2020-12-07 09:17:08 +01:00
MarcoFalke
1a04f45fe9
Merge #19832: p2p: Put disconnecting logs into BCLog::NET category
1816327e53 p2p: Put disconnecting logs into BCLog::NET category (Hennadii Stepanov)

Pull request description:

  It's too noisy:
  ```
  $ cat debug.log | wc -l
  28529
  $ cat debug.log | grep "Disconnecting and discouraging peer" | wc -l
  10177
  ```

ACKs for top commit:
  MarcoFalke:
     noban, addnode and local peers are still unconditionally logged (as they should), but this one can go into a category, so cr-ACK 1816327e53
  practicalswift:
    ACK 1816327e53 for the reasons MarcoFalke gave above.
  ajtowns:
    ACK 1816327e53

Tree-SHA512: c312c1009090840659b2cb1364d8ad9b6ab8e742fc462aef169996d93c76c248507639a00257ed9d73a6916c01176b1793491b2305e92fdded5f9de0935b6ba6
2020-12-07 09:07:57 +01:00
practicalswift
31b136e580 Don't declare de facto const reference variables as non-const 2020-12-06 18:44:31 +00:00
practicalswift
1c65c075ee Don't declare de facto const member functions as non-const 2020-12-06 18:44:25 +00:00
practicalswift
5021810650 Make CanFlushToDisk a const member function 2020-12-06 00:54:10 +00:00
practicalswift
281cf99554 Do not run functions with necessary side-effects in assert() 2020-12-06 00:48:09 +00:00
practicalswift
12dcdaaa54 Don't make "in" parameters look like "out"/"in-out" parameters: pass by ref to const instead of ref to non-const 2020-12-06 00:22:40 +00:00
Jon Atack
ce207d6b93
wallet, bugfix: allow send to take string fee rate values 2020-12-04 22:12:36 +01:00
João Barbosa
52fc39917f rpc: Reject empty txids in gettxoutproof 2020-12-04 18:38:23 +00:00
João Barbosa
73dc19a330 rpc, refactor: Avoid duplicate set lookup in gettxoutproof 2020-12-04 18:38:23 +00:00
Carl Dong
3eb94ec81b
sync: Use decltype(auto) return type for WITH_LOCK
Now that we're using C++17, we can use the decltype(auto) return type
(available since C++14) for functions and lambda expressions.

As demonstrated in this commit, this can simplify cases where previously
the compiler failed to deduce the correct return type.

Just for reference, for the "assign to ref" cases fixed here, there are
3 possible solutions:

- Return a pointer and immediately deref as used before this commit
- Make sure the function/lambda returns declspec(auto) as used after
  this commit
- Class& i = WITH_LOCK(..., return std::ref(...));

-----

References:
1. https://en.cppreference.com/w/cpp/language/function#Return_type_deduction
2. https://en.cppreference.com/w/cpp/language/template_argument_deduction#Other_contexts
3. https://en.cppreference.com/w/cpp/language/auto
4. https://en.cppreference.com/w/cpp/language/decltype

Explanations:
1. https://stackoverflow.com/a/21369192
2. https://stackoverflow.com/a/21369170
3. Item 3 in Effective Modern C++ (Scott Meyers) via jnewbery
2020-12-04 12:23:05 -05:00
Russell Yanofsky
f3d870fc22 wallet: List all wallets in non-SQLite or non-BDB builds
This commit does not change behavior when bitcoin is built normally with both
the SQLite and BDB libraries. It just makes non-SQLite and non-BDB builds
more similar to the normal build. Specifically:

- It makes wallet directory lists always include all wallets so wallets don't
  appear missing depending on the build.

- It now triggers specific "Build does not support SQLite database format" and
  "Build does not support Berkeley DB database format" errors if a wallet can't
  be loaded instead of the more ambiguous and scary "Data is not in recognized
  format" error.
2020-12-04 11:03:28 -04:00
Russell Yanofsky
d70dc89e78 refactor: Consolidate redundant wallet database path and exists functions
No change in behavior. Just remove a little bit of code, reduce macro usage,
remove duplicative functions, and make BDB and SQLite implementations more
consistent with each other.
2020-12-04 11:03:28 -04:00
Russell Yanofsky
6a7a63644c refactor: Drop call to GetWalletEnv in wallet salvage code
No observable change in behavior. This just avoids a redundant environment
lookup. Motivation is to be able to simplify the GetWalletEnv implementation in
an upcoming commit.
2020-12-04 11:03:28 -04:00
Russell Yanofsky
6ee9cbdd18 refactor: Replace ListWalletDir() function with ListDatabases()
No change to behavior. This is just cleanup after previous MOVEONLY commit to
make db.h list function fit conventions of surrounding functions.
2020-12-04 11:03:28 -04:00