Commit graph

271 commits

Author SHA1 Message Date
MacroFake
9eaef10801
Merge bitcoin/bitcoin#25707: refactor: Make const references to avoid unnecessarily copying objects and enable two clang-tidy checks
ae7ae36d31 tidy: Enable two clang-tidy checks (Aurèle Oulès)
081b0e53e3 refactor: Make const refs vars where applicable (Aurèle Oulès)

Pull request description:

  I added const references to some variables to avoid unnecessarily copying objects.

  Also added two clang-tidy checks : [performance-for-range-copy](https://releases.llvm.org/11.1.0/tools/clang/tools/extra/docs/clang-tidy/checks/performance-for-range-copy.html) and [performance-unnecessary-copy-initialization](https://releases.llvm.org/12.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/performance-unnecessary-copy-initialization.html).

ACKs for top commit:
  vasild:
    ACK ae7ae36d31
  MarcoFalke:
    review ACK ae7ae36d31

Tree-SHA512: f6ac6b0cd0eee1e0c34d2f186484bc0f7ec6071451cccb33fa88a67d93d92b304e2fac378b88f087e94657745bca4e966dbc443759587400eb01b1f3061fde8c
2022-08-19 17:11:06 +02:00
fanquake
e09ad284c7
Merge bitcoin/bitcoin#24675: util: Use ArgsManager::GetPathArg more widely
b01f336708 util, refactor: Drop explicit conversion to fs::path (Hennadii Stepanov)
138c668e2b util, refactor: Use GetPathArg to read "-rpccookiefile" value (Hennadii Stepanov)
1276090705 util, refactor: Use GetPathArg to read "-conf" value (Hennadii Stepanov)

Pull request description:

  This PR is a continuation of bitcoin/bitcoin#24265 and bitcoin/bitcoin#24306.

  Now the following command-line arguments / configure options been read with the `GetPathArg` method:
  - `-conf`, also `includeconf` values been normalized
  - `-rpccookiefile`

ACKs for top commit:
  jarolrod:
    Code Review ACK b01f336708
  ryanofsky:
    Code review ACK b01f336708. Changes since last review: just dropping first commit (NormalizedPathFromString) as suggested

Tree-SHA512: 2d26d50b73542acdbcc63a32068977b2a49a017d31ca337471a0446f964eb0a6e3e4e3bb1ebe6771566a260f2cae3bc2ebe93b4b523183cea0d51768daab85c9
2022-08-04 16:58:01 +01:00
Aurèle Oulès
081b0e53e3 refactor: Make const refs vars where applicable
This avoids initializing variables with the copy-constructor of a
non-trivially copyable type.
2022-07-27 13:27:57 +02:00
fanquake
cc7b2fdd70
refactor: move compat.h into compat/ 2022-07-20 10:34:46 +01:00
fanquake
fbae8c59a2
compat: Consolidate mingw-w64 ASLR workaround for upstream libsecp changes
Achieve this by adding a MAIN_FUNCTION macro, consolidating the docs, and
introducing the macro across our distributed binaries.

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

https://packages.ubuntu.com/focal/binutils
2022-06-11 14:55:13 +01:00
Jon Atack
a17c5e96b6 Rename NetinfoRequestHandler::is_block_relay data member to is_tx_relay
and inverse its logic.

The naming is out of date and incorrect, as lack of request of tx relay does not
imply block relay, and a preference for tx relay doesn't imply that block relay
isn't happening.
2022-05-20 16:06:07 +02:00
Jon Atack
f0bb7db34c Fix frequent -netinfo JSON errors from null getpeerinfo#relaytxes
"error: JSON value is not a boolean as expected"

due to fRelayTxes/m_relay_txs being moved in PR 21160 from CNodeStats to
CNodeStateStats, which made getpeerinfo#relaytxes an optional field that
can return UniValue IsNull().
2022-05-20 14:33:12 +02:00
fanquake
6407c0e8a3
Merge bitcoin/bitcoin#25101: Add mockable clock type
fa305fd92c Add mockable clock type and TicksSinceEpoch helper (MarcoFalke)

Pull request description:

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

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

Tree-SHA512: da00200126833c1f55b1b1e68f596eab5c9254e82b188ad17779c08ffd685e198a7c5270791b4b69a858dc6ba4e051fe0c8b445d203d356d0c884f6365ee1cfe
2022-05-20 07:48:07 +01:00
fanquake
0de36941ec
Merge bitcoin/bitcoin#25153: scripted-diff: Use getInt<T> over get_int/get_int64
fa9af21878 scripted-diff: Use getInt<T> over get_int/get_int64 (MacroFake)

Pull request description:

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

ACKs for top commit:
  fanquake:
    ACK fa9af21878

Tree-SHA512: 284aa2527d0f663ca01550115025c9c64c787531d595f866c718f6ad09b9b0cac1e683a7d77f8009b75de990fd37166b44063ffa83fba8a04e9a31600b4c2725
2022-05-19 16:32:56 +01:00
MacroFake
7b3343f300
Merge bitcoin/bitcoin#25108: tidy: add modernize-use-default-member-init
ac6fbf2c83 tidy: use modernize-use-default-member-init (fanquake)
7aa40f5563 refactor: use C++11 default initializers (fanquake)

Pull request description:

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

Top commit has no ACKs.

Tree-SHA512: 536b406f20639f8c588fe9e96175ec60c7bb825506b2670b562370b2f572801c24203c483443be3c199e1b958c0765d4532e57c57a4e78689162a1dd422d844f
2022-05-18 19:19:55 +02:00
MacroFake
fa9af21878
scripted-diff: Use getInt<T> over get_int/get_int64
-BEGIN VERIFY SCRIPT-
 sed -i 's|\<get_int64\>|getInt<int64_t>|g' $(git grep -l get_int ':(exclude)src/univalue')
 sed -i 's|\<get_int\>|getInt<int>|g'       $(git grep -l get_int ':(exclude)src/univalue')
-END VERIFY SCRIPT-
2022-05-18 19:15:03 +02:00
MarcoFalke
fa305fd92c
Add mockable clock type and TicksSinceEpoch helper 2022-05-18 18:58:05 +02:00
fanquake
7aa40f5563
refactor: use C++11 default initializers 2022-05-17 17:18:58 +01:00
Jon Atack
3a998d2e37 Use steady_clock in ConnectAndCallRPC and inline time call in loop conditional
to avoid unnecessary invocations and an unneeded local variable allocation.
2022-05-17 16:56:50 +02:00
Jon Atack
3799d2dcdd Fix -rpcwait with -netinfo printing negative time durations
Fixes negative time duration values in the "send", "recv",
and "age" columns (potentially the "txn" and "blk" columns also)
for the first run of -rpcwait -netinfo after bitcoind startup.

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

The negative times will be larger/more apparent with a slower
CPU speed or e.g. higher checkblocks/checklevel config option
settings.
2022-05-17 16:18:22 +02:00
MacroFake
fab9e8a29c
Remove unused GetTimeSeconds 2022-05-11 16:39:23 +02:00
Hennadii Stepanov
1276090705
util, refactor: Use GetPathArg to read "-conf" value
Also "includeconf" values been normalized.
2022-04-21 12:55:31 +02:00
laanwj
3bbc46ddaf
Merge bitcoin/bitcoin#24632: add (none) in -getinfo Warnings: if no warning returned
0cea7b10f1 print `(none)` if no warnings in -getinfo (/dev/fd0)

Pull request description:

  Adds `(none)` in warnings when no warnings returned by -getinfo

  Reviewers can test this by making the following change in `/src/warnings.cpp`:

  ```diff
  bilingual_str GetWarnings(bool verbose)
  {
      bilingual_str warnings_concise;
      std::vector<bilingual_str> warnings_verbose;

      LOCK(g_warnings_mutex);

      // Pre-release build warning
      if (!CLIENT_VERSION_IS_RELEASE) {
  -        warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");;
  +        warnings_concise = _("");;
  ```

  Before this pull request:

  ```
  $ bitcoin-cli -getinfo
  Chain: regtest
  Blocks: 0
  Headers: 0
  Verification progress: 100.0000%
  Difficulty: 4.656542373906925e-10

  Network: in 0, out 0, total 0
  Version: 239900
  Time offset (s): 0
  Proxies: n/a
  Min tx relay fee rate (BTC/kvB): 0.00001000

  Warnings:
  ```

  After this pull request:

  ```diff
  $ bitcoin-cli -getinfo
  Chain: regtest
  Blocks: 0
  Headers: 0
  Verification progress: 100.0000%
  Difficulty: 4.656542373906925e-10

  Network: in 0, out 0, total 0
  Version: 239900
  Time offset (s): 0
  Proxies: n/a
  Min tx relay fee rate (BTC/kvB): 0.00001000

  Warnings: (none)
  ```

ACKs for top commit:
  jonatack:
    ACK 0cea7b10f1
  laanwj:
    Tested ACK 0cea7b10f1

Tree-SHA512: a12499d11ff84bc954db354f968eb1f5ee4999d8b80581fe0bdf604732b2e2f608cb5c35c4ca8cb5a430f3991954a6207f0758302618662e6b9505044cf2dc95
2022-04-13 21:49:22 +02:00
/dev/fd0
0cea7b10f1 print (none) if no warnings in -getinfo 2022-04-08 20:33:07 +05:30
fanquake
0598f36852
refactor: account for requiring libevent 2.1.8+ 2022-03-30 14:00:12 +02:00
fanquake
2618fb8d15
Output license info when binaries are passed -version
Consolidate to outputting the licensing info when we pass -version to a binary,
i.e bitcoind -version:
```bash
itcoin Core version v22.99.0-fc1f355913f6-dirty
Copyright (C) 2009-2022 The Bitcoin Core developers

Please contribute if you find Bitcoin Core useful. Visit
<https://bitcoincore.org/> for further information about the software.
The source code is available from <https://github.com/bitcoin/bitcoin>.

This is experimental software.
Distributed under the MIT software license, see the accompanying file COPYING
or <https://opensource.org/licenses/MIT>
```
2022-02-22 15:36:19 +00:00
Jon Atack
ce690847b6
cli: describe quality/recency filtering in -addrinfo
Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2022-02-21 14:16:48 +01:00
MarcoFalke
fa30e62cc6
doc: Rework generate* doc
Can be reviewed with --word-diff-regex=. --ignore-all-space
2022-02-21 11:02:20 +01:00
Jon Atack
a4da16fbd4
Improve -netinfo help based on feedback from users and devs
- clarify that the peer counts table is of reachable networks

- a few other clarifications
2022-02-16 18:38:37 +01:00
Hennadii Stepanov
f47dda2c58
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-

Commits of previous years:
* 2020: fa0074e2d8
* 2019: aaaaad6ac9
2021-12-30 19:36:57 +02:00
Jon Atack
7b6528746a
cli: hoist networks class data members to a constant 2021-11-11 13:14:01 +01:00
Jon Atack
5bd40a3e84
cli: add cjdns network to -addrinfo and -netinfo 2021-11-11 13:13:59 +01:00
Russell Yanofsky
c5d7e34bd9 scripted-diff: disable unimplemented ArgsManager BOOL/INT/STRING flags
This commit does not change behavior in any way. See previous commit for
complete rationale, but these flags are being disabled because they
aren't implemented and will otherwise break backwards compatibility when
they are implemented.

-BEGIN VERIFY SCRIPT-
sed -i 's:\(ALLOW_.*\)   \(//!< unimplemented\):// \1\2:' src/util/system.h
sed -i '/DISALLOW_NEGATION.*scripted-diff/d' src/util/system.cpp
git grep -l 'ArgsManager::ALLOW_\(INT\|STRING\)'  | xargs sed -i 's/ArgsManager::ALLOW_\(INT\|STRING\)/ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION/g'
git grep -l 'ALLOW_BOOL' -- ':!src/util/system.h' | xargs sed -i 's/ALLOW_BOOL/ALLOW_ANY/g'
-END VERIFY SCRIPT-
2021-10-25 10:44:17 -04:00
Jon Atack
96f469f91b
netinfo: print peer counts for all reachable networks
instead of only for networks we have peer connections to.

Users reported the previous behavior caused confusion,
as no column was printed when a network was reachable
but no peers were connected. Users expected a column
to be printed with 0 peers. This commit aligns
behavior with that expectation.
2021-10-20 15:52:54 +02:00
Russell Yanofsky
6544ea5035 refactor: Block unsafe fs::path std::string conversion calls
There is no change in behavior. This just helps prepare for the
transition from boost::filesystem to std::filesystem by avoiding calls
to methods which will be unsafe after the transaction to std::filesystem
to due lack of a boost::filesystem::path::imbue equivalent and inability
to set a predictable locale.

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Co-authored-by: Kiminuo <kiminuo@protonmail.com>
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2021-10-05 11:10:47 -04:00
Russell Yanofsky
93b9800fec scripted-diff: Rename overloaded int GetArg to GetIntArg
Improve readability of code, simplify future scripted diff cleanup PRs, and be
more consistent with naming for GetBoolArg.

This will also be useful for replacing runtime settings type checking
with compile time checking.

-BEGIN VERIFY SCRIPT-
git grep -l GetArg | xargs sed -i 's/GetArg(\([^)]*\( [0-9]\+\|-1\|port\|BaseParams().RPCPort()\|Params().GetDefaultPort()\|_TIMEOUT\|Height\|_WORKQUEUE\|_THREADS\|_CONNECTIONS\|LIMIT\|SigOp\|Bytes\|_VERSION\|_AGE\|_CHECKS\|Checks() ? 1 : 0\|_BANTIME\|Cache\|BLOCKS\|LEVEL\|Weight\|Version\|BUFFER\|TARGET\|WEIGHT\|TXN\|TRANSACTIONS\|ADJUSTMENT\|i64\|Size\|nDefault\|_EXPIRY\|HEIGHT\|SIZE\|SNDHWM\|_TIME_MS\)\))/GetIntArg(\1)/g'
-END VERIFY SCRIPT-

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2021-09-27 06:57:20 -04:00
klementtan
7c3712fa32
cli: Display all proxies in -getinfo 2021-09-20 18:52:04 +08:00
W. J. van der Laan
0de84b7328
Merge bitcoin/bitcoin#22544: cli -addrinfo: drop torv2; torv3 becomes onion per GetNetworkName()
49d503aefa doc: update -addrinfo in release-notes.md and tor.md (Jon Atack)
75ea9ecf11 cli -addrinfo: drop torv2, torv3 becomes onion per GetNetworkName() (Jon Atack)

Pull request description:

  #22050 removed torv2 support from 22.0. For 23.0 and subsequent releases, we can probably remove torv2 from -addrinfo.

  before
  ```
    "addresses_known": {
      "ipv4": 58305,
      "ipv6": 5138,
      "torv2": 0,
      "torv3": 5441,
      "i2p": 14,
      "total": 68898
    }
  ```
  after
  ```
    "addresses_known": {
      "ipv4": 58305,
      "ipv6": 5138,
      "onion": 5441,
      "i2p": 14,
      "total": 68898
    }
  ```
  Per the naming of `netbase.{h, cpp}::GetNetworkName()`, torv3 becomes onion, which is what is printed in the output of getpeerinfo, getnetworkinfo and getnodeaddresses.

ACKs for top commit:
  practicalswift:
    cr ACK 49d503aefa
  Zero-1729:
    tACK 49d503aefa 🧉
  klementtan:
    Code review and tested ACK 49d503aefa

Tree-SHA512: bca52520d8b12c26f1c329d661b9e22c567954ed2af7d2a16d7669eae1a221eada20944f8b2f4e78e31a7190d5f3d3fbfd37509e5edf2d9a3747a0a8f4e375bb
2021-09-16 18:44:20 +02:00
fanquake
6045a14642
util: remove libevent <= 2.0.18 back-compat code
Now that we require libevent >=2.0.21, remove backwards compatibility
code for older versions.
2021-09-09 21:37:42 +08:00
Jon Atack
e952d7557e
netinfo: clarify client and server versions in header 2021-09-05 12:44:16 +02:00
W. J. van der Laan
a70768d159
Merge bitcoin/bitcoin#22501: netinfo: display addr_{processed, rate_limited, relay_enabled} and relaytxes data
218862a018 Display peers in -netinfo that we don't relay addresses to (Jon Atack)
3834e23b25 Display peers in -netinfo that request we not relay transactions (Jon Atack)
0a9ee3a2c7 Simplify a few conditionals in -netinfo (Jon Atack)
5eeea8e257 Add addr_processed and addr_rate_limited stats to -netinfo (Jon Atack)

Pull request description:

  Update CLI -netinfo to display the getpeerinfo `addr_processed`, `addr_rate_limited`, `addr_relay_enabled` and `relaytxes` data with auto-adjusting column widths.

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

    txn      Time since last novel transaction received from the peer and accepted into our mempool, in minutes
             "*" - the peer requested we not relay transactions to it (relaytxes is false)

    addrp    Total number of addresses processed, excluding those dropped due to rate limiting
             "." - we do not relay addresses to this peer (addr_relay_enabled is false)

    addrl    Total number of addresses dropped due to rate limiting
  ```

  ![Screenshot from 2021-08-22 14-31-40](https://user-images.githubusercontent.com/2415484/130355514-f6fd4f21-79d6-463b-9791-de01ebef20b1.png)

ACKs for top commit:
  0xB10C:
    Code review and tested ACK 218862a018
  Zero-1729:
    re-tACK 218862a018
  vasild:
    ACK 218862a018
  jarolrod:
    tACK 218862a018

Tree-SHA512: bb9da4bdd71859b234f6e4c2c46257a57ef0d0e0b363d2b8fded128bcaa28132f64a0a4651c622e1de1e3b7c05c7587a4369e9e79799895884fda9745c63409d
2021-09-02 17:12:48 +02:00
Kiminuo
aa5e7c9471 Fix typo in bitcoin-cli.cpp 2021-08-24 07:44:09 +02:00
Jon Atack
218862a018
Display peers in -netinfo that we don't relay addresses to
i.e. peers where getpeerinfo#addr_relay_enabled is false
2021-08-13 12:20:07 +02:00
Jon Atack
3834e23b25
Display peers in -netinfo that request we not relay transactions
i.e. peers where getpeerinfo#relaytxes is false
2021-08-13 12:19:54 +02:00
Jon Atack
0a9ee3a2c7
Simplify a few conditionals in -netinfo 2021-08-10 12:17:07 +02:00
Jon Atack
5eeea8e257
Add addr_processed and addr_rate_limited stats to -netinfo 2021-08-10 12:17:05 +02:00
klementtan
b851a92c06
cli: Add progress bar for -getinfo
Co-authored-by: jonatack <jon@atack.com>
2021-08-03 00:58:12 +08:00
Jon Atack
75ea9ecf11
cli -addrinfo: drop torv2, torv3 becomes onion per GetNetworkName() 2021-07-25 12:55:48 +02:00
Klement Tan
a37e29d32f
cli: Implement human readable -getinfo. 2021-07-21 19:27:04 +08:00
MarcoFalke
fa34cb8024
cli: Avoid truncating -rpcwaittimeout 2021-06-23 14:40:55 +02:00
Christian Decker
f76cb10d7d rpc: Prefix rpcwaittimeout error with details on its nature
As proposed by @laanwj the error message is now prefixed with the
"timeout on transient error:" prefix, to explain why the error is
suddenly considered terminal.
2021-06-03 11:23:22 +02:00
Christian Decker
a7fcc8eb59 rpc: Add a -rpcwaittimeout parameter to limit time spent waiting
Adds a new numeric `-rpcwaittimeout` that can be used to limit the
time we spend waiting on the RPC server to appear. This is used by
downstream projects to provide a bit of slack when `bitcoind`s RPC
interface is not available right away.
2021-06-03 11:23:22 +02:00
fanquake
feb72e5432
scripted-diff: rename GetSystemTimeInSeconds to GetTimeSeconds
-BEGIN VERIFY SCRIPT-
sed -i -e 's/GetSystemTimeInSeconds/GetTimeSeconds/g' $(git grep -l GetSystemTimeInSeconds src)
-END VERIFY SCRIPT-
2021-05-31 15:11:18 +08:00
Jon Atack
06c43201a7
cli: use C++17 std::array class template argument deduction (CTAD)
Credit to João Barbosa (promag) for the suggestions.

Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
2021-04-20 10:35:53 +02:00
Jon Atack
edf3167151
addrinfo: raise helpfully on server error or incompatible server version 2021-04-12 22:12:41 +02:00