aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml53
-rw-r--r--Makefile.am10
-rw-r--r--ci/README.md2
-rw-r--r--configure.ac2
-rwxr-xr-xcontrib/devtools/circular-dependencies.py5
-rwxr-xr-xcontrib/devtools/security-check.py3
-rwxr-xr-xcontrib/devtools/symbol-check.py7
-rwxr-xr-xcontrib/devtools/test-security-check.py3
-rwxr-xr-xcontrib/devtools/test-symbol-check.py7
-rwxr-xr-xcontrib/devtools/utils.py3
-rw-r--r--contrib/guix/INSTALL.md5
-rwxr-xr-xcontrib/macdeploy/macdeployqtplus6
-rwxr-xr-xcontrib/message-capture/message-capture-parser.py6
-rw-r--r--contrib/seeds/asmap.py81
-rwxr-xr-xcontrib/seeds/makeseeds.py16
-rwxr-xr-xcontrib/signet/miner2
-rwxr-xr-xcontrib/verify-binaries/verify.py26
-rw-r--r--depends/config.site.in1
-rw-r--r--depends/description.md5
-rw-r--r--doc/build-osx.md1
-rw-r--r--doc/build-windows.md7
-rw-r--r--src/addrman.h2
-rw-r--r--src/bench/checkblock.cpp4
-rw-r--r--src/bench/nanobench.h98
-rw-r--r--src/bench/pool.cpp3
-rw-r--r--src/bench/verify_script.cpp2
-rw-r--r--src/bitcoin-util.cpp1
-rw-r--r--src/blockencodings.cpp2
-rw-r--r--src/coins.cpp3
-rw-r--r--src/coins.h3
-rw-r--r--src/consensus/validation.h1
-rw-r--r--src/core_read.cpp1
-rw-r--r--src/external_signer.cpp4
-rw-r--r--src/hash.h1
-rw-r--r--src/index/blockfilterindex.cpp4
-rw-r--r--src/kernel/coinstats.cpp1
-rw-r--r--src/net.h1
-rw-r--r--src/net_processing.cpp4
-rw-r--r--src/node/blockstorage.cpp4
-rw-r--r--src/policy/policy.h2
-rw-r--r--src/primitives/transaction.cpp1
-rw-r--r--src/psbt.cpp1
-rw-r--r--src/psbt.h4
-rw-r--r--src/qt/transactiontablemodel.cpp2
-rw-r--r--src/rest.cpp1
-rw-r--r--src/rpc/blockchain.cpp4
-rw-r--r--src/rpc/rawtransaction.cpp1
-rw-r--r--src/rpc/server.cpp2
-rw-r--r--src/rpc/util.cpp2
-rw-r--r--src/rpc/util.h2
-rw-r--r--src/script/bitcoinconsensus.cpp1
-rw-r--r--src/script/interpreter.cpp2
-rw-r--r--src/script/sign.cpp2
-rw-r--r--src/serialize.h35
-rw-r--r--src/signet.cpp1
-rw-r--r--src/support/allocators/pool.h2
-rw-r--r--src/test/flatfile_tests.cpp2
-rw-r--r--src/test/fuzz/FuzzedDataProvider.h2
-rw-r--r--src/test/fuzz/autofile.cpp16
-rw-r--r--src/test/fuzz/buffered_file.cpp14
-rw-r--r--src/test/fuzz/load_external_block_file.cpp2
-rw-r--r--src/test/fuzz/miniscript.cpp2
-rw-r--r--src/test/fuzz/package_eval.cpp22
-rw-r--r--src/test/fuzz/policy_estimator.cpp5
-rw-r--r--src/test/fuzz/policy_estimator_io.cpp8
-rw-r--r--src/test/fuzz/util.h25
-rw-r--r--src/test/fuzz/validation_load_mempool.cpp2
-rw-r--r--src/test/miniscript_tests.cpp2
-rw-r--r--src/test/orphanage_tests.cpp2
-rw-r--r--src/test/pool_tests.cpp24
-rw-r--r--src/test/script_tests.cpp2
-rw-r--r--src/test/serialize_tests.cpp48
-rw-r--r--src/test/uint256_tests.cpp8
-rw-r--r--src/test/util/script.h12
-rw-r--r--src/test/util/setup_common.h1
-rw-r--r--src/test/versionbits_tests.cpp2
-rw-r--r--src/torcontrol.cpp2
-rw-r--r--src/txmempool.h2
-rw-r--r--src/undo.h1
-rw-r--r--src/wallet/feebumper.cpp2
-rw-r--r--src/wallet/rpc/spend.cpp1
-rw-r--r--src/wallet/spend.cpp6
-rw-r--r--src/wallet/wallet.h2
-rw-r--r--src/zmq/zmqpublishnotifier.cpp1
-rwxr-xr-xtest/functional/feature_assumeutxo.py4
-rwxr-xr-xtest/functional/interface_rest.py2
-rw-r--r--test/functional/test_framework/blockfilter.py2
-rw-r--r--test/functional/test_framework/script.py5
-rwxr-xr-xtest/functional/test_framework/test_framework.py3
-rw-r--r--test/functional/test_framework/util.py5
-rw-r--r--test/functional/test_framework/wallet.py3
-rwxr-xr-xtest/functional/wallet_avoidreuse.py2
-rwxr-xr-xtest/functional/wallet_fast_rescan.py4
-rwxr-xr-xtest/lint/lint-files.py4
-rwxr-xr-xtest/lint/lint-include-guards.py3
-rw-r--r--test/lint/spelling.ignore-words.txt1
96 files changed, 376 insertions, 335 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1cd40be541..1381d8a23e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -60,7 +60,9 @@ jobs:
# ancestors from the rev-list output as described in:
# https://git-scm.com/docs/git-rev-list
echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD ^$(git rev-list -n1 --merges HEAD)^@ | head -1)" >> "$GITHUB_ENV"
- - run: sudo apt install clang ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
+ - run: |
+ sudo apt-get update
+ sudo apt-get install clang ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
- name: Compile and run tests
run: |
# Run tests on commits after the last merge commit and before the PR head commit
@@ -136,6 +138,55 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
+ - name: Fix Visual Studio installation
+ # Avoid toolset ambiguity that MSVC can't handle.
+ run: |
+ Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
+ $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
+ $componentsToRemove= @(
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM64.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM64"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM64.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM64"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM64.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM64"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.x86.x64.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.37.17.7.x86.x64"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.ARM"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.ARM.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.ARM64"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.ARM64.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL.ARM"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL.ARM.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL.ARM64"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL.ARM64.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC.ARM"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC.ARM.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC.ARM64"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC.ARM64.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC.Spectre"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.x86.x64"
+ "Microsoft.VisualStudio.Component.VC.14.38.17.8.x86.x64.Spectre"
+ )
+ [string]$workloadArgs = $componentsToRemove | ForEach-Object {" --remove " + $_}
+ $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
+ # should be run twice
+ $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
+ $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
+
- name: Configure Developer Command Prompt for Microsoft Visual C++
# Using microsoft/setup-msbuild is not enough.
uses: ilammy/msvc-dev-cmd@v1
diff --git a/Makefile.am b/Makefile.am
index 7c3cd82e7f..c50421dfc3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,8 +14,6 @@ endif
.PHONY: deploy FORCE
.INTERMEDIATE: $(COVERAGE_INFO)
-export PYTHONPATH
-
if BUILD_BITCOIN_LIBS
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libbitcoinconsensus.pc
@@ -189,7 +187,7 @@ $(COV_TOOL_WRAPPER):
@chmod +x $(COV_TOOL_WRAPPER)
baseline.info: $(COV_TOOL_WRAPPER)
- $(LCOV) -c -i -d $(abs_builddir)/src -o $@
+ $(LCOV) $(LCOV_OPTS) -c -i -d $(abs_builddir)/src -o $@
baseline_filtered.info: baseline.info
$(abs_builddir)/contrib/filter-lcov.py $(LCOV_FILTER_PATTERN) $< $@
@@ -223,13 +221,13 @@ functional_test_filtered.info: functional_test.info
$(LCOV) -a $@ $(LCOV_OPTS) -o $@
fuzz_coverage.info: fuzz_filtered.info
- $(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a fuzz_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt
+ $(LCOV) $(LCOV_OPTS) -a baseline_filtered.info -a fuzz_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt
test_bitcoin_coverage.info: baseline_filtered.info test_bitcoin_filtered.info
- $(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a test_bitcoin_filtered.info -o $@
+ $(LCOV) $(LCOV_OPTS) -a baseline_filtered.info -a test_bitcoin_filtered.info -o $@
total_coverage.info: test_bitcoin_filtered.info functional_test_filtered.info
- $(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a test_bitcoin_filtered.info -a functional_test_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt
+ $(LCOV) $(LCOV_OPTS) -a baseline_filtered.info -a test_bitcoin_filtered.info -a functional_test_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt
fuzz.coverage/.dirstamp: fuzz_coverage.info
$(GENHTML) -s $(LCOV_OPTS) $< -o $(@D)
diff --git a/ci/README.md b/ci/README.md
index f89af329dd..7cf3b1f563 100644
--- a/ci/README.md
+++ b/ci/README.md
@@ -52,5 +52,5 @@ in order.
### Cache
In order to avoid rebuilding all dependencies for each build, the binaries are
-cached and re-used when possible. Changes in the dependency-generator will
+cached and reused when possible. Changes in the dependency-generator will
trigger cache-invalidation and rebuilds as necessary.
diff --git a/configure.ac b/configure.ac
index 5d26f49e8b..20992380d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -139,8 +139,6 @@ AC_PATH_TOOL([OBJCOPY], [objcopy])
AC_PATH_PROG([DOXYGEN], [doxygen])
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
-AC_ARG_VAR([PYTHONPATH], [Augments the default search path for python module files])
-
AC_ARG_ENABLE([wallet],
[AS_HELP_STRING([--disable-wallet],
[disable wallet (enabled by default)])],
diff --git a/contrib/devtools/circular-dependencies.py b/contrib/devtools/circular-dependencies.py
index b1d9f2b7db..b742a8cea6 100755
--- a/contrib/devtools/circular-dependencies.py
+++ b/contrib/devtools/circular-dependencies.py
@@ -5,7 +5,6 @@
import sys
import re
-from typing import Dict, List, Set
MAPPING = {
'core_read.cpp': 'core_io.cpp',
@@ -33,7 +32,7 @@ def module_name(path):
return None
files = dict()
-deps: Dict[str, Set[str]] = dict()
+deps: dict[str, set[str]] = dict()
RE = re.compile("^#include <(.*)>")
@@ -65,7 +64,7 @@ while True:
shortest_cycle = None
for module in sorted(deps.keys()):
# Build the transitive closure of dependencies of module
- closure: Dict[str, List[str]] = dict()
+ closure: dict[str, list[str]] = dict()
for dep in deps[module]:
closure[dep] = []
while True:
diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py
index f90fa5785f..590c2ed87d 100755
--- a/contrib/devtools/security-check.py
+++ b/contrib/devtools/security-check.py
@@ -8,7 +8,6 @@ Exit status will be 0 if successful, and the program will be silent.
Otherwise the exit status will be 1 and it will log which executables failed which checks.
'''
import sys
-from typing import List
import lief
@@ -255,7 +254,7 @@ if __name__ == '__main__':
retval = 1
continue
- failed: List[str] = []
+ failed: list[str] = []
for (name, func) in CHECKS[etype][arch]:
if not func(binary):
failed.append(name)
diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py
index a3d00bec95..e3e8e398c2 100755
--- a/contrib/devtools/symbol-check.py
+++ b/contrib/devtools/symbol-check.py
@@ -11,7 +11,6 @@ Example usage:
find ../path/to/binaries -type f -executable | xargs python3 contrib/devtools/symbol-check.py
'''
import sys
-from typing import List, Dict
import lief
@@ -53,7 +52,7 @@ IGNORE_EXPORTS = {
# Expected linker-loader names can be found here:
# https://sourceware.org/glibc/wiki/ABIList?action=recall&rev=16
-ELF_INTERPRETER_NAMES: Dict[lief.ELF.ARCH, Dict[lief.ENDIANNESS, str]] = {
+ELF_INTERPRETER_NAMES: dict[lief.ELF.ARCH, dict[lief.ENDIANNESS, str]] = {
lief.ELF.ARCH.x86_64: {
lief.ENDIANNESS.LITTLE: "/lib64/ld-linux-x86-64.so.2",
},
@@ -72,7 +71,7 @@ ELF_INTERPRETER_NAMES: Dict[lief.ELF.ARCH, Dict[lief.ENDIANNESS, str]] = {
},
}
-ELF_ABIS: Dict[lief.ELF.ARCH, Dict[lief.ENDIANNESS, List[int]]] = {
+ELF_ABIS: dict[lief.ELF.ARCH, dict[lief.ENDIANNESS, list[int]]] = {
lief.ELF.ARCH.x86_64: {
lief.ENDIANNESS.LITTLE: [3,2,0],
},
@@ -302,7 +301,7 @@ if __name__ == '__main__':
retval = 1
continue
- failed: List[str] = []
+ failed: list[str] = []
for (name, func) in CHECKS[etype]:
if not func(binary):
failed.append(name)
diff --git a/contrib/devtools/test-security-check.py b/contrib/devtools/test-security-check.py
index 92272cf8f9..64daabad4e 100755
--- a/contrib/devtools/test-security-check.py
+++ b/contrib/devtools/test-security-check.py
@@ -8,7 +8,6 @@ Test script for security-check.py
import lief
import os
import subprocess
-from typing import List
import unittest
from utils import determine_wellknown_cmd
@@ -34,7 +33,7 @@ def call_security_check(cc: str, source: str, executable: str, options) -> tuple
#
# See the definitions for ac_link in autoconf's lib/autoconf/c.m4 file for
# reference.
- env_flags: List[str] = []
+ env_flags: list[str] = []
for var in ['CFLAGS', 'CPPFLAGS', 'LDFLAGS']:
env_flags += filter(None, os.environ.get(var, '').split(' '))
diff --git a/contrib/devtools/test-symbol-check.py b/contrib/devtools/test-symbol-check.py
index fe8a99739f..0140decb25 100755
--- a/contrib/devtools/test-symbol-check.py
+++ b/contrib/devtools/test-symbol-check.py
@@ -7,18 +7,17 @@ Test script for symbol-check.py
'''
import os
import subprocess
-from typing import List
import unittest
from utils import determine_wellknown_cmd
-def call_symbol_check(cc: List[str], source, executable, options):
+def call_symbol_check(cc: list[str], source, executable, options):
# This should behave the same as AC_TRY_LINK, so arrange well-known flags
# in the same order as autoconf would.
#
# See the definitions for ac_link in autoconf's lib/autoconf/c.m4 file for
# reference.
- env_flags: List[str] = []
+ env_flags: list[str] = []
for var in ['CFLAGS', 'CPPFLAGS', 'LDFLAGS']:
env_flags += filter(None, os.environ.get(var, '').split(' '))
@@ -28,7 +27,7 @@ def call_symbol_check(cc: List[str], source, executable, options):
os.remove(executable)
return (p.returncode, p.stdout.rstrip())
-def get_machine(cc: List[str]):
+def get_machine(cc: list[str]):
p = subprocess.run([*cc,'-dumpmachine'], stdout=subprocess.PIPE, text=True)
return p.stdout.rstrip()
diff --git a/contrib/devtools/utils.py b/contrib/devtools/utils.py
index 68ad1c3aba..8b4c67c6c0 100755
--- a/contrib/devtools/utils.py
+++ b/contrib/devtools/utils.py
@@ -8,10 +8,9 @@ Common utility functions
import shutil
import sys
import os
-from typing import List
-def determine_wellknown_cmd(envvar, progname) -> List[str]:
+def determine_wellknown_cmd(envvar, progname) -> list[str]:
maybe_env = os.getenv(envvar)
maybe_which = shutil.which(progname)
if maybe_env:
diff --git a/contrib/guix/INSTALL.md b/contrib/guix/INSTALL.md
index 49e92acdf9..61310de724 100644
--- a/contrib/guix/INSTALL.md
+++ b/contrib/guix/INSTALL.md
@@ -389,10 +389,7 @@ git clone https://git.savannah.gnu.org/git/guix.git
cd guix
```
-You will likely want to build the latest release, however, if the latest release
-when you're reading this is still 1.3.0 then you may want to use 998eda30 instead
-to avoid the issues described in [#25099](
-https://github.com/bitcoin/bitcoin/pull/25099).
+You will likely want to build the latest release.
```
git branch -a -l 'origin/version-*' # check for the latest release
diff --git a/contrib/macdeploy/macdeployqtplus b/contrib/macdeploy/macdeployqtplus
index fa9b868349..4b1d72650d 100755
--- a/contrib/macdeploy/macdeployqtplus
+++ b/contrib/macdeploy/macdeployqtplus
@@ -20,7 +20,7 @@ import sys, re, os, platform, shutil, stat, subprocess, os.path
from argparse import ArgumentParser
from pathlib import Path
from subprocess import PIPE, run
-from typing import List, Optional
+from typing import Optional
# This is ported from the original macdeployqt with modifications
@@ -181,7 +181,7 @@ class DeploymentInfo(object):
return True
return False
-def getFrameworks(binaryPath: str, verbose: int) -> List[FrameworkInfo]:
+def getFrameworks(binaryPath: str, verbose: int) -> list[FrameworkInfo]:
if verbose:
print(f"Inspecting with otool: {binaryPath}")
otoolbin=os.getenv("OTOOL", "otool")
@@ -285,7 +285,7 @@ def copyFramework(framework: FrameworkInfo, path: str, verbose: int) -> Optional
return toPath
-def deployFrameworks(frameworks: List[FrameworkInfo], bundlePath: str, binaryPath: str, strip: bool, verbose: int, deploymentInfo: Optional[DeploymentInfo] = None) -> DeploymentInfo:
+def deployFrameworks(frameworks: list[FrameworkInfo], bundlePath: str, binaryPath: str, strip: bool, verbose: int, deploymentInfo: Optional[DeploymentInfo] = None) -> DeploymentInfo:
if deploymentInfo is None:
deploymentInfo = DeploymentInfo()
diff --git a/contrib/message-capture/message-capture-parser.py b/contrib/message-capture/message-capture-parser.py
index d6ddc1c149..0f409717d4 100755
--- a/contrib/message-capture/message-capture-parser.py
+++ b/contrib/message-capture/message-capture-parser.py
@@ -11,7 +11,7 @@ import sys
from io import BytesIO
import json
from pathlib import Path
-from typing import Any, List, Optional
+from typing import Any, Optional
sys.path.append(os.path.join(os.path.dirname(__file__), '../../test/functional'))
@@ -92,7 +92,7 @@ def to_jsonable(obj: Any) -> Any:
return obj
-def process_file(path: str, messages: List[Any], recv: bool, progress_bar: Optional[ProgressBar]) -> None:
+def process_file(path: str, messages: list[Any], recv: bool, progress_bar: Optional[ProgressBar]) -> None:
with open(path, 'rb') as f_in:
if progress_bar:
bytes_read = 0
@@ -188,7 +188,7 @@ def main():
output = Path.cwd() / Path(args.output) if args.output else False
use_progress_bar = (not args.no_progress_bar) and sys.stdout.isatty()
- messages = [] # type: List[Any]
+ messages = [] # type: list[Any]
if use_progress_bar:
total_size = sum(capture.stat().st_size for capture in capturepaths)
progress_bar = ProgressBar(total_size)
diff --git a/contrib/seeds/asmap.py b/contrib/seeds/asmap.py
index e28e5cf532..214805b5a5 100644
--- a/contrib/seeds/asmap.py
+++ b/contrib/seeds/asmap.py
@@ -10,11 +10,12 @@ import copy
import ipaddress
import random
import unittest
+from collections.abc import Callable, Iterable
from enum import Enum
from functools import total_ordering
-from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union, overload
+from typing import Optional, Union, overload
-def net_to_prefix(net: Union[ipaddress.IPv4Network,ipaddress.IPv6Network]) -> List[bool]:
+def net_to_prefix(net: Union[ipaddress.IPv4Network,ipaddress.IPv6Network]) -> list[bool]:
"""
Convert an IPv4 or IPv6 network to a prefix represented as a list of bits.
@@ -32,7 +33,7 @@ def net_to_prefix(net: Union[ipaddress.IPv4Network,ipaddress.IPv6Network]) -> Li
assert (netrange & ((1 << (128 - num_bits)) - 1)) == 0
return [((netrange >> (127 - i)) & 1) != 0 for i in range(num_bits)]
-def prefix_to_net(prefix: List[bool]) -> Union[ipaddress.IPv4Network,ipaddress.IPv6Network]:
+def prefix_to_net(prefix: list[bool]) -> Union[ipaddress.IPv4Network,ipaddress.IPv6Network]:
"""The reverse operation of net_to_prefix."""
# Convert to number
netrange = sum(b << (127 - i) for i, b in enumerate(prefix))
@@ -47,10 +48,10 @@ def prefix_to_net(prefix: List[bool]) -> Union[ipaddress.IPv4Network,ipaddress.I
return ipaddress.IPv6Network((netrange, num_bits), True)
# Shortcut for (prefix, ASN) entries.
-ASNEntry = Tuple[List[bool], int]
+ASNEntry = tuple[list[bool], int]
# Shortcut for (prefix, old ASN, new ASN) entries.
-ASNDiff = Tuple[List[bool], int, int]
+ASNDiff = tuple[list[bool], int, int]
class _VarLenCoder:
"""
@@ -75,7 +76,7 @@ class _VarLenCoder:
other classes start one past the last element of the class before it.
"""
- def __init__(self, minval: int, clsbits: List[int]):
+ def __init__(self, minval: int, clsbits: list[int]):
"""Construct a new _VarLenCoder."""
self._minval = minval
self._clsbits = clsbits
@@ -85,7 +86,7 @@ class _VarLenCoder:
"""Check whether value val is in the range this coder supports."""
return self._minval <= val <= self._maxval
- def encode(self, val: int, ret: List[int]) -> None:
+ def encode(self, val: int, ret: list[int]) -> None:
"""Append encoding of val onto integer list ret."""
assert self._minval <= val <= self._maxval
@@ -120,7 +121,7 @@ class _VarLenCoder:
break
return ret + bits
- def decode(self, stream, bitpos) -> Tuple[int,int]:
+ def decode(self, stream, bitpos) -> tuple[int,int]:
"""Decode a number starting at bitpos in stream, returning value and new bitpos."""
val = self._minval
bits = 0
@@ -281,11 +282,11 @@ class ASMap:
- mappings, represented by new trie nodes.
"""
- def update(self, prefix: List[bool], asn: int) -> None:
+ def update(self, prefix: list[bool], asn: int) -> None:
"""Update this ASMap object to map prefix to the specified asn."""
assert asn == 0 or _CODER_ASN.can_encode(asn)
- def recurse(node: List, offset: int) -> None:
+ def recurse(node: list, offset: int) -> None:
if offset == len(prefix):
# Reached the end of prefix; overwrite this node.
node.clear()
@@ -306,7 +307,7 @@ class ASMap:
node.append(oldasn)
recurse(self._trie, 0)
- def update_multi(self, entries: List[Tuple[List[bool], int]]) -> None:
+ def update_multi(self, entries: list[tuple[list[bool], int]]) -> None:
"""Apply multiple update operations, where longer prefixes take precedence."""
entries.sort(key=lambda entry: len(entry[0]))
for prefix, asn in entries:
@@ -314,7 +315,7 @@ class ASMap:
def _set_trie(self, trie) -> None:
"""Set trie directly. Internal use only."""
- def recurse(node: List) -> None:
+ def recurse(node: list) -> None:
if len(node) < 2:
return
recurse(node[0])
@@ -342,7 +343,7 @@ class ASMap:
for prefix, asn in sorted(entries, key=entry_key):
self.update(prefix, asn)
- def lookup(self, prefix: List[bool]) -> Optional[int]:
+ def lookup(self, prefix: list[bool]) -> Optional[int]:
"""Look up a prefix. Returns ASN, or 0 if unassigned, or None if indeterminate."""
node = self._trie
for bit in prefix:
@@ -353,11 +354,11 @@ class ASMap:
return node[0]
return None
- def _to_entries_flat(self, fill: bool = False) -> List[ASNEntry]:
+ def _to_entries_flat(self, fill: bool = False) -> list[ASNEntry]:
"""Convert an ASMap object to a list of non-overlapping (prefix, asn) objects."""
- prefix : List[bool] = []
+ prefix : list[bool] = []
- def recurse(node: List) -> List[ASNEntry]:
+ def recurse(node: list) -> list[ASNEntry]:
ret = []
if len(node) == 1:
if node[0] > 0:
@@ -375,24 +376,24 @@ class ASMap:
return ret
return recurse(self._trie)
- def _to_entries_minimal(self, fill: bool = False) -> List[ASNEntry]:
+ def _to_entries_minimal(self, fill: bool = False) -> list[ASNEntry]:
"""Convert a trie to a minimal list of ASNEntry objects, exploiting overlap."""
- prefix : List[bool] = []
+ prefix : list[bool] = []
- def recurse(node: List) -> (Tuple[Dict[Optional[int], List[ASNEntry]], bool]):
+ def recurse(node: list) -> (tuple[dict[Optional[int], list[ASNEntry]], bool]):
if len(node) == 1 and node[0] == 0:
return {None if fill else 0: []}, True
if len(node) == 1:
return {node[0]: [], None: [(list(prefix), node[0])]}, False
- ret: Dict[Optional[int], List[ASNEntry]] = {}
+ ret: dict[Optional[int], list[ASNEntry]] = {}
prefix.append(False)
left, lhole = recurse(node[0])
prefix[-1] = True
right, rhole = recurse(node[1])
prefix.pop()
hole = not fill and (lhole or rhole)
- def candidate(ctx: Optional[int], res0: Optional[List[ASNEntry]],
- res1: Optional[List[ASNEntry]]):
+ def candidate(ctx: Optional[int], res0: Optional[list[ASNEntry]],
+ res1: Optional[list[ASNEntry]]):
if res0 is not None and res1 is not None:
if ctx not in ret or len(res0) + len(res1) < len(ret[ctx]):
ret[ctx] = res0 + res1
@@ -417,7 +418,7 @@ class ASMap:
"""Convert this ASMap object to a string containing Python code constructing it."""
return f"ASMap({self._trie})"
- def to_entries(self, overlapping: bool = True, fill: bool = False) -> List[ASNEntry]:
+ def to_entries(self, overlapping: bool = True, fill: bool = False) -> list[ASNEntry]:
"""
Convert the mappings in this ASMap object to a list of ASNEntry objects.
@@ -448,7 +449,7 @@ class ASMap:
assert max_asn >= 1 or unassigned_prob == 1
assert _CODER_ASN.can_encode(max_asn)
assert 0.0 <= unassigned_prob <= 1.0
- trie: List = []
+ trie: list = []
leaves = [trie]
ret = ASMap()
for i in range(1, num_leaves):
@@ -472,12 +473,12 @@ class ASMap:
def _to_binnode(self, fill: bool = False) -> _BinNode:
"""Convert a trie to a _BinNode object."""
- def recurse(node: List) -> Tuple[Dict[Optional[int], _BinNode], bool]:
+ def recurse(node: list) -> tuple[dict[Optional[int], _BinNode], bool]:
if len(node) == 1 and node[0] == 0:
return {(None if fill else 0): _BinNode.make_end()}, True
if len(node) == 1:
return {None: _BinNode.make_leaf(node[0]), node[0]: _BinNode.make_end()}, False
- ret: Dict[Optional[int], _BinNode] = {}
+ ret: dict[Optional[int], _BinNode] = {}
left, lhole = recurse(node[0])
right, rhole = recurse(node[1])
hole = (lhole or rhole) and not fill
@@ -507,7 +508,7 @@ class ASMap:
@staticmethod
def _from_binnode(binnode: _BinNode) -> "ASMap":
"""Construct an ASMap object from a _BinNode. Internal use only."""
- def recurse(node: _BinNode, default: int) -> List:
+ def recurse(node: _BinNode, default: int) -> list:
if node.ins == _Instruction.RETURN:
return [node.arg1]
if node.ins == _Instruction.JUMP:
@@ -542,7 +543,7 @@ class ASMap:
Returns:
A bytes object with the encoding of this ASMap object.
"""
- bits: List[int] = []
+ bits: list[int] = []
def recurse(node: _BinNode) -> None:
_CODER_INS.encode(node.ins.value, bits)
@@ -582,11 +583,11 @@ class ASMap:
def from_binary(bindata: bytes) -> Optional["ASMap"]:
"""Decode an ASMap object from the provided binary encoding."""
- bits: List[int] = []
+ bits: list[int] = []
for byte in bindata:
bits.extend((byte >> i) & 1 for i in range(8))
- def recurse(bitpos: int) -> Tuple[_BinNode, int]:
+ def recurse(bitpos: int) -> tuple[_BinNode, int]:
insval, bitpos = _CODER_INS.decode(bits, bitpos)
ins = _Instruction(insval)
if ins == _Instruction.RETURN:
@@ -632,7 +633,7 @@ class ASMap:
def extends(self, req: "ASMap") -> bool:
"""Determine whether this matches req for all subranges where req is assigned."""
- def recurse(actual: List, require: List) -> bool:
+ def recurse(actual: list, require: list) -> bool:
if len(require) == 1 and require[0] == 0:
return True
if len(require) == 1:
@@ -646,20 +647,20 @@ class ASMap:
#pylint: disable=protected-access
return recurse(self._trie, req._trie)
- def diff(self, other: "ASMap") -> List[ASNDiff]:
+ def diff(self, other: "ASMap") -> list[ASNDiff]:
"""Compute the diff from self to other."""
- prefix: List[bool] = []
- ret: List[ASNDiff] = []
+ prefix: list[bool] = []
+ ret: list[ASNDiff] = []
- def recurse(old_node: List, new_node: List):
+ def recurse(old_node: list, new_node: list):
if len(old_node) == 1 and len(new_node) == 1:
if old_node[0] != new_node[0]:
ret.append((list(prefix), old_node[0], new_node[0]))
else:
- old_left: List = old_node if len(old_node) == 1 else old_node[0]
- old_right: List = old_node if len(old_node) == 1 else old_node[1]
- new_left: List = new_node if len(new_node) == 1 else new_node[0]
- new_right: List = new_node if len(new_node) == 1 else new_node[1]
+ old_left: list = old_node if len(old_node) == 1 else old_node[0]
+ old_right: list = old_node if len(old_node) == 1 else old_node[1]
+ new_left: list = new_node if len(new_node) == 1 else new_node[0]
+ new_right: list = new_node if len(new_node) == 1 else new_node[1]
prefix.append(False)
recurse(old_left, new_left)
prefix[-1] = True
@@ -760,7 +761,7 @@ class TestASMap(unittest.TestCase):
# It starts off being equal to asmap.
patched = copy.copy(asmap)
# Keep a list of patches performed.
- patches: List[ASNEntry] = []
+ patches: list[ASNEntry] = []
# Initially there cannot be any difference.
self.assertEqual(asmap.diff(patched), [])
# Make 5 patches, each building on top of the previous ones.
diff --git a/contrib/seeds/makeseeds.py b/contrib/seeds/makeseeds.py
index af408c2df5..f03c2ab5e8 100755
--- a/contrib/seeds/makeseeds.py
+++ b/contrib/seeds/makeseeds.py
@@ -11,7 +11,7 @@ import collections
import ipaddress
import re
import sys
-from typing import List, Dict, Union
+from typing import Union
from asmap import ASMap, net_to_prefix
@@ -117,14 +117,14 @@ def parseline(line: str) -> Union[dict, None]:
'sortkey': sortkey,
}
-def dedup(ips: List[Dict]) -> List[Dict]:
+def dedup(ips: list[dict]) -> list[dict]:
""" Remove duplicates from `ips` where multiple ips share address and port. """
d = {}
for ip in ips:
d[ip['ip'],ip['port']] = ip
return list(d.values())
-def filtermultiport(ips: List[Dict]) -> List[Dict]:
+def filtermultiport(ips: list[dict]) -> list[dict]:
""" Filter out hosts with more nodes per IP"""
hist = collections.defaultdict(list)
for ip in ips:
@@ -132,7 +132,7 @@ def filtermultiport(ips: List[Dict]) -> List[Dict]:
return [value[0] for (key,value) in list(hist.items()) if len(value)==1]
# Based on Greg Maxwell's seed_filter.py
-def filterbyasn(asmap: ASMap, ips: List[Dict], max_per_asn: Dict, max_per_net: int) -> List[Dict]:
+def filterbyasn(asmap: ASMap, ips: list[dict], max_per_asn: dict, max_per_net: int) -> list[dict]:
""" Prunes `ips` by
(a) trimming ips to have at most `max_per_net` ips from each net (e.g. ipv4, ipv6); and
(b) trimming ips to have at most `max_per_asn` ips from each asn in each net.
@@ -143,8 +143,8 @@ def filterbyasn(asmap: ASMap, ips: List[Dict], max_per_asn: Dict, max_per_net: i
# Filter IPv46 by ASN, and limit to max_per_net per network
result = []
- net_count: Dict[str, int] = collections.defaultdict(int)
- asn_count: Dict[int, int] = collections.defaultdict(int)
+ net_count: dict[str, int] = collections.defaultdict(int)
+ asn_count: dict[int, int] = collections.defaultdict(int)
for i, ip in enumerate(ips_ipv46):
if net_count[ip['net']] == max_per_net:
@@ -165,9 +165,9 @@ def filterbyasn(asmap: ASMap, ips: List[Dict], max_per_asn: Dict, max_per_net: i
result.extend(ips_onion[0:max_per_net])
return result
-def ip_stats(ips: List[Dict]) -> str:
+def ip_stats(ips: list[dict]) -> str:
""" Format and return pretty string from `ips`. """
- hist: Dict[str, int] = collections.defaultdict(int)
+ hist: dict[str, int] = collections.defaultdict(int)
for ip in ips:
if ip is not None:
hist[ip['net']] += 1
diff --git a/contrib/signet/miner b/contrib/signet/miner
index 61d9f62be7..e5daf9f993 100755
--- a/contrib/signet/miner
+++ b/contrib/signet/miner
@@ -30,7 +30,7 @@ logging.basicConfig(
SIGNET_HEADER = b"\xec\xc7\xda\xa2"
PSBT_SIGNET_BLOCK = b"\xfc\x06signetb" # proprietary PSBT global field holding the block being signed
-RE_MULTIMINER = re.compile("^(\d+)(-(\d+))?/(\d+)$")
+RE_MULTIMINER = re.compile(r"^(\d+)(-(\d+))?/(\d+)$")
def create_coinbase(height, value, spk):
cb = CTransaction()
diff --git a/contrib/verify-binaries/verify.py b/contrib/verify-binaries/verify.py
index d0749f503f..12e6e10d8a 100755
--- a/contrib/verify-binaries/verify.py
+++ b/contrib/verify-binaries/verify.py
@@ -122,7 +122,7 @@ def download_with_wget(remote_file, local_file):
return result.returncode == 0, result.stdout.decode().rstrip()
-def download_lines_with_urllib(url) -> t.Tuple[bool, t.List[str]]:
+def download_lines_with_urllib(url) -> tuple[bool, list[str]]:
"""Get (success, text lines of a file) over HTTP."""
try:
return (True, [
@@ -138,7 +138,7 @@ def verify_with_gpg(
filename,
signature_filename,
output_filename: t.Optional[str] = None
-) -> t.Tuple[int, str]:
+) -> tuple[int, str]:
with tempfile.NamedTemporaryFile() as status_file:
args = [
'gpg', '--yes', '--verify', '--verify-options', 'show-primary-uid-only', "--status-file", status_file.name,
@@ -177,12 +177,12 @@ class SigData:
def parse_gpg_result(
- output: t.List[str]
-) -> t.Tuple[t.List[SigData], t.List[SigData], t.List[SigData]]:
+ output: list[str]
+) -> tuple[list[SigData], list[SigData], list[SigData]]:
"""Returns good, unknown, and bad signatures from GPG stdout."""
- good_sigs: t.List[SigData] = []
- unknown_sigs: t.List[SigData] = []
- bad_sigs: t.List[SigData] = []
+ good_sigs: list[SigData] = []
+ unknown_sigs: list[SigData] = []
+ bad_sigs: list[SigData] = []
total_resolved_sigs = 0
# Ensure that all lines we match on include a prefix that prevents malicious input
@@ -265,7 +265,7 @@ def files_are_equal(filename1, filename2):
def get_files_from_hosts_and_compare(
- hosts: t.List[str], path: str, filename: str, require_all: bool = False
+ hosts: list[str], path: str, filename: str, require_all: bool = False
) -> ReturnCode:
"""
Retrieve the same file from a number of hosts and ensure they have the same contents.
@@ -326,7 +326,7 @@ def get_files_from_hosts_and_compare(
return ReturnCode.SUCCESS
-def check_multisig(sums_file: str, sigfilename: str, args: argparse.Namespace) -> t.Tuple[int, str, t.List[SigData], t.List[SigData], t.List[SigData]]:
+def check_multisig(sums_file: str, sigfilename: str, args: argparse.Namespace) -> tuple[int, str, list[SigData], list[SigData], list[SigData]]:
# check signature
#
# We don't write output to a file because this command will almost certainly
@@ -365,8 +365,8 @@ def prompt_yn(prompt) -> bool:
def verify_shasums_signature(
signature_file_path: str, sums_file_path: str, args: argparse.Namespace
-) -> t.Tuple[
- ReturnCode, t.List[SigData], t.List[SigData], t.List[SigData], t.List[SigData]
+) -> tuple[
+ ReturnCode, list[SigData], list[SigData], list[SigData], list[SigData]
]:
min_good_sigs = args.min_good_sigs
gpg_allowed_codes = [0, 2] # 2 is returned when untrusted signatures are present.
@@ -429,14 +429,14 @@ def verify_shasums_signature(
return (ReturnCode.SUCCESS, good_trusted, good_untrusted, unknown, bad)
-def parse_sums_file(sums_file_path: str, filename_filter: t.List[str]) -> t.List[t.List[str]]:
+def parse_sums_file(sums_file_path: str, filename_filter: list[str]) -> list[list[str]]:
# extract hashes/filenames of binaries to verify from hash file;
# each line has the following format: "<hash> <binary_filename>"
with open(sums_file_path, 'r', encoding='utf8') as hash_file:
return [line.split()[:2] for line in hash_file if len(filename_filter) == 0 or any(f in line for f in filename_filter)]
-def verify_binary_hashes(hashes_to_verify: t.List[t.List[str]]) -> t.Tuple[ReturnCode, t.Dict[str, str]]:
+def verify_binary_hashes(hashes_to_verify: list[list[str]]) -> tuple[ReturnCode, dict[str, str]]:
offending_files = []
files_to_hashes = {}
diff --git a/depends/config.site.in b/depends/config.site.in
index 05c2ccbac1..a6a5596bb8 100644
--- a/depends/config.site.in
+++ b/depends/config.site.in
@@ -102,7 +102,6 @@ fi
if test -n "@CXX@" -a -z "${CXX}"; then
CXX="@CXX@"
fi
-PYTHONPATH="${depends_prefix}/native/lib/python3/dist-packages${PYTHONPATH:+${PATH_SEPARATOR}}${PYTHONPATH}"
if test -n "@AR@"; then
AR="@AR@"
diff --git a/depends/description.md b/depends/description.md
index 0a6f2e6442..69ee5bd36c 100644
--- a/depends/description.md
+++ b/depends/description.md
@@ -6,8 +6,7 @@ There are several features that make it different from most similar systems:
In theory, binaries for any target OS/architecture can be created, from a
builder running any OS/architecture. In practice, build-side tools must be
specified when the defaults don't fit, and packages must be amended to work
-on new hosts. For now, a build architecture of x86_64 is assumed, either on
-Linux or macOS.
+on new hosts.
### No reliance on timestamps
@@ -28,7 +27,7 @@ etc), and as well as a hash of the same data for each recursive dependency. If
any portion of a package's build recipe changes, it will be rebuilt as well as
any other package that depends on it. If any of the main makefiles (Makefile,
funcs.mk, etc) are changed, all packages will be rebuilt. After building, the
-results are cached into a tarball that can be re-used and distributed.
+results are cached into a tarball that can be reused and distributed.
### Package build results are (relatively) deterministic.
diff --git a/doc/build-osx.md b/doc/build-osx.md
index 76fc357956..5c3dc1ac7f 100644
--- a/doc/build-osx.md
+++ b/doc/build-osx.md
@@ -175,7 +175,6 @@ There are many ways to configure Bitcoin Core, here are a few common examples:
##### Wallet (BDB + SQlite) Support, No GUI:
If `berkeley-db@4` is installed, then legacy wallet support will be built.
-If `berkeley-db@4` is not installed, then this will throw an error.
If `sqlite` is installed, then descriptor wallet support will also be built.
Additionally, this explicitly disables the GUI.
diff --git a/doc/build-windows.md b/doc/build-windows.md
index 027e8f80f5..841693c77b 100644
--- a/doc/build-windows.md
+++ b/doc/build-windows.md
@@ -48,18 +48,11 @@ Acquire the source in the usual way:
## Building for 64-bit Windows
The first step is to install the mingw-w64 cross-compilation tool chain:
- - on modern systems (Ubuntu 21.04 Hirsute Hippo or newer, Debian 11 Bullseye or newer):
```sh
sudo apt install g++-mingw-w64-x86-64-posix
```
- - on older systems:
-
-```sh
-sudo apt install g++-mingw-w64-x86-64
-```
-
Once the toolchain is installed the build steps are common:
Note that for WSL the Bitcoin Core source path MUST be somewhere in the default mount file system, for
diff --git a/src/addrman.h b/src/addrman.h
index 4d44c943ac..67dc7604a4 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -172,7 +172,7 @@ public:
/**
* Returns an information-location pair for all addresses in the selected addrman table.
* If an address appears multiple times in the new table, an information-location pair
- * is returned for each occurence. Addresses only ever appear once in the tried table.
+ * is returned for each occurrence. Addresses only ever appear once in the tried table.
*
* @param[in] from_tried Selects which table to return entries from.
*
diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp
index 9f52a22672..b81878006c 100644
--- a/src/bench/checkblock.cpp
+++ b/src/bench/checkblock.cpp
@@ -18,7 +18,7 @@
static void DeserializeBlockTest(benchmark::Bench& bench)
{
- CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
+ DataStream stream(benchmark::data::block413567);
std::byte a{0};
stream.write({&a, 1}); // Prevent compaction
@@ -32,7 +32,7 @@ static void DeserializeBlockTest(benchmark::Bench& bench)
static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
{
- CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
+ DataStream stream(benchmark::data::block413567);
std::byte a{0};
stream.write({&a, 1}); // Prevent compaction
diff --git a/src/bench/nanobench.h b/src/bench/nanobench.h
index 8b3dc6c71c..127240d3c7 100644
--- a/src/bench/nanobench.h
+++ b/src/bench/nanobench.h
@@ -33,7 +33,7 @@
// see https://semver.org/
#define ANKERL_NANOBENCH_VERSION_MAJOR 4 // incompatible API changes
#define ANKERL_NANOBENCH_VERSION_MINOR 3 // backwards-compatible changes
-#define ANKERL_NANOBENCH_VERSION_PATCH 10 // backwards-compatible bug fixes
+#define ANKERL_NANOBENCH_VERSION_PATCH 11 // backwards-compatible bug fixes
///////////////////////////////////////////////////////////////////////////////////////////////////
// public facing api - as minimal as possible
@@ -120,6 +120,10 @@
# define ANKERL_NANOBENCH_IS_TRIVIALLY_COPYABLE(...) std::is_trivially_copyable<__VA_ARGS__>::value
#endif
+// noexcept may be missing for std::string.
+// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58265
+#define ANKERL_NANOBENCH_PRIVATE_NOEXCEPT_STRING_MOVE() std::is_nothrow_move_assignable<std::string>::value
+
// declarations ///////////////////////////////////////////////////////////////////////////////////
namespace ankerl {
@@ -404,7 +408,7 @@ struct Config {
Config();
~Config();
Config& operator=(Config const& other);
- Config& operator=(Config&& other) noexcept;
+ Config& operator=(Config&& other) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE));
Config(Config const& other);
Config(Config&& other) noexcept;
};
@@ -430,7 +434,7 @@ public:
~Result();
Result& operator=(Result const& other);
- Result& operator=(Result&& other) noexcept;
+ Result& operator=(Result&& other) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE));
Result(Result const& other);
Result(Result&& other) noexcept;
@@ -596,7 +600,7 @@ public:
*
* @return Vector containing the full state:
*/
- std::vector<uint64_t> state() const;
+ ANKERL_NANOBENCH(NODISCARD) std::vector<uint64_t> state() const;
private:
static constexpr uint64_t rotl(uint64_t x, unsigned k) noexcept;
@@ -628,7 +632,7 @@ public:
Bench();
Bench(Bench&& other) noexcept;
- Bench& operator=(Bench&& other) noexcept;
+ Bench& operator=(Bench&& other) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE));
Bench(Bench const& other);
Bench& operator=(Bench const& other);
~Bench() noexcept;
@@ -818,7 +822,7 @@ public:
* Default is zero, so we are fully relying on clockResolutionMultiple(). In most cases this is exactly what you want. If you see
* that the evaluation is unreliable with a high `err%`, you can increase either minEpochTime() or minEpochIterations().
*
- * @see maxEpochTim), minEpochIterations
+ * @see maxEpochTime, minEpochIterations
*
* @param t Minimum time each epoch should take.
*/
@@ -1030,7 +1034,7 @@ void doNotOptimizeAway(T const& val);
// These assembly magic is directly from what Google Benchmark is doing. I have previously used what facebook's folly was doing, but
// this seemed to have compilation problems in some cases. Google Benchmark seemed to be the most well tested anyways.
-// see https://github.com/google/benchmark/blob/master/include/benchmark/benchmark.h#L307
+// see https://github.com/google/benchmark/blob/v1.7.1/include/benchmark/benchmark.h#L443-L446
template <typename T>
void doNotOptimizeAway(T const& val) {
// NOLINTNEXTLINE(hicpp-no-assembler)
@@ -1781,7 +1785,7 @@ bool isEndlessRunning(std::string const& name);
bool isWarningsEnabled();
template <typename T>
-T parseFile(std::string const& filename);
+T parseFile(std::string const& filename, bool* fail);
void gatherStabilityInformation(std::vector<std::string>& warnings, std::vector<std::string>& recommendations);
void printStabilityInformationOnce(std::ostream* outStream);
@@ -1839,7 +1843,7 @@ class Number {
public:
Number(int width, int precision, double value);
Number(int width, int precision, int64_t value);
- std::string to_s() const;
+ ANKERL_NANOBENCH(NODISCARD) std::string to_s() const;
private:
friend std::ostream& operator<<(std::ostream& os, Number const& n);
@@ -1857,11 +1861,11 @@ std::ostream& operator<<(std::ostream& os, Number const& n);
class MarkDownColumn {
public:
- MarkDownColumn(int w, int prec, std::string tit, std::string suff, double val);
- std::string title() const;
- std::string separator() const;
- std::string invalid() const;
- std::string value() const;
+ MarkDownColumn(int w, int prec, std::string tit, std::string suff, double val) noexcept;
+ ANKERL_NANOBENCH(NODISCARD) std::string title() const;
+ ANKERL_NANOBENCH(NODISCARD) std::string separator() const;
+ ANKERL_NANOBENCH(NODISCARD) std::string invalid() const;
+ ANKERL_NANOBENCH(NODISCARD) std::string value() const;
private:
int mWidth;
@@ -1976,9 +1980,9 @@ PerformanceCounters& performanceCounters() {
}
// Windows version of doNotOptimizeAway
-// see https://github.com/google/benchmark/blob/master/include/benchmark/benchmark.h#L307
-// see https://github.com/facebook/folly/blob/master/folly/Benchmark.h#L280
-// see https://docs.microsoft.com/en-us/cpp/preprocessor/optimize
+// see https://github.com/google/benchmark/blob/v1.7.1/include/benchmark/benchmark.h#L514
+// see https://github.com/facebook/folly/blob/v2023.01.30.00/folly/lang/Hint-inl.h#L54-L58
+// see https://learn.microsoft.com/en-us/cpp/preprocessor/optimize
# if defined(_MSC_VER)
# pragma optimize("", off)
void doNotOptimizeAwaySink(void const*) {}
@@ -1986,10 +1990,13 @@ void doNotOptimizeAwaySink(void const*) {}
# endif
template <typename T>
-T parseFile(std::string const& filename) {
+T parseFile(std::string const& filename, bool* fail) {
std::ifstream fin(filename); // NOLINT(misc-const-correctness)
T num{};
fin >> num;
+ if (fail != nullptr) {
+ *fail = fin.fail();
+ }
return num;
}
@@ -2032,16 +2039,15 @@ void gatherStabilityInformation(std::vector<std::string>& warnings, std::vector<
if (nprocs <= 0) {
warnings.emplace_back("couldn't figure out number of processors - no governor, turbo check possible");
} else {
-
// check frequency scaling
for (long id = 0; id < nprocs; ++id) {
auto idStr = detail::fmt::to_s(static_cast<uint64_t>(id));
auto sysCpu = "/sys/devices/system/cpu/cpu" + idStr;
- auto minFreq = parseFile<int64_t>(sysCpu + "/cpufreq/scaling_min_freq");
- auto maxFreq = parseFile<int64_t>(sysCpu + "/cpufreq/scaling_max_freq");
+ auto minFreq = parseFile<int64_t>(sysCpu + "/cpufreq/scaling_min_freq", nullptr);
+ auto maxFreq = parseFile<int64_t>(sysCpu + "/cpufreq/scaling_max_freq", nullptr);
if (minFreq != maxFreq) {
- auto minMHz = static_cast<double>(minFreq) / 1000.0;
- auto maxMHz = static_cast<double>(maxFreq) / 1000.0;
+ auto minMHz = d(minFreq) / 1000.0;
+ auto maxMHz = d(maxFreq) / 1000.0;
warnings.emplace_back("CPU frequency scaling enabled: CPU " + idStr + " between " +
detail::fmt::Number(1, 1, minMHz).to_s() + " and " + detail::fmt::Number(1, 1, maxMHz).to_s() +
" MHz");
@@ -2050,13 +2056,15 @@ void gatherStabilityInformation(std::vector<std::string>& warnings, std::vector<
}
}
- auto currentGovernor = parseFile<std::string>("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor");
- if ("performance" != currentGovernor) {
+ auto fail = false;
+ auto currentGovernor = parseFile<std::string>("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", &fail);
+ if (!fail && "performance" != currentGovernor) {
warnings.emplace_back("CPU governor is '" + currentGovernor + "' but should be 'performance'");
recommendPyPerf = true;
}
- if (0 == parseFile<int>("/sys/devices/system/cpu/intel_pstate/no_turbo")) {
+ auto noTurbo = parseFile<int>("/sys/devices/system/cpu/intel_pstate/no_turbo", &fail);
+ if (!fail && noTurbo == 0) {
warnings.emplace_back("Turbo is enabled, CPU frequency will fluctuate");
recommendPyPerf = true;
}
@@ -2250,10 +2258,9 @@ struct IterationLogic::Impl {
mNumIters = 0;
}
- ANKERL_NANOBENCH_LOG(mBench.name() << ": " << detail::fmt::Number(20, 3, static_cast<double>(elapsed.count())) << " elapsed, "
- << detail::fmt::Number(20, 3, static_cast<double>(mTargetRuntimePerEpoch.count()))
- << " target. oldIters=" << oldIters << ", mNumIters=" << mNumIters
- << ", mState=" << static_cast<int>(mState));
+ ANKERL_NANOBENCH_LOG(mBench.name() << ": " << detail::fmt::Number(20, 3, d(elapsed.count())) << " elapsed, "
+ << detail::fmt::Number(20, 3, d(mTargetRuntimePerEpoch.count())) << " target. oldIters="
+ << oldIters << ", mNumIters=" << mNumIters << ", mState=" << static_cast<int>(mState));
}
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
@@ -2357,7 +2364,7 @@ struct IterationLogic::Impl {
}
os << fmt::MarkDownCode(mBench.name());
if (showUnstable) {
- auto avgIters = static_cast<double>(mTotalNumIters) / static_cast<double>(mBench.epochs());
+ auto avgIters = d(mTotalNumIters) / d(mBench.epochs());
// NOLINTNEXTLINE(bugprone-incorrect-roundings)
auto suggestedIters = static_cast<uint64_t>(avgIters * 10 + 0.5);
@@ -2435,7 +2442,7 @@ public:
bool monitor(perf_sw_ids swId, Target target);
bool monitor(perf_hw_id hwId, Target target);
- bool hasError() const noexcept {
+ ANKERL_NANOBENCH(NODISCARD) bool hasError() const noexcept {
return mHasError;
}
@@ -2691,16 +2698,23 @@ PerformanceCounters::PerformanceCounters()
, mVal()
, mHas() {
- mHas.pageFaults = mPc->monitor(PERF_COUNT_SW_PAGE_FAULTS, LinuxPerformanceCounters::Target(&mVal.pageFaults, true, false));
+ // HW events
mHas.cpuCycles = mPc->monitor(PERF_COUNT_HW_REF_CPU_CYCLES, LinuxPerformanceCounters::Target(&mVal.cpuCycles, true, false));
- mHas.contextSwitches =
- mPc->monitor(PERF_COUNT_SW_CONTEXT_SWITCHES, LinuxPerformanceCounters::Target(&mVal.contextSwitches, true, false));
+ if (!mHas.cpuCycles) {
+ // Fallback to cycles counter, reference cycles not available in many systems.
+ mHas.cpuCycles = mPc->monitor(PERF_COUNT_HW_CPU_CYCLES, LinuxPerformanceCounters::Target(&mVal.cpuCycles, true, false));
+ }
mHas.instructions = mPc->monitor(PERF_COUNT_HW_INSTRUCTIONS, LinuxPerformanceCounters::Target(&mVal.instructions, true, true));
mHas.branchInstructions =
mPc->monitor(PERF_COUNT_HW_BRANCH_INSTRUCTIONS, LinuxPerformanceCounters::Target(&mVal.branchInstructions, true, false));
mHas.branchMisses = mPc->monitor(PERF_COUNT_HW_BRANCH_MISSES, LinuxPerformanceCounters::Target(&mVal.branchMisses, true, false));
// mHas.branchMisses = false;
+ // SW events
+ mHas.pageFaults = mPc->monitor(PERF_COUNT_SW_PAGE_FAULTS, LinuxPerformanceCounters::Target(&mVal.pageFaults, true, false));
+ mHas.contextSwitches =
+ mPc->monitor(PERF_COUNT_SW_CONTEXT_SWITCHES, LinuxPerformanceCounters::Target(&mVal.contextSwitches, true, false));
+
mPc->start();
mPc->calibrate([] {
auto before = ankerl::nanobench::Clock::now();
@@ -2789,7 +2803,7 @@ void StreamStateRestorer::restore() {
Number::Number(int width, int precision, int64_t value)
: mWidth(width)
, mPrecision(precision)
- , mValue(static_cast<double>(value)) {}
+ , mValue(d(value)) {}
Number::Number(int width, int precision, double value)
: mWidth(width)
@@ -2823,7 +2837,7 @@ std::ostream& operator<<(std::ostream& os, Number const& n) {
return n.write(os);
}
-MarkDownColumn::MarkDownColumn(int w, int prec, std::string tit, std::string suff, double val)
+MarkDownColumn::MarkDownColumn(int w, int prec, std::string tit, std::string suff, double val) noexcept
: mWidth(w)
, mPrecision(prec)
, mTitle(std::move(tit))
@@ -2884,14 +2898,14 @@ std::ostream& operator<<(std::ostream& os, MarkDownCode const& mdCode) {
Config::Config() = default;
Config::~Config() = default;
Config& Config::operator=(Config const&) = default;
-Config& Config::operator=(Config&&) noexcept = default;
+Config& Config::operator=(Config&&) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE)) = default;
Config::Config(Config const&) = default;
Config::Config(Config&&) noexcept = default;
// provide implementation here so it's only generated once
Result::~Result() = default;
Result& Result::operator=(Result const&) = default;
-Result& Result::operator=(Result&&) noexcept = default;
+Result& Result::operator=(Result&&) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE)) = default;
Result::Result(Result const&) = default;
Result::Result(Result&&) noexcept = default;
@@ -2992,7 +3006,7 @@ double Result::medianAbsolutePercentError(Measure m) const {
auto data = mNameToMeasurements[detail::u(m)];
// calculates MdAPE which is the median of percentage error
- // see https://www.spiderfinancial.com/support/documentation/numxl/reference-manual/forecasting-performance/mdape
+ // see https://support.numxl.com/hc/en-us/articles/115001223503-MdAPE-Median-Absolute-Percentage-Error
auto med = calcMedian(data);
// transform the data to absolute error
@@ -3106,7 +3120,7 @@ Bench::Bench() {
}
Bench::Bench(Bench&&) noexcept = default;
-Bench& Bench::operator=(Bench&&) noexcept = default;
+Bench& Bench::operator=(Bench&&) noexcept(ANKERL_NANOBENCH(NOEXCEPT_STRING_MOVE)) = default;
Bench::Bench(Bench const&) = default;
Bench& Bench::operator=(Bench const&) = default;
Bench::~Bench() noexcept = default;
@@ -3423,7 +3437,7 @@ BigO::BigO(std::string bigOName, RangeMeasure const& rangeMeasure)
sumMeasure += rm.second;
}
- auto n = static_cast<double>(rangeMeasure.size());
+ auto n = detail::d(rangeMeasure.size());
auto mean = sumMeasure / n;
mNormalizedRootMeanSquare = std::sqrt(err / n) / mean;
}
diff --git a/src/bench/pool.cpp b/src/bench/pool.cpp
index b3e54d85a2..b2a5f8debf 100644
--- a/src/bench/pool.cpp
+++ b/src/bench/pool.cpp
@@ -37,8 +37,7 @@ static void PoolAllocator_StdUnorderedMapWithPoolResource(benchmark::Bench& benc
std::hash<uint64_t>,
std::equal_to<uint64_t>,
PoolAllocator<std::pair<const uint64_t, uint64_t>,
- sizeof(std::pair<const uint64_t, uint64_t>) + 4 * sizeof(void*),
- alignof(void*)>>;
+ sizeof(std::pair<const uint64_t, uint64_t>) + 4 * sizeof(void*)>>;
// make sure the resource supports large enough pools to hold the node. We do this by adding the size of a few pointers to it.
auto pool_resource = Map::allocator_type::ResourceType();
diff --git a/src/bench/verify_script.cpp b/src/bench/verify_script.cpp
index e1a0bf138e..3682b33518 100644
--- a/src/bench/verify_script.cpp
+++ b/src/bench/verify_script.cpp
@@ -61,7 +61,7 @@ static void VerifyScriptBench(benchmark::Bench& bench)
assert(success);
#if defined(HAVE_CONSENSUS_LIB)
- CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
+ DataStream stream;
stream << TX_WITH_WITNESS(txSpend);
int csuccess = bitcoinconsensus_verify_script_with_amount(
txCredit.vout[0].scriptPubKey.data(),
diff --git a/src/bitcoin-util.cpp b/src/bitcoin-util.cpp
index 8b68d04b2b..96387e8c71 100644
--- a/src/bitcoin-util.cpp
+++ b/src/bitcoin-util.cpp
@@ -19,7 +19,6 @@
#include <util/exception.h>
#include <util/strencodings.h>
#include <util/translation.h>
-#include <version.h>
#include <atomic>
#include <cstdio>
diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp
index 29306b2229..1e940e8f03 100644
--- a/src/blockencodings.cpp
+++ b/src/blockencodings.cpp
@@ -164,7 +164,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
break;
}
- LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock, PROTOCOL_VERSION));
+ LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock));
return READ_STATUS_OK;
}
diff --git a/src/coins.cpp b/src/coins.cpp
index b44d920ee1..f576fae748 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -8,7 +8,6 @@
#include <logging.h>
#include <random.h>
#include <util/trace.h>
-#include <version.h>
bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return false; }
uint256 CCoinsView::GetBestBlock() const { return uint256(); }
@@ -339,7 +338,7 @@ void CCoinsViewCache::SanityCheck() const
assert(recomputed_usage == cachedCoinsUsage);
}
-static const size_t MIN_TRANSACTION_OUTPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxOut(), PROTOCOL_VERSION);
+static const size_t MIN_TRANSACTION_OUTPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxOut());
static const size_t MAX_OUTPUTS_PER_BLOCK = MAX_BLOCK_WEIGHT / MIN_TRANSACTION_OUTPUT_WEIGHT;
const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
diff --git a/src/coins.h b/src/coins.h
index a6cbb03133..bbf9e3895f 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -145,8 +145,7 @@ using CCoinsMap = std::unordered_map<COutPoint,
SaltedOutpointHasher,
std::equal_to<COutPoint>,
PoolAllocator<std::pair<const COutPoint, CCoinsCacheEntry>,
- sizeof(std::pair<const COutPoint, CCoinsCacheEntry>) + sizeof(void*) * 4,
- alignof(void*)>>;
+ sizeof(std::pair<const COutPoint, CCoinsCacheEntry>) + sizeof(void*) * 4>>;
using CCoinsMapMemoryResource = CCoinsMap::allocator_type::ResourceType;
diff --git a/src/consensus/validation.h b/src/consensus/validation.h
index 3fdc01e66b..1556c7888f 100644
--- a/src/consensus/validation.h
+++ b/src/consensus/validation.h
@@ -7,7 +7,6 @@
#define BITCOIN_CONSENSUS_VALIDATION_H
#include <string>
-#include <version.h>
#include <consensus/consensus.h>
#include <primitives/transaction.h>
#include <primitives/block.h>
diff --git a/src/core_read.cpp b/src/core_read.cpp
index bffb9e9042..e32e46d1b9 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -12,7 +12,6 @@
#include <streams.h>
#include <util/result.h>
#include <util/strencodings.h>
-#include <version.h>
#include <algorithm>
#include <string>
diff --git a/src/external_signer.cpp b/src/external_signer.cpp
index 102c58b56a..15024f6e0f 100644
--- a/src/external_signer.cpp
+++ b/src/external_signer.cpp
@@ -2,12 +2,14 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <external_signer.h>
+
#include <chainparams.h>
#include <common/run_command.h>
#include <core_io.h>
#include <psbt.h>
#include <util/strencodings.h>
-#include <external_signer.h>
+#include <version.h>
#include <algorithm>
#include <stdexcept>
diff --git a/src/hash.h b/src/hash.h
index 132e1a9fb3..52babf8b1d 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -14,7 +14,6 @@
#include <serialize.h>
#include <span.h>
#include <uint256.h>
-#include <version.h>
#include <string>
#include <vector>
diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp
index 5fda798efd..58f777b326 100644
--- a/src/index/blockfilterindex.cpp
+++ b/src/index/blockfilterindex.cpp
@@ -174,8 +174,8 @@ size_t BlockFilterIndex::WriteFilterToDisk(FlatFilePos& pos, const BlockFilter&
assert(filter.GetFilterType() == GetFilterType());
size_t data_size =
- GetSerializeSize(filter.GetBlockHash(), CLIENT_VERSION) +
- GetSerializeSize(filter.GetEncodedFilter(), CLIENT_VERSION);
+ GetSerializeSize(filter.GetBlockHash()) +
+ GetSerializeSize(filter.GetEncodedFilter());
// If writing the filter would overflow the file, flush and move to the next one.
if (pos.nPos + data_size > MAX_FLTR_FILE_SIZE) {
diff --git a/src/kernel/coinstats.cpp b/src/kernel/coinstats.cpp
index 9bd755ed27..302638cdbe 100644
--- a/src/kernel/coinstats.cpp
+++ b/src/kernel/coinstats.cpp
@@ -21,7 +21,6 @@
#include <util/check.h>
#include <util/overflow.h>
#include <validation.h>
-#include <version.h>
#include <cassert>
#include <iosfwd>
diff --git a/src/net.h b/src/net.h
index 16312cf72d..aa75df075d 100644
--- a/src/net.h
+++ b/src/net.h
@@ -30,6 +30,7 @@
#include <util/check.h>
#include <util/sock.h>
#include <util/threadinterrupt.h>
+#include <version.h>
#include <atomic>
#include <condition_variable>
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index c1c60b59d2..1556dc7e67 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2449,7 +2449,7 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
// of transactions relevant to them, without having to download the
// entire memory pool.
// Also, other nodes can use these messages to automatically request a
- // transaction from some other peer that annnounced it, and stop
+ // transaction from some other peer that announced it, and stop
// waiting for us to respond.
// In normal operation, we often send NOTFOUND messages for parents of
// transactions that we relay; if a peer is missing a parent, they may
@@ -3594,7 +3594,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
return;
}
- // Log succesful connections unconditionally for outbound, but not for inbound as those
+ // Log successful connections unconditionally for outbound, but not for inbound as those
// can be triggered by an attacker at high rate.
if (!pfrom.IsInboundConn() || LogAcceptCategory(BCLog::NET, BCLog::Level::Debug)) {
const auto mapped_as{m_connman.GetMappedAS(pfrom.addr)};
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index 1108cc676b..c066d1c939 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -662,7 +662,7 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
}
// Write index header
- unsigned int nSize = GetSerializeSize(blockundo, CLIENT_VERSION);
+ unsigned int nSize = GetSerializeSize(blockundo);
fileout << GetParams().MessageStart() << nSize;
// Write undo data
@@ -979,7 +979,7 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
// Write undo information to disk
if (block.GetUndoPos().IsNull()) {
FlatFilePos _pos;
- if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo, CLIENT_VERSION) + 40)) {
+ if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo) + 40)) {
return error("ConnectBlock(): FindUndoPos failed");
}
if (!UndoWriteToDisk(blockundo, _pos, block.pprev->GetBlockHash())) {
diff --git a/src/policy/policy.h b/src/policy/policy.h
index d1c8148800..6a7980c312 100644
--- a/src/policy/policy.h
+++ b/src/policy/policy.h
@@ -98,7 +98,7 @@ static constexpr unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY_P2SH |
* Standard script verification flags that standard transactions will comply
* with. However we do not ban/disconnect nodes that forward txs violating
* the additional (non-mandatory) rules here, to improve forwards and
- * backwards compatability.
+ * backwards compatibility.
*/
static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRIPT_VERIFY_FLAGS |
SCRIPT_VERIFY_STRICTENC |
diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp
index 6650277c2b..82fb59d349 100644
--- a/src/primitives/transaction.cpp
+++ b/src/primitives/transaction.cpp
@@ -13,7 +13,6 @@
#include <uint256.h>
#include <util/strencodings.h>
#include <util/transaction_identifier.h>
-#include <version.h>
#include <cassert>
#include <stdexcept>
diff --git a/src/psbt.cpp b/src/psbt.cpp
index 76a2fd8241..e46032f5d5 100644
--- a/src/psbt.cpp
+++ b/src/psbt.cpp
@@ -8,6 +8,7 @@
#include <script/signingprovider.h>
#include <util/check.h>
#include <util/strencodings.h>
+#include <version.h>
PartiallySignedTransaction::PartiallySignedTransaction(const CMutableTransaction& tx) : tx(tx)
diff --git a/src/psbt.h b/src/psbt.h
index 1fd186f6a5..a14df03837 100644
--- a/src/psbt.h
+++ b/src/psbt.h
@@ -89,7 +89,9 @@ struct PSBTProprietary
template<typename Stream, typename... X>
void SerializeToVector(Stream& s, const X&... args)
{
- WriteCompactSize(s, GetSerializeSizeMany(s.GetVersion(), args...));
+ SizeComputer sizecomp;
+ SerializeMany(sizecomp, args...);
+ WriteCompactSize(s, sizecomp.size());
SerializeMany(s, args...);
}
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 486e51c777..d4267fcf61 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -219,7 +219,7 @@ public:
// If a status update is needed (blocks came in since last check),
// try to update the status of this transaction from the wallet.
- // Otherwise, simply re-use the cached status.
+ // Otherwise, simply reuse the cached status.
interfaces::WalletTxStatus wtx;
int numBlocks;
int64_t block_time;
diff --git a/src/rest.cpp b/src/rest.cpp
index f86c47ee6b..3894b5141d 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -28,7 +28,6 @@
#include <util/check.h>
#include <util/strencodings.h>
#include <validation.h>
-#include <version.h>
#include <any>
#include <string>
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 9a29b73bee..6a3aa397d9 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1861,7 +1861,7 @@ static RPCHelpMan getblockstats()
for (const CTxOut& out : tx->vout) {
tx_total_out += out.nValue;
- size_t out_size = GetSerializeSize(out, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
+ size_t out_size = GetSerializeSize(out) + PER_UTXO_OVERHEAD;
utxo_size_inc += out_size;
// The Genesis block and the repeated BIP30 block coinbases don't change the UTXO
@@ -1913,7 +1913,7 @@ static RPCHelpMan getblockstats()
const CTxOut& prevoutput = coin.out;
tx_total_in += prevoutput.nValue;
- size_t prevout_size = GetSerializeSize(prevoutput, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
+ size_t prevout_size = GetSerializeSize(prevoutput) + PER_UTXO_OVERHEAD;
utxo_size_inc -= prevout_size;
utxo_size_inc_actual -= prevout_size;
}
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 397ece08c0..e8bcbd8a2b 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -40,6 +40,7 @@
#include <util/vector.h>
#include <validation.h>
#include <validationinterface.h>
+#include <version.h>
#include <numeric>
#include <stdint.h>
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 5de05e2e67..7adc28f416 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -409,7 +409,7 @@ static inline JSONRPCRequest transformNamedArguments(const JSONRPCRequest& in, c
}
// Process expected parameters. If any parameters were left unspecified in
// the request before a parameter that was specified, null values need to be
- // inserted at the unspecifed parameter positions, and the "hole" variable
+ // inserted at the unspecified parameter positions, and the "hole" variable
// below tracks the number of null values that need to be inserted.
// The "initial_hole_size" variable stores the size of the initial hole,
// i.e. how many initial positional arguments were left unspecified. This is
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index 63618ad202..cf48ee11e7 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -1089,7 +1089,7 @@ UniValue RPCResult::MatchesType(const UniValue& result) const
if (UniValue::VARR == result.getType()) {
UniValue errors(UniValue::VOBJ);
for (size_t i{0}; i < result.get_array().size(); ++i) {
- // If there are more results than documented, re-use the last doc_inner.
+ // If there are more results than documented, reuse the last doc_inner.
const RPCResult& doc_inner{m_inner.at(std::min(m_inner.size() - 1, i))};
UniValue match{doc_inner.MatchesType(result.get_array()[i])};
if (!match.isTrue()) errors.pushKV(strprintf("%d", i), match);
diff --git a/src/rpc/util.h b/src/rpc/util.h
index d2137993de..e2d5ed333c 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -402,7 +402,7 @@ public:
* RPC method implementations. The helper internally checks whether the
* user-passed argument isNull() and parses (from JSON) and returns the
* user-passed argument, or the default value derived from the RPCArg
- * documention, or a falsy value if no default was given.
+ * documentation, or a falsy value if no default was given.
*
* Use Arg<Type>(i) to get the argument or its default value. Otherwise,
* use MaybeArg<Type>(i) to get the optional argument or a falsy value.
diff --git a/src/script/bitcoinconsensus.cpp b/src/script/bitcoinconsensus.cpp
index 2ca8dac48c..c4eccacf41 100644
--- a/src/script/bitcoinconsensus.cpp
+++ b/src/script/bitcoinconsensus.cpp
@@ -8,7 +8,6 @@
#include <primitives/transaction.h>
#include <pubkey.h>
#include <script/interpreter.h>
-#include <version.h>
namespace {
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 5f4a1aceb2..c969ce45f1 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -1934,7 +1934,7 @@ static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion,
if ((control[0] & TAPROOT_LEAF_MASK) == TAPROOT_LEAF_TAPSCRIPT) {
// Tapscript (leaf version 0xc0)
exec_script = CScript(script.begin(), script.end());
- execdata.m_validation_weight_left = ::GetSerializeSize(witness.stack, PROTOCOL_VERSION) + VALIDATION_WEIGHT_OFFSET;
+ execdata.m_validation_weight_left = ::GetSerializeSize(witness.stack) + VALIDATION_WEIGHT_OFFSET;
execdata.m_validation_weight_left_init = true;
return ExecuteWitnessScript(stack, exec_script, flags, SigVersion::TAPSCRIPT, checker, execdata, serror);
}
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 251a8420f7..be4b357568 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -379,7 +379,7 @@ static bool SignTaproot(const SigningProvider& provider, const BaseSignatureCrea
result_stack.emplace_back(std::begin(script), std::end(script)); // Push the script
result_stack.push_back(*control_blocks.begin()); // Push the smallest control block
if (smallest_result_stack.size() == 0 ||
- GetSerializeSize(result_stack, PROTOCOL_VERSION) < GetSerializeSize(smallest_result_stack, PROTOCOL_VERSION)) {
+ GetSerializeSize(result_stack) < GetSerializeSize(smallest_result_stack)) {
smallest_result_stack = std::move(result_stack);
}
}
diff --git a/src/serialize.h b/src/serialize.h
index b09d6fbe60..83715866f5 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -124,7 +124,7 @@ template<typename Stream> inline uint64_t ser_readdata64(Stream &s)
// i.e. anything that supports .read(Span<std::byte>) and .write(Span<const std::byte>)
//
-class CSizeComputer;
+class SizeComputer;
enum
{
@@ -324,7 +324,7 @@ constexpr inline unsigned int GetSizeOfCompactSize(uint64_t nSize)
else return sizeof(unsigned char) + sizeof(uint64_t);
}
-inline void WriteCompactSize(CSizeComputer& os, uint64_t nSize);
+inline void WriteCompactSize(SizeComputer& os, uint64_t nSize);
template<typename Stream>
void WriteCompactSize(Stream& os, uint64_t nSize)
@@ -450,7 +450,7 @@ inline unsigned int GetSizeOfVarInt(I n)
}
template<typename I>
-inline void WriteVarInt(CSizeComputer& os, I n);
+inline void WriteVarInt(SizeComputer& os, I n);
template<typename Stream, VarIntMode Mode, typename I>
void WriteVarInt(Stream& os, I n)
@@ -1070,22 +1070,21 @@ struct ActionUnserialize {
/* ::GetSerializeSize implementations
*
* Computing the serialized size of objects is done through a special stream
- * object of type CSizeComputer, which only records the number of bytes written
+ * object of type SizeComputer, which only records the number of bytes written
* to it.
*
* If your Serialize or SerializationOp method has non-trivial overhead for
* serialization, it may be worthwhile to implement a specialized version for
- * CSizeComputer, which uses the s.seek() method to record bytes that would
+ * SizeComputer, which uses the s.seek() method to record bytes that would
* be written instead.
*/
-class CSizeComputer
+class SizeComputer
{
protected:
size_t nSize{0};
- const int nVersion;
public:
- explicit CSizeComputer(int nVersionIn) : nVersion(nVersionIn) {}
+ SizeComputer() {}
void write(Span<const std::byte> src)
{
@@ -1099,7 +1098,7 @@ public:
}
template<typename T>
- CSizeComputer& operator<<(const T& obj)
+ SizeComputer& operator<<(const T& obj)
{
::Serialize(*this, obj);
return (*this);
@@ -1108,33 +1107,23 @@ public:
size_t size() const {
return nSize;
}
-
- int GetVersion() const { return nVersion; }
};
template<typename I>
-inline void WriteVarInt(CSizeComputer &s, I n)
+inline void WriteVarInt(SizeComputer &s, I n)
{
s.seek(GetSizeOfVarInt<I>(n));
}
-inline void WriteCompactSize(CSizeComputer &s, uint64_t nSize)
+inline void WriteCompactSize(SizeComputer &s, uint64_t nSize)
{
s.seek(GetSizeOfCompactSize(nSize));
}
template <typename T>
-size_t GetSerializeSize(const T& t, int nVersion = 0)
-{
- return (CSizeComputer(nVersion) << t).size();
-}
-
-template <typename... T>
-size_t GetSerializeSizeMany(int nVersion, const T&... t)
+size_t GetSerializeSize(const T& t)
{
- CSizeComputer sc(nVersion);
- SerializeMany(sc, t...);
- return sc.size();
+ return (SizeComputer() << t).size();
}
/** Wrapper that overrides the GetParams() function of a stream (and hides GetVersion/GetType). */
diff --git a/src/signet.cpp b/src/signet.cpp
index ef0faaa5f8..d6a3a44d91 100644
--- a/src/signet.cpp
+++ b/src/signet.cpp
@@ -22,6 +22,7 @@
#include <streams.h>
#include <uint256.h>
#include <util/strencodings.h>
+#include <version.h>
static constexpr uint8_t SIGNET_HEADER[4] = {0xec, 0xc7, 0xda, 0xa2};
diff --git a/src/support/allocators/pool.h b/src/support/allocators/pool.h
index c8e70ebacf..873e260b65 100644
--- a/src/support/allocators/pool.h
+++ b/src/support/allocators/pool.h
@@ -272,7 +272,7 @@ public:
/**
* Forwards all allocations/deallocations to the PoolResource.
*/
-template <class T, std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES>
+template <class T, std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
class PoolAllocator
{
PoolResource<MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES>* m_resource;
diff --git a/src/test/flatfile_tests.cpp b/src/test/flatfile_tests.cpp
index 3874b38f61..21a36d9d43 100644
--- a/src/test/flatfile_tests.cpp
+++ b/src/test/flatfile_tests.cpp
@@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(flatfile_open)
"lost if a trusted third party is still required to prevent double-spending.");
size_t pos1 = 0;
- size_t pos2 = pos1 + GetSerializeSize(line1, CLIENT_VERSION);
+ size_t pos2 = pos1 + GetSerializeSize(line1);
// Write first line to file.
{
diff --git a/src/test/fuzz/FuzzedDataProvider.h b/src/test/fuzz/FuzzedDataProvider.h
index 8a8214bd99..5903ed8379 100644
--- a/src/test/fuzz/FuzzedDataProvider.h
+++ b/src/test/fuzz/FuzzedDataProvider.h
@@ -158,7 +158,7 @@ FuzzedDataProvider::ConsumeRandomLengthString(size_t max_length) {
// picking its contents.
std::string result;
- // Reserve the anticipated capaticity to prevent several reallocations.
+ // Reserve the anticipated capacity to prevent several reallocations.
result.reserve(std::min(max_length, remaining_bytes_));
for (size_t i = 0; i < max_length && remaining_bytes_ != 0; ++i) {
char next = ConvertUnsignedToSigned<char>(data_ptr_[0]);
diff --git a/src/test/fuzz/autofile.cpp b/src/test/fuzz/autofile.cpp
index a7b41370a8..45316b6b21 100644
--- a/src/test/fuzz/autofile.cpp
+++ b/src/test/fuzz/autofile.cpp
@@ -2,24 +2,28 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <span.h>
#include <streams.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <array>
-#include <cstdint>
+#include <cstddef>
+#include <cstdio>
#include <iostream>
-#include <optional>
-#include <string>
#include <vector>
FUZZ_TARGET(autofile)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
- FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);
- AutoFile auto_file{fuzzed_auto_file_provider.open()};
- LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
+ AutoFile auto_file{
+ fuzzed_file_provider.open(),
+ ConsumeRandomLengthByteVector<std::byte>(fuzzed_data_provider),
+ };
+ LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 100)
+ {
CallOneOf(
fuzzed_data_provider,
[&] {
diff --git a/src/test/fuzz/buffered_file.cpp b/src/test/fuzz/buffered_file.cpp
index 636f11b381..813af63738 100644
--- a/src/test/fuzz/buffered_file.cpp
+++ b/src/test/fuzz/buffered_file.cpp
@@ -2,31 +2,37 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <span.h>
#include <streams.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <array>
+#include <cstddef>
#include <cstdint>
#include <iostream>
#include <optional>
-#include <string>
#include <vector>
FUZZ_TARGET(buffered_file)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
- FuzzedFileProvider fuzzed_file_provider = ConsumeFile(fuzzed_data_provider);
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
std::optional<BufferedFile> opt_buffered_file;
- CAutoFile fuzzed_file{fuzzed_file_provider.open(), 0};
+ CAutoFile fuzzed_file{
+ fuzzed_file_provider.open(),
+ 0,
+ ConsumeRandomLengthByteVector<std::byte>(fuzzed_data_provider),
+ };
try {
opt_buffered_file.emplace(fuzzed_file, fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096), fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096));
} catch (const std::ios_base::failure&) {
}
if (opt_buffered_file && !fuzzed_file.IsNull()) {
bool setpos_fail = false;
- LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
+ LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 100)
+ {
CallOneOf(
fuzzed_data_provider,
[&] {
diff --git a/src/test/fuzz/load_external_block_file.cpp b/src/test/fuzz/load_external_block_file.cpp
index fc903e5ec2..ae4f5d089b 100644
--- a/src/test/fuzz/load_external_block_file.cpp
+++ b/src/test/fuzz/load_external_block_file.cpp
@@ -27,7 +27,7 @@ void initialize_load_external_block_file()
FUZZ_TARGET(load_external_block_file, .init = initialize_load_external_block_file)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
- FuzzedFileProvider fuzzed_file_provider = ConsumeFile(fuzzed_data_provider);
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
CAutoFile fuzzed_block_file{fuzzed_file_provider.open(), CLIENT_VERSION};
if (fuzzed_block_file.IsNull()) {
return;
diff --git a/src/test/fuzz/miniscript.cpp b/src/test/fuzz/miniscript.cpp
index 8c73edfa9d..0d0ee59ab3 100644
--- a/src/test/fuzz/miniscript.cpp
+++ b/src/test/fuzz/miniscript.cpp
@@ -1121,7 +1121,7 @@ void TestNode(const MsCtx script_ctx, const NodeRef& node, FuzzedDataProvider& p
assert(mal_success);
assert(stack_nonmal == stack_mal);
// Compute witness size (excluding script push, control block, and witness count encoding).
- const size_t wit_size = GetSerializeSize(stack_nonmal, PROTOCOL_VERSION) - GetSizeOfCompactSize(stack_nonmal.size());
+ const size_t wit_size = GetSerializeSize(stack_nonmal) - GetSizeOfCompactSize(stack_nonmal.size());
assert(wit_size <= *node->GetWitnessSize());
// Test non-malleable satisfaction.
diff --git a/src/test/fuzz/package_eval.cpp b/src/test/fuzz/package_eval.cpp
index 8d316134cc..8658c0b45a 100644
--- a/src/test/fuzz/package_eval.cpp
+++ b/src/test/fuzz/package_eval.cpp
@@ -40,7 +40,7 @@ void initialize_tx_pool()
g_setup = testing_setup.get();
for (int i = 0; i < 2 * COINBASE_MATURITY; ++i) {
- COutPoint prevout{MineBlock(g_setup->m_node, P2WSH_OP_TRUE)};
+ COutPoint prevout{MineBlock(g_setup->m_node, P2WSH_EMPTY)};
if (i < COINBASE_MATURITY) {
// Remember the txids to avoid expensive disk access later on
g_outpoints_coinbase_init_mature.push_back(prevout);
@@ -195,7 +195,8 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
// Create input
const auto sequence = ConsumeSequence(fuzzed_data_provider);
const auto script_sig = CScript{};
- const auto script_wit_stack = std::vector<std::vector<uint8_t>>{WITNESS_STACK_ELEM_OP_TRUE};
+ const auto script_wit_stack = fuzzed_data_provider.ConsumeBool() ? P2WSH_EMPTY_TRUE_STACK : P2WSH_EMPTY_TWO_STACK;
+
CTxIn in;
in.prevout = outpoint;
in.nSequence = sequence;
@@ -204,17 +205,30 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
tx_mut.vin.push_back(in);
}
+
+ // Duplicate an input
+ bool dup_input = fuzzed_data_provider.ConsumeBool();
+ if (dup_input) {
+ tx_mut.vin.push_back(tx_mut.vin.back());
+ }
+
+ // Refer to a non-existant input
+ if (fuzzed_data_provider.ConsumeBool()) {
+ tx_mut.vin.emplace_back();
+ }
+
const auto amount_fee = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(0, amount_in);
const auto amount_out = (amount_in - amount_fee) / num_out;
for (int i = 0; i < num_out; ++i) {
- tx_mut.vout.emplace_back(amount_out, P2WSH_OP_TRUE);
+ tx_mut.vout.emplace_back(amount_out, P2WSH_EMPTY);
}
// TODO vary transaction sizes to catch size-related issues
auto tx = MakeTransactionRef(tx_mut);
// Restore previously removed outpoints, except in-package outpoints
if (!last_tx) {
for (const auto& in : tx->vin) {
- Assert(outpoints.insert(in.prevout).second);
+ // It's a fake input, or a new input, or a duplicate
+ Assert(in == CTxIn() || outpoints.insert(in.prevout).second || dup_input);
}
// Cache the in-package outpoints being made
for (size_t i = 0; i < tx->vout.size(); ++i) {
diff --git a/src/test/fuzz/policy_estimator.cpp b/src/test/fuzz/policy_estimator.cpp
index a6275d2fd2..220799be41 100644
--- a/src/test/fuzz/policy_estimator.cpp
+++ b/src/test/fuzz/policy_estimator.cpp
@@ -13,6 +13,7 @@
#include <test/fuzz/util/mempool.h>
#include <test/util/setup_common.h>
+#include <memory>
#include <optional>
#include <vector>
@@ -81,8 +82,8 @@ FUZZ_TARGET(policy_estimator, .init = initialize_policy_estimator)
(void)block_policy_estimator.HighestTargetTracked(fuzzed_data_provider.PickValueInArray(ALL_FEE_ESTIMATE_HORIZONS));
}
{
- FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);
- AutoFile fuzzed_auto_file{fuzzed_auto_file_provider.open()};
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
+ AutoFile fuzzed_auto_file{fuzzed_file_provider.open()};
block_policy_estimator.Write(fuzzed_auto_file);
block_policy_estimator.Read(fuzzed_auto_file);
}
diff --git a/src/test/fuzz/policy_estimator_io.cpp b/src/test/fuzz/policy_estimator_io.cpp
index c04ef8f5b0..3e7d093343 100644
--- a/src/test/fuzz/policy_estimator_io.cpp
+++ b/src/test/fuzz/policy_estimator_io.cpp
@@ -4,13 +4,13 @@
#include <policy/fees.h>
#include <policy/fees_args.h>
+#include <streams.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <test/util/setup_common.h>
-#include <cstdint>
-#include <vector>
+#include <memory>
namespace {
const BasicTestingSetup* g_setup;
@@ -25,8 +25,8 @@ void initialize_policy_estimator_io()
FUZZ_TARGET(policy_estimator_io, .init = initialize_policy_estimator_io)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
- FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);
- AutoFile fuzzed_auto_file{fuzzed_auto_file_provider.open()};
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
+ AutoFile fuzzed_auto_file{fuzzed_file_provider.open()};
// Re-using block_policy_estimator across runs to avoid costly creation of CBlockPolicyEstimator object.
static CBlockPolicyEstimator block_policy_estimator{FeeestPath(*g_setup->m_node.args), DEFAULT_ACCEPT_STALE_FEE_ESTIMATES};
if (block_policy_estimator.Read(fuzzed_auto_file)) {
diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h
index 95d910b64d..0ad2ed6128 100644
--- a/src/test/fuzz/util.h
+++ b/src/test/fuzz/util.h
@@ -263,31 +263,6 @@ public:
static int close(void* cookie);
};
-[[nodiscard]] inline FuzzedFileProvider ConsumeFile(FuzzedDataProvider& fuzzed_data_provider) noexcept
-{
- return {fuzzed_data_provider};
-}
-
-class FuzzedAutoFileProvider
-{
- FuzzedFileProvider m_fuzzed_file_provider;
-
-public:
- FuzzedAutoFileProvider(FuzzedDataProvider& fuzzed_data_provider) : m_fuzzed_file_provider{fuzzed_data_provider}
- {
- }
-
- AutoFile open()
- {
- return AutoFile{m_fuzzed_file_provider.open()};
- }
-};
-
-[[nodiscard]] inline FuzzedAutoFileProvider ConsumeAutoFile(FuzzedDataProvider& fuzzed_data_provider) noexcept
-{
- return {fuzzed_data_provider};
-}
-
#define WRITE_TO_STREAM_CASE(type, consume) \
[&] { \
type o = consume; \
diff --git a/src/test/fuzz/validation_load_mempool.cpp b/src/test/fuzz/validation_load_mempool.cpp
index 5d020b4d59..00678742c9 100644
--- a/src/test/fuzz/validation_load_mempool.cpp
+++ b/src/test/fuzz/validation_load_mempool.cpp
@@ -38,7 +38,7 @@ FUZZ_TARGET(validation_load_mempool, .init = initialize_validation_load_mempool)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
SetMockTime(ConsumeTime(fuzzed_data_provider));
- FuzzedFileProvider fuzzed_file_provider = ConsumeFile(fuzzed_data_provider);
+ FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
CTxMemPool pool{MemPoolOptionsForTest(g_setup->m_node)};
diff --git a/src/test/miniscript_tests.cpp b/src/test/miniscript_tests.cpp
index 996c379962..1f28e61bc9 100644
--- a/src/test/miniscript_tests.cpp
+++ b/src/test/miniscript_tests.cpp
@@ -369,7 +369,7 @@ void TestSatisfy(const KeyConverter& converter, const std::string& testcase, con
CScriptWitness witness_nonmal;
const bool nonmal_success = node->Satisfy(satisfier, witness_nonmal.stack, true) == miniscript::Availability::YES;
// Compute witness size (excluding script push, control block, and witness count encoding).
- const size_t wit_size = GetSerializeSize(witness_nonmal.stack, PROTOCOL_VERSION) - GetSizeOfCompactSize(witness_nonmal.stack.size());
+ const size_t wit_size = GetSerializeSize(witness_nonmal.stack) - GetSizeOfCompactSize(witness_nonmal.stack.size());
SatisfactionToWitness(converter.MsContext(), witness_nonmal, script, builder);
if (nonmal_success) {
diff --git a/src/test/orphanage_tests.cpp b/src/test/orphanage_tests.cpp
index d374497a45..b51de30cb2 100644
--- a/src/test/orphanage_tests.cpp
+++ b/src/test/orphanage_tests.cpp
@@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
}
SignatureData empty;
BOOST_CHECK(SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL, empty));
- // Re-use same signature for other inputs
+ // Reuse same signature for other inputs
// (they don't have to be valid for this test)
for (unsigned int j = 1; j < tx.vin.size(); j++)
tx.vin[j].scriptSig = tx.vin[0].scriptSig;
diff --git a/src/test/pool_tests.cpp b/src/test/pool_tests.cpp
index 8a07e09a44..5ad4afa3a1 100644
--- a/src/test/pool_tests.cpp
+++ b/src/test/pool_tests.cpp
@@ -156,21 +156,20 @@ BOOST_AUTO_TEST_CASE(random_allocations)
BOOST_AUTO_TEST_CASE(memusage_test)
{
- auto std_map = std::unordered_map<int, int>{};
-
- using Map = std::unordered_map<int,
- int,
- std::hash<int>,
- std::equal_to<int>,
- PoolAllocator<std::pair<const int, int>,
- sizeof(std::pair<const int, int>) + sizeof(void*) * 4,
- alignof(void*)>>;
+ auto std_map = std::unordered_map<int64_t, int64_t>{};
+
+ using Map = std::unordered_map<int64_t,
+ int64_t,
+ std::hash<int64_t>,
+ std::equal_to<int64_t>,
+ PoolAllocator<std::pair<const int64_t, int64_t>,
+ sizeof(std::pair<const int64_t, int64_t>) + sizeof(void*) * 4>>;
auto resource = Map::allocator_type::ResourceType(1024);
PoolResourceTester::CheckAllDataAccountedFor(resource);
{
- auto resource_map = Map{0, std::hash<int>{}, std::equal_to<int>{}, &resource};
+ auto resource_map = Map{0, std::hash<int64_t>{}, std::equal_to<int64_t>{}, &resource};
// can't have the same resource usage
BOOST_TEST(memusage::DynamicUsage(std_map) != memusage::DynamicUsage(resource_map));
@@ -182,6 +181,11 @@ BOOST_AUTO_TEST_CASE(memusage_test)
// Eventually the resource_map should have a much lower memory usage because it has less malloc overhead
BOOST_TEST(memusage::DynamicUsage(resource_map) <= memusage::DynamicUsage(std_map) * 90 / 100);
+
+ // Make sure the pool is actually used by the nodes
+ auto max_nodes_per_chunk = resource.ChunkSizeBytes() / sizeof(Map::value_type);
+ auto min_num_allocated_chunks = resource_map.size() / max_nodes_per_chunk + 1;
+ BOOST_TEST(resource.NumAllocatedChunks() >= min_num_allocated_chunks);
}
PoolResourceTester::CheckAllDataAccountedFor(resource);
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index b05a6da804..874f3e51f7 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -1112,7 +1112,7 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23)
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
keys.clear();
- keys.push_back(key2); keys.push_back(key2); // Can't re-use sig
+ keys.push_back(key2); keys.push_back(key2); // Can't reuse sig
CScript badsig1 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, nullptr, gFlags, MutableTransactionSignatureChecker(&txTo23, 0, txFrom23.vout[0].nValue, MissingDataBehavior::ASSERT_FAIL), &err));
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp
index 6d5a14ad9e..d75eb499b4 100644
--- a/src/test/serialize_tests.cpp
+++ b/src/test/serialize_tests.cpp
@@ -62,31 +62,31 @@ public:
BOOST_AUTO_TEST_CASE(sizes)
{
- BOOST_CHECK_EQUAL(sizeof(unsigned char), GetSerializeSize((unsigned char)0, 0));
- BOOST_CHECK_EQUAL(sizeof(int8_t), GetSerializeSize(int8_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(uint8_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(int16_t), GetSerializeSize(int16_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(uint16_t), GetSerializeSize(uint16_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(int32_t), GetSerializeSize(int32_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(uint32_t), GetSerializeSize(uint32_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(int64_t), GetSerializeSize(int64_t(0), 0));
- BOOST_CHECK_EQUAL(sizeof(uint64_t), GetSerializeSize(uint64_t(0), 0));
+ BOOST_CHECK_EQUAL(sizeof(unsigned char), GetSerializeSize((unsigned char)0));
+ BOOST_CHECK_EQUAL(sizeof(int8_t), GetSerializeSize(int8_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(uint8_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(int16_t), GetSerializeSize(int16_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(uint16_t), GetSerializeSize(uint16_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(int32_t), GetSerializeSize(int32_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(uint32_t), GetSerializeSize(uint32_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(int64_t), GetSerializeSize(int64_t(0)));
+ BOOST_CHECK_EQUAL(sizeof(uint64_t), GetSerializeSize(uint64_t(0)));
// Bool is serialized as uint8_t
- BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(bool(0), 0));
+ BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(bool(0)));
// Sanity-check GetSerializeSize and c++ type matching
- BOOST_CHECK_EQUAL(GetSerializeSize((unsigned char)0, 0), 1U);
- BOOST_CHECK_EQUAL(GetSerializeSize(int8_t(0), 0), 1U);
- BOOST_CHECK_EQUAL(GetSerializeSize(uint8_t(0), 0), 1U);
- BOOST_CHECK_EQUAL(GetSerializeSize(int16_t(0), 0), 2U);
- BOOST_CHECK_EQUAL(GetSerializeSize(uint16_t(0), 0), 2U);
- BOOST_CHECK_EQUAL(GetSerializeSize(int32_t(0), 0), 4U);
- BOOST_CHECK_EQUAL(GetSerializeSize(uint32_t(0), 0), 4U);
- BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0), 0), 8U);
- BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0), 0), 8U);
- BOOST_CHECK_EQUAL(GetSerializeSize(bool(0), 0), 1U);
- BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 1>{0}, 0), 1U);
- BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 2>{0, 0}, 0), 2U);
+ BOOST_CHECK_EQUAL(GetSerializeSize((unsigned char)0), 1U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(int8_t(0)), 1U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(uint8_t(0)), 1U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(int16_t(0)), 2U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(uint16_t(0)), 2U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(int32_t(0)), 4U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(uint32_t(0)), 4U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0)), 8U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0)), 8U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(bool(0)), 1U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 1>{0}), 1U);
+ BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 2>{0, 0}), 2U);
}
BOOST_AUTO_TEST_CASE(varints)
@@ -97,13 +97,13 @@ BOOST_AUTO_TEST_CASE(varints)
DataStream::size_type size = 0;
for (int i = 0; i < 100000; i++) {
ss << VARINT_MODE(i, VarIntMode::NONNEGATIVE_SIGNED);
- size += ::GetSerializeSize(VARINT_MODE(i, VarIntMode::NONNEGATIVE_SIGNED), 0);
+ size += ::GetSerializeSize(VARINT_MODE(i, VarIntMode::NONNEGATIVE_SIGNED));
BOOST_CHECK(size == ss.size());
}
for (uint64_t i = 0; i < 100000000000ULL; i += 999999937) {
ss << VARINT(i);
- size += ::GetSerializeSize(VARINT(i), 0);
+ size += ::GetSerializeSize(VARINT(i));
BOOST_CHECK(size == ss.size());
}
diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp
index 9caefe43e2..933988dd7a 100644
--- a/src/test/uint256_tests.cpp
+++ b/src/test/uint256_tests.cpp
@@ -184,8 +184,8 @@ BOOST_AUTO_TEST_CASE( methods ) // GetHex SetHex begin() end() size() GetLow64 G
BOOST_CHECK(OneL.begin() + 32 == OneL.end());
BOOST_CHECK(MaxL.begin() + 32 == MaxL.end());
BOOST_CHECK(TmpL.begin() + 32 == TmpL.end());
- BOOST_CHECK(GetSerializeSize(R1L, PROTOCOL_VERSION) == 32);
- BOOST_CHECK(GetSerializeSize(ZeroL, PROTOCOL_VERSION) == 32);
+ BOOST_CHECK(GetSerializeSize(R1L) == 32);
+ BOOST_CHECK(GetSerializeSize(ZeroL) == 32);
DataStream ss{};
ss << R1L;
@@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE( methods ) // GetHex SetHex begin() end() size() GetLow64 G
BOOST_CHECK(OneS.begin() + 20 == OneS.end());
BOOST_CHECK(MaxS.begin() + 20 == MaxS.end());
BOOST_CHECK(TmpS.begin() + 20 == TmpS.end());
- BOOST_CHECK(GetSerializeSize(R1S, PROTOCOL_VERSION) == 20);
- BOOST_CHECK(GetSerializeSize(ZeroS, PROTOCOL_VERSION) == 20);
+ BOOST_CHECK(GetSerializeSize(R1S) == 20);
+ BOOST_CHECK(GetSerializeSize(ZeroS) == 20);
ss << R1S;
BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+20));
diff --git a/src/test/util/script.h b/src/test/util/script.h
index 428b3e10b3..96c4d55e5a 100644
--- a/src/test/util/script.h
+++ b/src/test/util/script.h
@@ -18,6 +18,18 @@ static const CScript P2WSH_OP_TRUE{
return hash;
}())};
+static const std::vector<uint8_t> EMPTY{};
+static const CScript P2WSH_EMPTY{
+ CScript{}
+ << OP_0
+ << ToByteVector([] {
+ uint256 hash;
+ CSHA256().Write(EMPTY.data(), EMPTY.size()).Finalize(hash.begin());
+ return hash;
+ }())};
+static const std::vector<std::vector<uint8_t>> P2WSH_EMPTY_TRUE_STACK{{static_cast<uint8_t>(OP_TRUE)}, {}};
+static const std::vector<std::vector<uint8_t>> P2WSH_EMPTY_TWO_STACK{{static_cast<uint8_t>(OP_2)}, {}};
+
/** Flags that are not forbidden by an assert in script validation */
bool IsValidFlagCombination(unsigned flags);
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
index 4e1a26f303..b60cf7e4fd 100644
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -17,6 +17,7 @@
#include <util/fs.h>
#include <util/string.h>
#include <util/vector.h>
+#include <version.h>
#include <functional>
#include <type_traits>
diff --git a/src/test/versionbits_tests.cpp b/src/test/versionbits_tests.cpp
index 9e69992752..f462895edb 100644
--- a/src/test/versionbits_tests.cpp
+++ b/src/test/versionbits_tests.cpp
@@ -424,7 +424,7 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
uint32_t chain_all_vbits{0};
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) {
const auto dep = static_cast<Consensus::DeploymentPos>(i);
- // Check that no bits are re-used (within the same chain). This is
+ // Check that no bits are reused (within the same chain). This is
// disallowed because the transition to FAILED (on timeout) does
// not take precedence over STARTED/LOCKED_IN. So all softforks on
// the same bit might overlap, even when non-overlapping start-end
diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp
index 60cf31a964..11d13d050a 100644
--- a/src/torcontrol.cpp
+++ b/src/torcontrol.cpp
@@ -251,7 +251,7 @@ std::map<std::string,std::string> ParseTorReplyMapping(const std::string &s)
/**
* Unescape value. Per https://spec.torproject.org/control-spec section 2.1.1:
*
- * For future-proofing, controller implementors MAY use the following
+ * For future-proofing, controller implementers MAY use the following
* rules to be compatible with buggy Tor implementations and with
* future ones that implement the spec as intended:
*
diff --git a/src/txmempool.h b/src/txmempool.h
index 122bac09b1..aed6acd9da 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -478,7 +478,7 @@ public:
void removeRecursive(const CTransaction& tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
/** After reorg, filter the entries that would no longer be valid in the next block, and update
* the entries' cached LockPoints if needed. The mempool does not have any knowledge of
- * consensus rules. It just appplies the callable function and removes the ones for which it
+ * consensus rules. It just applies the callable function and removes the ones for which it
* returns true.
* @param[in] filter_final_and_mature Predicate that checks the relevant validation rules
* and updates an entry's LockPoints.
diff --git a/src/undo.h b/src/undo.h
index a98f046735..1fb9ac0688 100644
--- a/src/undo.h
+++ b/src/undo.h
@@ -11,7 +11,6 @@
#include <consensus/consensus.h>
#include <primitives/transaction.h>
#include <serialize.h>
-#include <version.h>
/** Formatter for undo information for a CTxIn
*
diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp
index f0fd789c96..d9a08310a8 100644
--- a/src/wallet/feebumper.cpp
+++ b/src/wallet/feebumper.cpp
@@ -170,7 +170,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
return Result::INVALID_PARAMETER;
}
- // We are going to modify coin control later, copy to re-use
+ // We are going to modify coin control later, copy to reuse
CCoinControl new_coin_control(coin_control);
LOCK(wallet.cs_wallet);
diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp
index 0f7a882034..6519504618 100644
--- a/src/wallet/rpc/spend.cpp
+++ b/src/wallet/rpc/spend.cpp
@@ -19,6 +19,7 @@
#include <wallet/rpc/util.h>
#include <wallet/spend.h>
#include <wallet/wallet.h>
+#include <version.h>
#include <univalue.h>
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index ed0134375c..d586f6d4aa 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -1081,7 +1081,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
CTxOut txout(recipient.nAmount, GetScriptForDestination(recipient.dest));
// Include the fee cost for outputs.
- coin_selection_params.tx_noinputs_size += ::GetSerializeSize(txout, PROTOCOL_VERSION);
+ coin_selection_params.tx_noinputs_size += ::GetSerializeSize(txout);
if (IsDust(txout, wallet.chain().relayDustFee())) {
return util::Error{_("Transaction amount too small")};
@@ -1257,7 +1257,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
}
// Before we return success, we assume any change key will be used to prevent
- // accidental re-use.
+ // accidental reuse.
reservedest.KeepDestination();
wallet.WalletLogPrintf("Fee Calculation: Fee:%d Bytes:%u Tgt:%d (requested %d) Reason:\"%s\" Decay %.5f: Estimation: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out) Fail: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out)\n",
@@ -1299,7 +1299,7 @@ util::Result<CreatedTransactionResult> CreateTransaction(
CCoinControl tmp_cc = coin_control;
tmp_cc.m_avoid_partial_spends = true;
- // Re-use the change destination from the first creation attempt to avoid skipping BIP44 indexes
+ // Reuse the change destination from the first creation attempt to avoid skipping BIP44 indexes
const int ungrouped_change_pos = txr_ungrouped.change_pos;
if (ungrouped_change_pos != -1) {
ExtractDestination(txr_ungrouped.tx->vout[ungrouped_change_pos].scriptPubKey, tmp_cc.destChange);
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 0832887159..bc45010200 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -178,7 +178,7 @@ static const std::map<std::string,WalletFlags> WALLET_FLAG_MAP{
* Instantiating a ReserveDestination does not reserve an address. To do so,
* GetReservedDestination() needs to be called on the object. Once an address has been
* reserved, call KeepDestination() on the ReserveDestination object to make sure it is not
- * returned. Call ReturnDestination() to return the address so it can be re-used (for
+ * returned. Call ReturnDestination() to return the address so it can be reused (for
* example, if the address was used in a new transaction
* and that transaction was not completed and needed to be aborted).
*
diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp
index a4fb915d71..54d125e47b 100644
--- a/src/zmq/zmqpublishnotifier.cpp
+++ b/src/zmq/zmqpublishnotifier.cpp
@@ -19,7 +19,6 @@
#include <streams.h>
#include <sync.h>
#include <uint256.h>
-#include <version.h>
#include <zmq/zmqutil.h>
#include <zmq.h>
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
index d1232c5133..2e3589b020 100755
--- a/test/functional/feature_assumeutxo.py
+++ b/test/functional/feature_assumeutxo.py
@@ -75,7 +75,7 @@ class AssumeutxoTest(BitcoinTestFramework):
with self.nodes[1].assert_debug_log([log_msg]):
assert_raises_rpc_error(-32603, f"Unable to load UTXO snapshot{rpc_details}", self.nodes[1].loadtxoutset, bad_snapshot_path)
- self.log.info(" - snapshot file refering to a block that is not in the assumeutxo parameters")
+ self.log.info(" - snapshot file referring to a block that is not in the assumeutxo parameters")
prev_block_hash = self.nodes[0].getblockhash(SNAPSHOT_BASE_HEIGHT - 1)
bogus_block_hash = "0" * 64 # Represents any unknown block hash
for bad_block_hash in [bogus_block_hash, prev_block_hash]:
@@ -112,7 +112,7 @@ class AssumeutxoTest(BitcoinTestFramework):
def test_invalid_chainstate_scenarios(self):
self.log.info("Test different scenarios of invalid snapshot chainstate in datadir")
- self.log.info(" - snapshot chainstate refering to a block that is not in the assumeutxo parameters")
+ self.log.info(" - snapshot chainstate referring to a block that is not in the assumeutxo parameters")
self.stop_node(0)
chainstate_snapshot_path = self.nodes[0].chain_path / "chainstate_snapshot"
chainstate_snapshot_path.mkdir()
diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py
index c0679c5ba9..b81eae2506 100755
--- a/test/functional/interface_rest.py
+++ b/test/functional/interface_rest.py
@@ -65,7 +65,7 @@ class RESTTest (BitcoinTestFramework):
body: str = '',
status: int = 200,
ret_type: RetType = RetType.JSON,
- query_params: Optional[typing.Dict[str, typing.Any]] = None,
+ query_params: Optional[dict[str, typing.Any]] = None,
) -> typing.Union[http.client.HTTPResponse, bytes, str, None]:
rest_uri = '/rest' + uri
if req_type in ReqType:
diff --git a/test/functional/test_framework/blockfilter.py b/test/functional/test_framework/blockfilter.py
index 3d6b38a23d..a16aa3d34f 100644
--- a/test/functional/test_framework/blockfilter.py
+++ b/test/functional/test_framework/blockfilter.py
@@ -29,7 +29,7 @@ def bip158_basic_element_hash(script_pub_key, N, block_hash):
def bip158_relevant_scriptpubkeys(node, block_hash):
- """ Determines the basic filter relvant scriptPubKeys as defined in BIP158:
+ """ Determines the basic filter relevant scriptPubKeys as defined in BIP158:
'A basic filter MUST contain exactly the following items for each transaction in a block:
- The previous output script (the script being spent) for each input, except for
diff --git a/test/functional/test_framework/script.py b/test/functional/test_framework/script.py
index f4628bf4af..78d8580794 100644
--- a/test/functional/test_framework/script.py
+++ b/test/functional/test_framework/script.py
@@ -10,7 +10,6 @@ This file is modified from python-bitcoinlib.
from collections import namedtuple
import struct
import unittest
-from typing import List, Dict
from .key import TaggedHash, tweak_add_pubkey, compute_xonly_pubkey
@@ -110,8 +109,8 @@ class CScriptOp(int):
_opcode_instances.append(super().__new__(cls, n))
return _opcode_instances[n]
-OPCODE_NAMES: Dict[CScriptOp, str] = {}
-_opcode_instances: List[CScriptOp] = []
+OPCODE_NAMES: dict[CScriptOp, str] = {}
+_opcode_instances: list[CScriptOp] = []
# Populate opcode instance table
for n in range(0xff + 1):
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 70b3943478..0369b4be05 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -19,7 +19,6 @@ import sys
import tempfile
import time
-from typing import List
from .address import create_deterministic_address_bcrt1_p2tr_op_true
from .authproxy import JSONRPCException
from . import coverage
@@ -97,7 +96,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
"""Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method"""
self.chain: str = 'regtest'
self.setup_clean_chain: bool = False
- self.nodes: List[TestNode] = []
+ self.nodes: list[TestNode] = []
self.extra_args = None
self.network_thread = None
self.rpc_timeout = 60 # Wait for up to 60 seconds for the RPC server to respond
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index 104f158d92..c65e3e38e6 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -19,7 +19,8 @@ import time
from . import coverage
from .authproxy import AuthServiceProxy, JSONRPCException
-from typing import Callable, Optional, Tuple
+from collections.abc import Callable
+from typing import Optional
logger = logging.getLogger("TestFramework.utils")
@@ -409,7 +410,7 @@ def get_datadir_path(dirname, n):
return pathlib.Path(dirname) / f"node{n}"
-def get_temp_default_datadir(temp_dir: pathlib.Path) -> Tuple[dict, pathlib.Path]:
+def get_temp_default_datadir(temp_dir: pathlib.Path) -> tuple[dict, pathlib.Path]:
"""Return os-specific environment variables that can be set to make the
GetDefaultDataDir() function return a datadir path under the provided
temp_dir, as well as the complete path it would return."""
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index 035a482f4c..53c8e1b0cc 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -9,7 +9,6 @@ from decimal import Decimal
from enum import Enum
from typing import (
Any,
- List,
Optional,
)
from test_framework.address import (
@@ -284,7 +283,7 @@ class MiniWallet:
def create_self_transfer_multi(
self,
*,
- utxos_to_spend: Optional[List[dict]] = None,
+ utxos_to_spend: Optional[list[dict]] = None,
num_outputs=1,
amount_per_output=0,
locktime=0,
diff --git a/test/functional/wallet_avoidreuse.py b/test/functional/wallet_avoidreuse.py
index c257bda452..9d3c55d6b6 100755
--- a/test/functional/wallet_avoidreuse.py
+++ b/test/functional/wallet_avoidreuse.py
@@ -257,7 +257,7 @@ class AvoidReuseTest(BitcoinTestFramework):
if not self.options.descriptors:
# For the second send, we transmute it to a related single-key address
- # to make sure it's also detected as re-use
+ # to make sure it's also detected as reuse
fund_spk = address_to_scriptpubkey(fundaddr).hex()
fund_decoded = self.nodes[0].decodescript(fund_spk)
if second_addr_type == "p2sh-segwit":
diff --git a/test/functional/wallet_fast_rescan.py b/test/functional/wallet_fast_rescan.py
index 2f9c924e71..1315bccafd 100755
--- a/test/functional/wallet_fast_rescan.py
+++ b/test/functional/wallet_fast_rescan.py
@@ -4,8 +4,6 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test that fast rescan using block filters for descriptor wallets detects
top-ups correctly and finds the same transactions than the slow variant."""
-from typing import List
-
from test_framework.address import address_to_scriptpubkey
from test_framework.descriptors import descsum_create
from test_framework.test_framework import BitcoinTestFramework
@@ -32,7 +30,7 @@ class WalletFastRescanTest(BitcoinTestFramework):
self.skip_if_no_wallet()
self.skip_if_no_sqlite()
- def get_wallet_txids(self, node: TestNode, wallet_name: str) -> List[str]:
+ def get_wallet_txids(self, node: TestNode, wallet_name: str) -> list[str]:
w = node.get_wallet_rpc(wallet_name)
txs = w.listtransactions('*', 1000000)
return [tx['txid'] for tx in txs]
diff --git a/test/lint/lint-files.py b/test/lint/lint-files.py
index f2b5db681b..86fe727b06 100755
--- a/test/lint/lint-files.py
+++ b/test/lint/lint-files.py
@@ -11,7 +11,7 @@ import os
import re
import sys
from subprocess import check_output
-from typing import Dict, Optional, NoReturn
+from typing import Optional, NoReturn
CMD_TOP_LEVEL = ["git", "rev-parse", "--show-toplevel"]
CMD_ALL_FILES = ["git", "ls-files", "-z", "--full-name", "--stage"]
@@ -69,7 +69,7 @@ class FileMeta(object):
return None
-def get_git_file_metadata() -> Dict[str, FileMeta]:
+def get_git_file_metadata() -> dict[str, FileMeta]:
'''
Return a dictionary mapping the name of all files in the repository to git tree metadata.
'''
diff --git a/test/lint/lint-include-guards.py b/test/lint/lint-include-guards.py
index 48b918e9da..291e528c1d 100755
--- a/test/lint/lint-include-guards.py
+++ b/test/lint/lint-include-guards.py
@@ -11,7 +11,6 @@ Check include guards.
import re
import sys
from subprocess import check_output
-from typing import List
HEADER_ID_PREFIX = 'BITCOIN_'
@@ -28,7 +27,7 @@ EXCLUDE_FILES_WITH_PREFIX = ['contrib/devtools/bitcoin-tidy',
'src/test/fuzz/FuzzedDataProvider.h']
-def _get_header_file_lst() -> List[str]:
+def _get_header_file_lst() -> list[str]:
""" Helper function to get a list of header filepaths to be
checked for include guards.
"""
diff --git a/test/lint/spelling.ignore-words.txt b/test/lint/spelling.ignore-words.txt
index ecc2a553d2..cb0e0c4d31 100644
--- a/test/lint/spelling.ignore-words.txt
+++ b/test/lint/spelling.ignore-words.txt
@@ -6,6 +6,7 @@ bu
cachable
clen
crypted
+debbugs
fo
fpr
hights