Commit Graph

521 Commits

Author SHA1 Message Date
Ava Chow
7640cfdd62
Merge bitcoin/bitcoin#31118: doc: replace -? with -h and -help
33a28e252a Change default help arg to `-help` and mention `-h` and `-?` as alternatives (Lőrinc)
f0130ab1a1 doc: replace `-?` with `-h` for bench_bitcoin help (Lőrinc)

Pull request description:

  The question mark is interpreted as a wildcard for any single character in Zsh (see https://www.techrepublic.com/article/globbing-wildcard-characters-with-zsh), so `bench_bitcoin -?` will not show the help message on systems using Zsh, such as macOS.

  Since `-h` provides equivalent help functionality (as defined in https://github.com/bitcoin/bitcoin/blob/master/src/common/args.cpp#L684-L693), the `benchmarking.md` documentation has been updated to ensure compatibility with macOS.

  ----

  ### -?
  > % cmake -B build -DBUILD_BENCH=ON && cmake --build build && build/src/bench/bench_bitcoin -?
  zsh: no matches found: -?

  ### -h
  > % cmake -B build -DBUILD_BENCH=ON && cmake --build build && build/src/bench/bench_bitcoin -h
  Usage:  bench_bitcoin [options]
  Options:
  ...

  ----

  Based on the comments the args help default was also changed to `-help`, mentioning `-h` and `-?` (instead of `-?` being the default)

ACKs for top commit:
  edilmedeiros:
    tACK 33a28e252a
  maflcko:
    lgtm ACK 33a28e252a
  achow101:
    ACK 33a28e252a
  rkrux:
    tACK 33a28e252a
  laanwj:
    Code review ACK 33a28e252a

Tree-SHA512: 8c6e27488462be9ba9186b34abe6249c1d93026b3963acc0f42c75496f39407563766ae518cf1839156039cc0047e29d91f70d191cfb97e0fbde85665e88c71e
2024-10-24 18:01:41 -04:00
merge-script
0e9f20625a
Merge bitcoin/bitcoin#31063: lint: commit-script-check.sh: echo to stderr
fac6cfe5ac lint: commit-script-check.sh: echo to stderr (MarcoFalke)

Pull request description:

  This makes it easier to redirect the produced `git diff` on failure. On success, it shouldn't hurt, because the same output is still present, just on stderr.

  Can be tested by introducing a fault in any scripted diff and then calling `commit-script-check.sh HEAD~..HEAD > any_file.txt`. Previously the file contained the full output, now it contains just the diff.

ACKs for top commit:
  TheCharlatan:
    ACK fac6cfe5ac

Tree-SHA512: b4dfad10a4a902729a7ad7533ed0ef86b9e79761083f2ec623d448a551462b268fe04bdba387ca62160dae9ef7b1781e005dec60f18b111d9bfa6b97357108e6
2024-10-21 10:46:46 +01:00
Lőrinc
33a28e252a Change default help arg to -help and mention -h and -? as alternatives
% build/src/bench/bench_bitcoin -h
[...]
  -help
       Print this help message and exit (also -h or -?)
2024-10-21 11:08:51 +02:00
Sebastian Falbesoner
882f736d0a doc: lint: correct outdated comment (s/Makefile.am/CMakeLists.txt/) 2024-10-10 12:25:14 +02:00
Sebastian Falbesoner
1786be7b4a scripted-diff: drop config/ subdir for bitcoin-config.h, rename to bitcoin-build-config.h
Follow-up for PR #30856, commit 0dd66251.

-BEGIN VERIFY SCRIPT-
sed -i "s|config/bitcoin-config\.h|bitcoin-build-config.h|g" $(git grep -l config/bitcoin-config\.h)
sed -i "s|bitcoin-config\.h|bitcoin-build-config.h|g" $(git grep -l "bitcoin-config\.h" ./src ./test ./cmake)
git mv ./cmake/bitcoin-config.h.in ./cmake/bitcoin-build-config.h.in
-END VERIFY SCRIPT-
2024-10-10 12:22:12 +02:00
MarcoFalke
fac6cfe5ac
lint: commit-script-check.sh: echo to stderr 2024-10-09 18:00:42 +02:00
MarcoFalke
fa2b7d8d6b
Remove redundant unterminated-logprintf tidy check 2024-10-01 11:34:22 +02:00
merge-script
2db926f49c
Merge bitcoin/bitcoin#30889: log: Use ConstevalFormatString
facbcd4cef log: Use ConstevalFormatString (MarcoFalke)
fae9b60c4f test: Use LogPrintStr to test m_log_sourcelocations (MarcoFalke)
fa39b1ca63 doc: move-only logging warning (MarcoFalke)

Pull request description:

  This changes all logging (including the wallet logging) to produce a
  `ConstevalFormatString` at compile time, so that the format string can be
  validated at compile-time.

  I tested with `clang` and found that the compiler will use less than 1% more of time and memory.

  When an error is found, the compile-time error depends on the compiler, but it may look similar to:

  ```
  src/util/string.h: In function ‘int main(int, char**)’:
  src/bitcoind.cpp:265:5:   in ‘constexpr’ expansion of ‘util::ConstevalFormatString<1>(((const char*)"Hi %s %s"))’
  src/util/string.h:38:98:   in ‘constexpr’ expansion of ‘util::ConstevalFormatString<1>::Detail_CheckNumFormatSpecifiers(std::basic_string_view<char>(((const char*)((util::ConstevalFormatString<1>*)this)->util::ConstevalFormatString<1>::fmt)))’
  src/util/string.h:78:34: error: expression ‘<throw-expression>’ is not a constant expression
     78 |         if (num_params != count) throw "Format specifier count must match the argument count!";
        |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ```

  This refactor does not change behavior of the compiled executables.

ACKs for top commit:
  hodlinator:
    re-ACK facbcd4cef
  l0rinc:
    ACK facbcd4cef
  ryanofsky:
    Code review ACK facbcd4cef
  pablomartin4btc:
    re-ACK facbcd4cef
  stickies-v:
    Approach ACK and code LGTM facbcd4cef modulo a `tinyformat::format_error` concern.

Tree-SHA512: 852f74d360897020f0d0f6e5064edc5e7f7dacc2bec1d5feff22c634a2fcd2eb535aa75be0b7191d9053728be6108484c737154b02d68ad3186a2e5544ba0db8
2024-09-19 12:17:14 +01:00
kevkevinpal
a9964c0444
doc: Updating docs from autotools to cmake
replaced --enable-debug with -DCMAKE_BUILD_TYPE=Debug in developer-notes
replaced --enable-multiprocess with -DWITH_MULTIPROCESS=ON
replaced --disable-zmq with -DWITH_ZMQ=OFF
2024-09-18 11:04:52 -04:00
MarcoFalke
facbcd4cef
log: Use ConstevalFormatString
This changes all logging (including the wallet logging) to produce a
ConstevalFormatString at compile time, so that the format string can be
validated at compile-time.

Also, while touching the wallet logging, avoid a copy of the template
Params by using const Params&.
2024-09-17 18:21:23 +02:00
MarcoFalke
fa5bc450d5
util: Use compile-time check for LogConnectFailure 2024-09-12 15:01:35 +02:00
MarcoFalke
fa7087b896
util: Use compile-time check for FatalErrorf 2024-09-12 15:01:20 +02:00
MarcoFalke
fae7b83eb5
lint: Remove forbidden functions from lint-format-strings.py
Given that all of them are forbidden by the
test/lint/lint-locale-dependence.py check, they can be removed.
2024-09-11 16:52:57 +02:00
merge-script
118b55c462
Merge bitcoin/bitcoin#30790: bench: Remove redundant logging benchmarks
fadbcd51fc bench: Remove redundant logging benchmarks (MarcoFalke)
fa8dd952e2 bench: Use LogInfo instead of the deprecated alias LogPrintf (MarcoFalke)

Pull request description:

  `LogPrint*ThreadNames` is redundant with `LogWith(out)ThreadNames`,
  because they all measure toggling the thread names (and check that it
  has no effect on performance).

  Fix it by removing the redundant ones. This also allows to drop a deprecated logging alias.

ACKs for top commit:
  stickies-v:
    ACK fadbcd51fc

Tree-SHA512: 4fe137f374aa4ee1aa0e1da4a1f9839c0e52c23dbb93198ecafee98de39d311cc47304bba4191f3807aa00c51b1eae543e3f270f03d341c84910e5e341a1d475
2024-09-06 09:50:19 +01:00
MarcoFalke
fa3a7ebe5b
lint: Check for release note snippets in the wrong folder 2024-09-05 13:09:34 +02:00
MarcoFalke
fadbcd51fc
bench: Remove redundant logging benchmarks
LogPrint*ThreadNames is redundant with LogWith(out)ThreadNames, because
they all measure toggling the thread names (and check that it has no
effect on performance).

This also allows to remove unused and deprecated macros.
2024-09-05 07:17:22 +02:00
Ava Chow
f640b323bd
Merge bitcoin/bitcoin#30723: lint: Speed up and fix flake8 checks
fafdb7df34 lint: Speed up flake8 checks (MarcoFalke)
faf17df7fb lint: Document missing py_lint dependency (MarcoFalke)
faebeb828f lint: Remove python whitespace and shadowing lint rules (MarcoFalke)
7777047835 lint: Remove python lint rules that are SyntaxError (MarcoFalke)
faaf3e53f0 test: [refactor] Fix F841 flake8 (MarcoFalke)
444421db69 test: [refactor] Fix E714 pycodestyle (MarcoFalke)

Pull request description:

  The checks have many issues:

  * Some checks that could in theory hide bugs are not applied -> Fix them and apply them going forward
  * Some checks are redundant Python 2 checks, or of low value -> Remove them
  * The checks are slow -> Speed them up from ~10 seconds to about ~20 milliseconds

ACKs for top commit:
  davidgumberg:
    review and tested reACK fafdb7df34
  kevkevinpal:
    ACK [fafdb7d](fafdb7df34)
  achow101:
    ACK fafdb7df34

Tree-SHA512: a0488b722cfaf7071bd6848cd3be002e0b6c38af80d8b5cbb08613c0b174ef63277289f960db8ac31adb09fe563a4973203b8fb10b83cbcfdc6f0ef39bd04410
2024-09-04 15:35:52 -04:00
MarcoFalke
fa09cb41f5
refactor: Remove unused LogPrint 2024-08-29 15:58:27 +02:00
MarcoFalke
3333415890
scripted-diff: LogPrint -> LogDebug
-BEGIN VERIFY SCRIPT-
 sed -i 's/\<LogPrint\>/LogDebug/g' $( git grep -l '\<LogPrint\>'  -- ./contrib/ ./src/ ./test/ ':(exclude)src/logging.h' )
-END VERIFY SCRIPT-
2024-08-29 13:49:57 +02:00
MarcoFalke
fafdb7df34
lint: Speed up flake8 checks
Previously they may have taken more than 10 seconds. Now they should
finish in less than one second.

This also allows to drop one dependency to be installed.
2024-08-29 07:03:42 +02:00
MarcoFalke
faf17df7fb
lint: Document missing py_lint dependency
Also, change the linter name, needed for the next commit.
2024-08-29 07:03:09 +02:00
MarcoFalke
faebeb828f
lint: Remove python whitespace and shadowing lint rules
The rules have many issues:

* Most are redundant, because Python already has a built-in
  IndentationError, a subclass of SyntaxError, to enforce whitespace.
* They are not enforced consistently anyway, see for examples [1][2]
  below.
* They are stylistic rules where the author intentionally formatted the
  code to be easier to read. Starting to enforce them now would make the
  code harder to read and create frustration in the future.

Fix all issues by removing them.

[1]:
test/functional/feature_cltv.py:63:35: E272 [*] Multiple spaces before keyword
   |
61 |         # | Script to prepend to scriptSig                  | nSequence  | nLockTime    |
62 |         # +-------------------------------------------------+------------+--------------+
63 |         [[OP_CHECKLOCKTIMEVERIFY],                            None,       None],
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E272

[2]:
contrib/asmap/asmap.py:395:13: E306 [*] Expected 1 blank line before a nested definition, found 0
    |
393 |             prefix.pop()
394 |             hole = not fill and (lhole or rhole)
395 |             def candidate(ctx: Optional[int], res0: Optional[list[ASNEntry]],
    |             ^^^ E306
2024-08-29 07:02:03 +02:00
MarcoFalke
7777047835
lint: Remove python lint rules that are SyntaxError
Any kind of syntax error is already reported, so there is no need to
enumerate all possible types of syntax errors of ancient versions of
Python 2 or 3.
2024-08-29 07:01:55 +02:00
Lőrinc
837fbca036 Update spelling.ignore-words
Removed ba, inflight, keypair and warmup.
Added incomin found in optionsdialog.ui:345 and re-use found in utxo_snapshot.cpp
2024-08-28 18:42:19 +02:00
Hennadii Stepanov
c360837ca5
cmake, lint: Adjust lint_includes_build_config 2024-08-16 21:19:12 +01:00
MarcoFalke
fac7b7ff7f
lint: Find function calls in default arguments 2024-08-09 08:11:16 +02:00
Lőrinc
bccfca0382 Fix lint-spelling warnings
These warnings were often polluting the CI output, e.g. https://github.com/bitcoin/bitcoin/pull/30499/checks?check_run_id=27745036545

> ./test/lint/lint-spelling.py

before the change:
```
doc/design/libraries.md💯 targetted ==> targeted
doc/developer-notes.md:495: dependant ==> dependent
src/bench/sign_transaction.cpp:49: hashIn ==> hashing, hash in
src/bitcoin-chainstate.cpp:213: hashIn ==> hashing, hash in
src/bitcoin-chainstate.cpp:213: hashIn ==> hashing, hash in
src/coins.cpp:24: viewIn ==> viewing, view in
src/coins.cpp:24: viewIn ==> viewing, view in
src/coins.cpp:29: viewIn ==> viewing, view in
src/coins.cpp:29: viewIn ==> viewing, view in
src/coins.h:44: outIn ==> outing, out in
src/coins.h:44: outIn ==> outing, out in
src/coins.h:45: outIn ==> outing, out in
src/coins.h:45: outIn ==> outing, out in
src/coins.h:215: viewIn ==> viewing, view in
src/coins.h:220: viewIn ==> viewing, view in
src/primitives/transaction.h:37: hashIn ==> hashing, hash in
src/primitives/transaction.h:37: hashIn ==> hashing, hash in
src/protocol.cpp:51: hashIn ==> hashing, hash in
src/protocol.cpp:51: hashIn ==> hashing, hash in
src/protocol.h:497: hashIn ==> hashing, hash in
src/qt/forms/optionsdialog.ui:344: incomin ==> incoming
src/qt/optionsdialog.cpp:445: proxys ==> proxies
src/rpc/mining.cpp:987: hashIn ==> hashing, hash in
src/rpc/mining.cpp:987: hashIn ==> hashing, hash in
src/script/interpreter.h:298: amountIn ==> amounting, amount in
src/script/interpreter.h:298: amountIn ==> amounting, amount in
src/script/interpreter.h:299: amountIn ==> amounting, amount in
src/script/interpreter.h:299: amountIn ==> amounting, amount in
src/script/sigcache.h:70: amountIn ==> amounting, amount in
src/script/sigcache.h:70: amountIn ==> amounting, amount in
src/signet.cpp:144: amountIn ==> amounting, amount in
src/test/fuzz/util/net.cpp:386: occured ==> occurred
src/test/fuzz/util/net.cpp:398: occured ==> occurred
src/util/vecdeque.h:79: deques ==> dequeues
src/util/vecdeque.h:160: deques ==> dequeues
src/util/vecdeque.h:184: deques ==> dequeues
src/util/vecdeque.h:194: deques ==> dequeues
src/validation.cpp:2130: re-declared ==> redeclared
src/validation.h:348: outIn ==> outing, out in
src/validation.h:349: outIn ==> outing, out in
test/functional/wallet_bumpfee.py:851: atleast ==> at least
```
2024-07-22 13:59:42 +02:00
MarcoFalke
fa6270737e
rpc: Use CHECK_NONFATAL over Assert 2024-07-12 09:27:41 +02:00
willcl-ark
dea7afd5e4
lint: remove unneeded trailing line fix 2024-07-03 11:14:01 +01:00
willcl-ark
4d942547a8
lint: ignore files ignored by git in mlc
Updating to MLC v0.18.0 includes a new feature which will ignore all
files ignored by git: `--gitignore`.

This helps avoid false-positives flagged by this linter in non-project
files, such as a developer might expect to have in their directory (e.g.
guix-builds, python venvs, etc.)
2024-07-03 09:46:15 +01:00
David Gumberg
0fcbfdb7ad Support running individual lint checks
Add support for passing `--lint=LINT_TO_RUN` to the lint runner and
add corresponding help message.
2024-06-04 09:13:44 -04:00
willcl-ark
4b7d984269
lint: add markdown hyperlink checker
This adds a markdown hyperlink check task to the lint test_runner. It
relies on having the [`mlc`](https://crates.io/crates/mlc) binary found
on $PATH, but will fail with `success` if the binary is not found.

`mlc` is also added to the ci/04_install.sh script run by the
containerfile.

Note that broken markdown hyperlinks will be detected in untracked
markdown files found in a dirty working directory (including e.g.
.venv).
2024-05-24 12:11:50 +01:00
merge-script
09d3ad2861
Merge bitcoin/bitcoin#30025: doc: fix broken relative md links
4b9f49da2b doc: fix broken relative md links (willcl-ark)

Pull request description:

  These relative links in our documentation are broken, fix them.

ACKs for top commit:
  maflcko:
    ACK 4b9f49da2b
  ryanofsky:
    Code review ACK 4b9f49da2b. Thanks for the updates!
  ismaelsadeeq:
    Re ACK 4b9f49da2b

Tree-SHA512: df4ef5ddece6c21125ce719ed6a4f69aba4f884c353ff7a8445ecb6438ed6bf0ff8268a1ae19cdd910adaadc189c6861c445b4d469f92ee81874d810dcbd0846
2024-05-08 11:54:46 +08:00
Ava Chow
8efd03ad04
Merge bitcoin/bitcoin#29494: build: Assume HAVE_CONFIG_H, Add IWYU pragma keep to bitcoin-config.h includes
fa09451f8e Add lint check for bitcoin-config.h include IWYU pragma (MarcoFalke)
dddd40ba82 scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes (MarcoFalke)

Pull request description:

  The `bitcoin-config.h` includes have issues:

  * The header is incompatible with iwyu, because symbols may be defined or not defined. So the `IWYU pragma: keep` is needed to keep the include when a symbol is not defined on a platform. Compare the previous discussion in https://github.com/bitcoin/bitcoin/pull/29408#issuecomment-1948959711
  * Guarding the includes by `HAVE_CONFIG_H` is verbose and brittle. Now that all build config dependencies have been removed from low level headers, the benefits are questionable, and the guard can be removed. The linter could also be tricked by guarding the include by `#if defined(HAVE_C0NFIG_H)` (`O` replaced by `0`). Compare the previous discussion in https://github.com/bitcoin/bitcoin/pull/29404#discussion_r1483189853 .

ACKs for top commit:
  achow101:
    ACK fa09451f8e
  TheCharlatan:
    ACK fa09451f8e
  hebasto:
    re-ACK fa09451f8e, only rebased since my recent [review](https://github.com/bitcoin/bitcoin/pull/29494#pullrequestreview-2028864535) (`timedata.cpp` removed in https://github.com/bitcoin/bitcoin/pull/29623).

Tree-SHA512: 47cb973f7f24bc625acc4e78683371863675d186780236d55d886cf4130e05a78bb04f1d731aae7088313b8e963a9677cc77cf518187dbd99d776f6421ca9b52
2024-05-07 14:14:03 -04:00
willcl-ark
4b9f49da2b
doc: fix broken relative md links
These relative links in our documentation are broken, fix them.
2024-05-03 16:07:12 +01:00
MarcoFalke
fa09451f8e
Add lint check for bitcoin-config.h include IWYU pragma
Also, remove the no longer needed, remaining definitions and checks of
HAVE_CONFIG_H.
2024-05-01 08:33:43 +02:00
MarcoFalke
fa9be2f795
lint: [doc] Clarify Windows line endings (CR LF) not to be used 2024-05-01 08:12:40 +02:00
Ava Chow
a9011781fc
Merge bitcoin/bitcoin#29689: lint: scripted-diff verification also requires GNU grep
3bf4f8db66 lint: scripted-diff verification also requires GNU grep (Sjors Provoost)

Pull request description:

  I noticed while trying to verify all historical `scripted-diff:` commits on macOS that some scripts require GNU sed.

  For example 0d6d2b650d uses `git grep --perl-regexp`.

ACKs for top commit:
  hernanmarino:
    cr ACK 3bf4f8db66
  maflcko:
    utACK 3bf4f8db66
  achow101:
    ACK 3bf4f8db66
  alfonsoromanz:
    Tested ACK 3bf4f8db66
  kristapsk:
    cr utACK 3bf4f8db66

Tree-SHA512: 09a060ab1bafad03df60d0f20c3dd1451850868dbd66ea38b18178b6230c1f06cf48622db82d9c51422d5689962ee0cd7aae0a31f84bd6d878215e6d73c1d47e
2024-04-25 12:34:50 -04:00
Hennadii Stepanov
13f5391bbb
Fix typos in subprocess.hpp 2024-04-11 14:03:37 +02:00
Sebastian Falbesoner
70434b1c44
external_signer: replace boost::process with cpp-subprocess
This primarily affects the `RunCommandParseJSON` utility function.
2024-03-27 14:16:37 +00:00
Hennadii Stepanov
cc8b9875b1
Add cpp-subprocess header-only library
Upstream repo: https://github.com/arun11299/cpp-subprocess
Commit: 4025693decacaceb9420efedbf4967a04cb028e7

The "Convenience Functions" section is unused in our codebase, so it has
been removed.
2024-03-27 14:16:32 +00:00
fanquake
28f2ca675f
Merge bitcoin/bitcoin#29479: test: Refactor subtree exclusion in lint tests
80fa7da21c test: Refactor subtree exclusion in lint tests (Brandon Odiwuor)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/17413

  Refactor subtree exclusion in lint tests to one place

  Second attempt after PR: https://github.com/bitcoin/bitcoin/pull/24435

ACKs for top commit:
  fjahr:
    re-ACK 80fa7da21c
  maflcko:
    lgtm ACK 80fa7da21c
  davidgumberg:
    ACK 80fa7da21c

Tree-SHA512: deff7457dd19ca5ea440d3d53feae047e8863b9ddeb6494a3c94605a5d16edc91db8f99a435b4fab2ef89aedee42439562be006da647fb85bbf3def903a3ce50
2024-03-27 11:40:18 +00:00
Brandon Odiwuor
80fa7da21c test: Refactor subtree exclusion in lint tests 2024-03-26 13:49:47 +03:00
MarcoFalke
fa1146d01b
lint: Fix COMMIT_RANGE issues 2024-03-21 20:15:08 +01:00
Sjors Provoost
3bf4f8db66
lint: scripted-diff verification also requires GNU grep 2024-03-21 13:12:19 +01:00
Fabian Jahr
fad7f42324
lint: Clarify lint runner rust dependency 2024-03-17 21:24:02 +01:00
MarcoFalke
5555395c15
lint: Use git --no-pager to print any output in one go 2024-03-13 17:07:15 +01:00
MarcoFalke
fa5729436c
lint: Fix lint-whitespace issues 2024-03-12 13:38:39 +01:00
naiyoma
53ffd5a410 docs: Fix broken reference to CI setup in test/lint/README.md 2024-03-05 17:00:08 +03:00
MarcoFalke
fa31908ea8
lint: Check for missing or redundant bitcoin-config.h includes 2024-02-20 15:03:23 +01:00