0
0
mirror of https://github.com/namecoin/namecoin-core synced 2025-10-06 00:22:46 +02:00

Merge branch 'auxpow'

This commit is contained in:
Daniel Kraft
2025-06-16 07:42:24 +02:00
209 changed files with 1664 additions and 1428 deletions

60
.github/ci-test-each-commit-exec.py vendored Executable file
View File

@@ -0,0 +1,60 @@
#!/usr/bin/env python3
# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
import subprocess
import sys
import shlex
def run(cmd, **kwargs):
print("+ " + shlex.join(cmd), flush=True)
try:
return subprocess.run(cmd, check=True, **kwargs)
except Exception as e:
sys.exit(e)
def main():
print("Running test-one-commit on ...")
run(["git", "log", "-1"])
num_procs = int(run(["nproc"], stdout=subprocess.PIPE).stdout)
# Use clang++, because it is a bit faster and uses less memory than g++
run([
"cmake",
"-B",
"build",
"-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang++",
"-DWERROR=ON",
"-DWITH_ZMQ=ON",
"-DBUILD_GUI=ON",
"-DBUILD_BENCH=ON",
"-DBUILD_FUZZ_BINARY=ON",
"-DWITH_USDT=ON",
"-DCMAKE_CXX_FLAGS=-Wno-error=unused-member-function",
])
run(["cmake", "--build", "build", "-j", str(num_procs)])
run([
"ctest",
"--output-on-failure",
"--stop-on-failure",
"--test-dir",
"build",
"-j",
str(num_procs),
])
run([
sys.executable,
"./build/test/functional/test_runner.py",
"-j",
str(num_procs * 2),
"--combinedlogslen=99999999",
])
if __name__ == "__main__":
main()

View File

@@ -1,21 +0,0 @@
#!/usr/bin/env bash
#
# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL=C.UTF-8
set -o errexit -o pipefail -o xtrace
echo "Running test-one-commit on $( git log -1 )"
# Use clang++, because it is a bit faster and uses less memory than g++
CC=clang CXX=clang++ cmake -B build -DWERROR=ON -DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_USDT=ON -DCMAKE_CXX_FLAGS='-Wno-error=unused-member-function'
cmake --build build -j "$( nproc )"
ctest --output-on-failure --stop-on-failure --test-dir build -j "$( nproc )"
./build/test/functional/test_runner.py -j $(( $(nproc) * 2 )) --combinedlogslen=99999999

View File

@@ -1,6 +1,6 @@
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# file COPYING or https://opensource.org/license/mit.
name: CI
on:
@@ -81,7 +81,7 @@ jobs:
- name: Compile and run tests
run: |
# Run tests on commits after the last merge commit and before the PR head commit
git rebase --exec "git merge --no-commit origin/${GITHUB_BASE_REF} && ./.github/ci-test-each-commit-exec.sh && git reset --hard" ${{ env.TEST_BASE }}
git rebase --exec "git merge --no-commit origin/${GITHUB_BASE_REF} && python3 ./.github/ci-test-each-commit-exec.py && git reset --hard" ${{ env.TEST_BASE }}
macos-native-arm64:
name: ${{ matrix.job-name }}

View File

@@ -115,6 +115,7 @@ fixes or code moves with actual code changes.
Make sure each individual commit is hygienic: that it builds successfully on its
own without warnings, errors, regressions, or test failures.
This means tests must be updated in the same commit that changes the behavior.
Commit messages should be verbose by default consisting of a short subject line
(50 chars max), a blank line and detailed explanatory text as separate

View File

@@ -73,8 +73,8 @@ in Python.
These tests can be run (if the [test dependencies](/test) are installed) with: `build/test/functional/test_runner.py`
(assuming `build` is your build directory).
The CI (Continuous Integration) systems make sure that every pull request is built for Windows, Linux, and macOS,
and that unit/sanity tests are run automatically.
The CI (Continuous Integration) systems make sure that every pull request is tested on Windows, Linux, and macOS.
The CI must pass on all commits before merge to avoid unrelated CI failures on new pull requests.
### Manual Quality Assurance (QA) Testing

View File

@@ -38,7 +38,7 @@ python3 --version
${CI_RETRY_EXE} pip3 install \
codespell==2.4.1 \
lief==0.13.2 \
lief==0.16.6 \
mypy==1.4.1 \
pyzmq==25.1.0 \
ruff==0.5.5 \

View File

@@ -69,6 +69,24 @@ fi
mkdir -p "$VERSION_BASE"
################
# SOURCE_DATE_EPOCH should not unintentionally be set
################
if [ -n "$SOURCE_DATE_EPOCH" ] && [ -z "$FORCE_SOURCE_DATE_EPOCH" ]; then
cat << EOF
ERR: Environment variable SOURCE_DATE_EPOCH is set which may break reproducibility.
Aborting...
Hint: You may want to:
1. Unset this variable: \`unset SOURCE_DATE_EPOCH\` before rebuilding
2. Set the 'FORCE_SOURCE_DATE_EPOCH' environment variable if you insist on
using your own epoch
EOF
exit 1
fi
################
# Build directories should not exist
################

View File

@@ -15,8 +15,10 @@
(gnu packages ninja)
(gnu packages pkg-config)
((gnu packages python) #:select (python-minimal))
((gnu packages python-build) #:select (python-tomli python-poetry-core))
((gnu packages python-build) #:select (python-poetry-core))
((gnu packages python-crypto) #:select (python-asn1crypto))
((gnu packages python-science) #:select (python-scikit-build-core))
((gnu packages python-xyz) #:select (python-pydantic-2 python-pydantic-core))
((gnu packages tls) #:select (openssl))
((gnu packages version-control) #:select (git-minimal))
(guix build-system cmake)
@@ -158,37 +160,35 @@ chain for " target " development."))
(define-public python-lief
(package
(name "python-lief")
(version "0.13.2")
(version "0.16.6")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/lief-project/LIEF")
(commit version)))
(file-name (git-file-name name version))
(modules '((guix build utils)))
(snippet
'(begin
;; Configure build for Python bindings.
(substitute* "api/python/config-default.toml"
(("(ninja = )true" all m)
(string-append m "false"))
(("(parallel-jobs = )0" all m)
(string-append m (number->string (parallel-job-count)))))))
(sha256
(base32
"0y48x358ppig5xp97ahcphfipx7cg9chldj2q5zrmn610fmi4zll"))))
(build-system python-build-system)
(native-inputs (list cmake-minimal python-tomli))
"1pq9nagrnkl1x943bqnpiyxmkd9vk99znfxiwqp6vf012b50bz2a"))
(patches (search-our-patches "lief-scikit-0-9.patch"))))
(build-system pyproject-build-system)
(native-inputs (list cmake-minimal
ninja
python-scikit-build-core
python-pydantic-core
python-pydantic-2))
(arguments
(list
#:tests? #f ;needs network
#:phases #~(modify-phases %standard-phases
(add-before 'build 'change-directory
(add-before 'build 'set-pythonpath
(lambda _
(chdir "api/python")))
(replace 'build
(setenv "PYTHONPATH"
(string-append (string-append (getcwd) "/api/python/backend")
":" (or (getenv "PYTHONPATH") "")))))
(add-after 'set-pythonpath 'change-directory
(lambda _
(invoke "python" "setup.py" "build"))))))
(chdir "api/python"))))))
(home-page "https://github.com/lief-project/LIEF")
(synopsis "Library to instrument executable formats")
(description

View File

@@ -0,0 +1,21 @@
Partially revert f23ced2f4ffc170d0a6f40ff4a1bee575e3447cf
Restore compat with python-scikit-build-core 0.9.x
Can be dropped when using python-scikit-build-core >= 0.10.x
--- a/api/python/backend/setup.py
+++ b/api/python/backend/setup.py
@@ -101,12 +101,12 @@ def _get_hooked_config(is_editable: bool) -> Optional[dict[str, Union[str, List[
config_settings = {
"logging.level": "DEBUG",
"build-dir": config.build_dir,
- "build.targets": config.build.targets,
"install.strip": config.strip,
"backport.find-python": "0",
"wheel.py-api": config.build.py_api,
"cmake.source-dir": SRC_DIR.as_posix(),
"cmake.build-type": config.build.build_type,
+ "cmake.targets": config.build.targets,
"cmake.args": [
*config.cmake_generator,
*config.get_cmake_args(is_editable),

View File

@@ -30,13 +30,13 @@ def check_ELF_RELRO(binary) -> bool:
# However, the dynamic linker need to write to this area so these are RW.
# Glibc itself takes care of mprotecting this area R after relocations are finished.
# See also https://marc.info/?l=binutils&m=1498883354122353
if segment.type == lief.ELF.SEGMENT_TYPES.GNU_RELRO:
if segment.type == lief.ELF.Segment.TYPE.GNU_RELRO:
have_gnu_relro = True
have_bindnow = False
try:
flags = binary.get(lief.ELF.DYNAMIC_TAGS.FLAGS)
if flags.value & lief.ELF.DYNAMIC_FLAGS.BIND_NOW:
flags = binary.get(lief.ELF.DynamicEntry.TAG.FLAGS)
if flags.has(lief.ELF.DynamicEntryFlags.FLAG.BIND_NOW):
have_bindnow = True
except Exception:
have_bindnow = False
@@ -55,9 +55,9 @@ def check_ELF_SEPARATE_CODE(binary):
based on their permissions. This checks for missing -Wl,-z,separate-code
and potentially other problems.
'''
R = lief.ELF.SEGMENT_FLAGS.R
W = lief.ELF.SEGMENT_FLAGS.W
E = lief.ELF.SEGMENT_FLAGS.X
R = lief.ELF.Segment.FLAGS.R
W = lief.ELF.Segment.FLAGS.W
E = lief.ELF.Segment.FLAGS.X
EXPECTED_FLAGS = {
# Read + execute
'.init': R | E,
@@ -99,7 +99,7 @@ def check_ELF_SEPARATE_CODE(binary):
# and for each section, remember the flags of the associated program header.
flags_per_section = {}
for segment in binary.segments:
if segment.type == lief.ELF.SEGMENT_TYPES.LOAD:
if segment.type == lief.ELF.Segment.TYPE.LOAD:
for section in segment.sections:
flags_per_section[section.name] = segment.flags
# Spot-check ELF LOAD program header flags per section
@@ -144,13 +144,13 @@ def check_ELF_FORTIFY(binary) -> bool:
def check_PE_DYNAMIC_BASE(binary) -> bool:
'''PIE: DllCharacteristics bit 0x40 signifies dynamicbase (ASLR)'''
return lief.PE.DLL_CHARACTERISTICS.DYNAMIC_BASE in binary.optional_header.dll_characteristics_lists
return lief.PE.OptionalHeader.DLL_CHARACTERISTICS.DYNAMIC_BASE in binary.optional_header.dll_characteristics_lists
# Must support high-entropy 64-bit address space layout randomization
# in addition to DYNAMIC_BASE to have secure ASLR.
def check_PE_HIGH_ENTROPY_VA(binary) -> bool:
'''PIE: DllCharacteristics bit 0x20 signifies high-entropy ASLR'''
return lief.PE.DLL_CHARACTERISTICS.HIGH_ENTROPY_VA in binary.optional_header.dll_characteristics_lists
return lief.PE.OptionalHeader.DLL_CHARACTERISTICS.HIGH_ENTROPY_VA in binary.optional_header.dll_characteristics_lists
def check_PE_RELOC_SECTION(binary) -> bool:
'''Check for a reloc section. This is required for functional ASLR.'''
@@ -181,7 +181,7 @@ def check_MACHO_NOUNDEFS(binary) -> bool:
'''
Check for no undefined references.
'''
return binary.header.has(lief.MachO.HEADER_FLAGS.NOUNDEFS)
return binary.header.has(lief.MachO.Header.FLAGS.NOUNDEFS)
def check_MACHO_FIXUP_CHAINS(binary) -> bool:
'''
@@ -206,7 +206,13 @@ def check_NX(binary) -> bool:
'''
Check for no stack execution
'''
return binary.has_nx
# binary.has_nx checks are only for the stack, but MachO binaries might
# have executable heaps.
if binary.format == lief.Binary.FORMATS.MACHO:
return binary.concrete.has_nx_stack and binary.concrete.has_nx_heap
else:
return binary.has_nx
def check_MACHO_CONTROL_FLOW(binary) -> bool:
'''
@@ -229,6 +235,7 @@ def check_MACHO_BRANCH_PROTECTION(binary) -> bool:
return False
BASE_ELF = [
('FORTIFY', check_ELF_FORTIFY),
('PIE', check_PIE),
('NX', check_NX),
('RELRO', check_ELF_RELRO),
@@ -253,21 +260,21 @@ BASE_MACHO = [
]
CHECKS = {
lief.EXE_FORMATS.ELF: {
lief.ARCHITECTURES.X86: BASE_ELF + [('CONTROL_FLOW', check_ELF_CONTROL_FLOW), ('FORTIFY', check_ELF_FORTIFY)],
lief.ARCHITECTURES.ARM: BASE_ELF + [('FORTIFY', check_ELF_FORTIFY)],
lief.ARCHITECTURES.ARM64: BASE_ELF + [('FORTIFY', check_ELF_FORTIFY)],
lief.ARCHITECTURES.PPC: BASE_ELF + [('FORTIFY', check_ELF_FORTIFY)],
lief.ARCHITECTURES.RISCV: BASE_ELF, # Skip FORTIFY. See https://github.com/lief-project/LIEF/issues/1082.
lief.Binary.FORMATS.ELF: {
lief.Header.ARCHITECTURES.X86_64: BASE_ELF + [('CONTROL_FLOW', check_ELF_CONTROL_FLOW)],
lief.Header.ARCHITECTURES.ARM: BASE_ELF,
lief.Header.ARCHITECTURES.ARM64: BASE_ELF,
lief.Header.ARCHITECTURES.PPC64: BASE_ELF,
lief.Header.ARCHITECTURES.RISCV: BASE_ELF,
},
lief.EXE_FORMATS.PE: {
lief.ARCHITECTURES.X86: BASE_PE,
lief.Binary.FORMATS.PE: {
lief.Header.ARCHITECTURES.X86_64: BASE_PE,
},
lief.EXE_FORMATS.MACHO: {
lief.ARCHITECTURES.X86: BASE_MACHO + [('PIE', check_PIE),
lief.Binary.FORMATS.MACHO: {
lief.Header.ARCHITECTURES.X86_64: BASE_MACHO + [('PIE', check_PIE),
('NX', check_NX),
('CONTROL_FLOW', check_MACHO_CONTROL_FLOW)],
lief.ARCHITECTURES.ARM64: BASE_MACHO + [('BRANCH_PROTECTION', check_MACHO_BRANCH_PROTECTION)],
lief.Header.ARCHITECTURES.ARM64: BASE_MACHO + [('BRANCH_PROTECTION', check_MACHO_BRANCH_PROTECTION)],
}
}
@@ -275,9 +282,9 @@ if __name__ == '__main__':
retval: int = 0
for filename in sys.argv[1:]:
binary = lief.parse(filename)
etype = binary.format
arch = binary.abstract.header.architecture
binary.concrete
failed: list[str] = []
for (name, func) in CHECKS[etype][arch]:

View File

@@ -34,7 +34,7 @@ import lief
MAX_VERSIONS = {
'GCC': (4,3,0),
'GLIBC': {
lief.ELF.ARCH.x86_64: (2,31),
lief.ELF.ARCH.X86_64: (2,31),
lief.ELF.ARCH.ARM: (2,31),
lief.ELF.ARCH.AARCH64:(2,31),
lief.ELF.ARCH.PPC64: (2,31),
@@ -52,41 +52,41 @@ 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]] = {
lief.ELF.ARCH.x86_64: {
lief.ENDIANNESS.LITTLE: "/lib64/ld-linux-x86-64.so.2",
ELF_INTERPRETER_NAMES: dict[lief.ELF.ARCH, dict[lief.Header.ENDIANNESS, str]] = {
lief.ELF.ARCH.X86_64: {
lief.Header.ENDIANNESS.LITTLE: "/lib64/ld-linux-x86-64.so.2",
},
lief.ELF.ARCH.ARM: {
lief.ENDIANNESS.LITTLE: "/lib/ld-linux-armhf.so.3",
lief.Header.ENDIANNESS.LITTLE: "/lib/ld-linux-armhf.so.3",
},
lief.ELF.ARCH.AARCH64: {
lief.ENDIANNESS.LITTLE: "/lib/ld-linux-aarch64.so.1",
lief.Header.ENDIANNESS.LITTLE: "/lib/ld-linux-aarch64.so.1",
},
lief.ELF.ARCH.PPC64: {
lief.ENDIANNESS.BIG: "/lib64/ld64.so.1",
lief.ENDIANNESS.LITTLE: "/lib64/ld64.so.2",
lief.Header.ENDIANNESS.BIG: "/lib64/ld64.so.1",
lief.Header.ENDIANNESS.LITTLE: "/lib64/ld64.so.2",
},
lief.ELF.ARCH.RISCV: {
lief.ENDIANNESS.LITTLE: "/lib/ld-linux-riscv64-lp64d.so.1",
lief.Header.ENDIANNESS.LITTLE: "/lib/ld-linux-riscv64-lp64d.so.1",
},
}
ELF_ABIS: dict[lief.ELF.ARCH, dict[lief.ENDIANNESS, list[int]]] = {
lief.ELF.ARCH.x86_64: {
lief.ENDIANNESS.LITTLE: [3,2,0],
ELF_ABIS: dict[lief.ELF.ARCH, dict[lief.Header.ENDIANNESS, list[int]]] = {
lief.ELF.ARCH.X86_64: {
lief.Header.ENDIANNESS.LITTLE: [3,2,0],
},
lief.ELF.ARCH.ARM: {
lief.ENDIANNESS.LITTLE: [3,2,0],
lief.Header.ENDIANNESS.LITTLE: [3,2,0],
},
lief.ELF.ARCH.AARCH64: {
lief.ENDIANNESS.LITTLE: [3,7,0],
lief.Header.ENDIANNESS.LITTLE: [3,7,0],
},
lief.ELF.ARCH.PPC64: {
lief.ENDIANNESS.LITTLE: [3,10,0],
lief.ENDIANNESS.BIG: [3,2,0],
lief.Header.ENDIANNESS.LITTLE: [3,10,0],
lief.Header.ENDIANNESS.BIG: [3,2,0],
},
lief.ELF.ARCH.RISCV: {
lief.ENDIANNESS.LITTLE: [4,15,0],
lief.Header.ENDIANNESS.LITTLE: [4,15,0],
},
}
@@ -223,13 +223,13 @@ def check_exported_symbols(binary) -> bool:
name = symbol.name
if binary.header.machine_type == lief.ELF.ARCH.RISCV or name in IGNORE_EXPORTS:
continue
print(f'{binary.name}: export of symbol {name} not allowed!')
print(f'{filename}: export of symbol {name} not allowed!')
ok = False
return ok
def check_RUNPATH(binary) -> bool:
assert binary.get(lief.ELF.DYNAMIC_TAGS.RUNPATH) is None
assert binary.get(lief.ELF.DYNAMIC_TAGS.RPATH) is None
assert binary.get(lief.ELF.DynamicEntry.TAG.RUNPATH) is None
assert binary.get(lief.ELF.DynamicEntry.TAG.RPATH) is None
return True
def check_ELF_libraries(binary) -> bool:
@@ -294,12 +294,12 @@ def check_ELF_interpreter(binary) -> bool:
def check_ELF_ABI(binary) -> bool:
expected_abi = ELF_ABIS[binary.header.machine_type][binary.abstract.header.endianness]
note = binary.concrete.get(lief.ELF.NOTE_TYPES.ABI_TAG)
assert note.details.abi == lief.ELF.NOTE_ABIS.LINUX
return note.details.version == expected_abi
note = binary.concrete.get(lief.ELF.Note.TYPE.GNU_ABI_TAG)
assert note.abi == lief.ELF.NoteAbi.ABI.LINUX
return note.version == expected_abi
CHECKS = {
lief.EXE_FORMATS.ELF: [
lief.Binary.FORMATS.ELF: [
('IMPORTED_SYMBOLS', check_imported_symbols),
('EXPORTED_SYMBOLS', check_exported_symbols),
('LIBRARY_DEPENDENCIES', check_ELF_libraries),
@@ -307,13 +307,13 @@ lief.EXE_FORMATS.ELF: [
('ABI', check_ELF_ABI),
('RUNPATH', check_RUNPATH),
],
lief.EXE_FORMATS.MACHO: [
lief.Binary.FORMATS.MACHO: [
('DYNAMIC_LIBRARIES', check_MACHO_libraries),
('MIN_OS', check_MACHO_min_os),
('SDK', check_MACHO_sdk),
('LLD', check_MACHO_lld),
],
lief.EXE_FORMATS.PE: [
lief.Binary.FORMATS.PE: [
('DYNAMIC_LIBRARIES', check_PE_libraries),
('SUBSYSTEM_VERSION', check_PE_subsystem_version),
('APPLICATION_MANIFEST', check_PE_application_manifest),
@@ -324,6 +324,7 @@ if __name__ == '__main__':
retval: int = 0
for filename in sys.argv[1:]:
binary = lief.parse(filename)
etype = binary.format
failed: list[str] = []

View File

@@ -40,8 +40,7 @@ def signet_txs(block, challenge):
txs[0].vout[-1].scriptPubKey += CScriptOp.encode_op_pushdata(SIGNET_HEADER)
hashes = []
for tx in txs:
tx.rehash()
hashes.append(ser_uint256(tx.sha256))
hashes.append(ser_uint256(tx.txid_int))
mroot = block.get_merkle_root(hashes)
sd = b""
@@ -55,12 +54,11 @@ def signet_txs(block, challenge):
to_spend.nLockTime = 0
to_spend.vin = [CTxIn(COutPoint(0, 0xFFFFFFFF), b"\x00" + CScriptOp.encode_op_pushdata(sd), 0)]
to_spend.vout = [CTxOut(0, challenge)]
to_spend.rehash()
spend = CTransaction()
spend.version = 0
spend.nLockTime = 0
spend.vin = [CTxIn(COutPoint(to_spend.sha256, 0), b"", 0)]
spend.vin = [CTxIn(COutPoint(to_spend.txid_int, 0), b"", 0)]
spend.vout = [CTxOut(0, b"\x6a")]
return spend, to_spend
@@ -88,7 +86,6 @@ def finish_block(block, signet_solution, grind_cmd):
pass # Don't need to add a signet commitment if there's no signet signature needed
else:
block.vtx[0].vout[-1].scriptPubKey += CScriptOp.encode_op_pushdata(SIGNET_HEADER + signet_solution)
block.vtx[0].rehash()
block.hashMerkleRoot = block.calc_merkle_root()
if grind_cmd is None:
block.solve()
@@ -111,7 +108,6 @@ def new_block(tmpl, reward_spk, *, blocktime=None, poolid=None):
cbtx.vin = [CTxIn(COutPoint(0, 0xffffffff), scriptSig, MAX_SEQUENCE_NONFINAL)]
cbtx.vout = [CTxOut(tmpl["coinbasevalue"], reward_spk)]
cbtx.vin[0].nSequence = 2**32-2
cbtx.rehash()
block = CBlock()
block.nVersion = tmpl["version"]
@@ -130,7 +126,6 @@ def new_block(tmpl, reward_spk, *, blocktime=None, poolid=None):
block.vtx[0].wit.vtxinwit = [cbwit]
block.vtx[0].vout.append(CTxOut(0, bytes(get_witness_script(witroot, witnonce))))
block.vtx[0].rehash()
block.hashMerkleRoot = block.calc_merkle_root()
return block

View File

@@ -31,7 +31,7 @@ To build dependencies for the current arch+OS:
### FreeBSD
pkg install bash
pkg install bash cmake curl gmake
To build dependencies for the current arch+OS:
@@ -39,7 +39,7 @@ To build dependencies for the current arch+OS:
### NetBSD
pkgin install bash gmake
pkgin install bash cmake curl gmake perl
To build dependencies for the current arch+OS:
@@ -47,7 +47,7 @@ To build dependencies for the current arch+OS:
### OpenBSD
pkg_add bash gmake gtar
pkg_add bash cmake curl gmake gtar
To build dependencies for the current arch+OS:

View File

@@ -1,7 +1,7 @@
build_openbsd_CC = clang
build_openbsd_CXX = clang++
build_openbsd_SHA256SUM = sha256
build_openbsd_SHA256SUM = sha256 -r
build_openbsd_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o
build_openbsd_TAR = gtar

View File

@@ -5,6 +5,7 @@ $(package)_download_file=$(native_$(package)_download_file)
$(package)_file_name=$(native_$(package)_file_name)
$(package)_sha256_hash=$(native_$(package)_sha256_hash)
$(package)_patches=abi_placement_new.patch
$(package)_patches += fix_openbsd_build.patch
define $(package)_set_vars
$(package)_config_opts := -DBUILD_TESTING=OFF
@@ -14,7 +15,8 @@ define $(package)_set_vars
endef
define $(package)_preprocess_cmds
patch -p2 < $($(package)_patch_dir)/abi_placement_new.patch
patch -p2 < $($(package)_patch_dir)/abi_placement_new.patch && \
patch -p2 < $($(package)_patch_dir)/fix_openbsd_build.patch
endef
define $(package)_config_cmds

View File

@@ -4,6 +4,7 @@ $(package)_download_path=https://download.savannah.gnu.org/releases/$(package)
$(package)_file_name=$(package)-$($(package)_version).tar.xz
$(package)_sha256_hash=8bee39bd3968c4804b70614a0a3ad597299ad0e824bc8aad5ce8aaf48067bde7
$(package)_build_subdir=build
$(package)_patches += cmake_minimum.patch
define $(package)_set_vars
$(package)_config_opts := -DCMAKE_BUILD_TYPE=None -DBUILD_SHARED_LIBS=TRUE
@@ -12,6 +13,10 @@ define $(package)_set_vars
$(package)_config_opts += -DCMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE
endef
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/cmake_minimum.patch
endef
define $(package)_config_cmds
$($(package)_cmake) -S .. -B .
endef

View File

@@ -4,6 +4,7 @@ $(package)_download_path=https://capnproto.org/
$(package)_download_file=capnproto-c++-$($(package)_version).tar.gz
$(package)_file_name=capnproto-cxx-$($(package)_version).tar.gz
$(package)_sha256_hash=07167580e563f5e821e3b2af1c238c16ec7181612650c5901330fa9a0da50939
$(package)_patches=fix_openbsd_build.patch
define $(package)_set_vars
$(package)_config_opts := -DBUILD_TESTING=OFF
@@ -11,6 +12,10 @@ define $(package)_set_vars
$(package)_config_opts += -DWITH_ZLIB=OFF
endef
define $(package)_preprocess_cmds
patch -p2 < $($(package)_patch_dir)/fix_openbsd_build.patch
endef
define $(package)_config_cmds
$($(package)_cmake) .
endef

View File

@@ -0,0 +1,71 @@
From 0cd1792332dce6a3afae6e2bc2939da69fea65fa Mon Sep 17 00:00:00 2001
From: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
Date: Sat, 31 May 2025 00:49:44 +0200
Subject: [PATCH 1/2] In cidr.c++, include <netinet/in.h> on all non-Windows
systems
The motivation for this commit is to fix the build for OpenBSD,
but it may also solves the same potential problem for other systems
without causing any harm.
Suggested already twice, see
https://github.com/capnproto/capnproto/pull/1846#discussion_r1399499535
https://github.com/capnproto/capnproto/pull/1907#discussion_r1452602424
---
c++/src/kj/cidr.c++ | 3 ---
1 file changed, 3 deletions(-)
diff --git a/c++/src/kj/cidr.c++ b/c++/src/kj/cidr.c++
index 6a1fa32e..9432b8f4 100644
--- a/c++/src/kj/cidr.c++
+++ b/c++/src/kj/cidr.c++
@@ -39,9 +39,6 @@
#else
#include <sys/socket.h>
#include <arpa/inet.h>
-#endif
-
-#if __FreeBSD__
#include <netinet/in.h>
#endif
--
2.49.0
From 2e76d17db3fc484061487c0779b16495939d30c3 Mon Sep 17 00:00:00 2001
From: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
Date: Sat, 31 May 2025 01:06:42 +0200
Subject: [PATCH 2/2] Don't set KJ_USE_KQUEUE on OpenBSD
OpenBSD doesn't support user event filters yet, hence
the build fails as it misses the symbol EVFILT_USER in
the kqueue implementation in async-unix.c++. Fix that
by not setting KJ_USE_KQUEUE on OpenBSD, so the poll()-
based implementation is used instead.
Suggested in
https://github.com/capnproto/capnproto/pull/1907/commits/829d3f03735f8f6762a50fc346db56bf02140f02#r1452600300
---
c++/src/kj/async-unix.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/c++/src/kj/async-unix.h b/c++/src/kj/async-unix.h
index 665305ea..e66ad8e4 100644
--- a/c++/src/kj/async-unix.h
+++ b/c++/src/kj/async-unix.h
@@ -37,8 +37,9 @@ KJ_BEGIN_HEADER
#if __linux__
// Default to epoll on Linux.
#define KJ_USE_EPOLL 1
-#elif __APPLE__ || __FreeBSD__ || __OpenBSD__ || __NetBSD__ || __DragonFly__
-// MacOS and BSDs prefer kqueue() for event notification.
+#elif __APPLE__ || __FreeBSD__ || __NetBSD__ || __DragonFly__
+// MacOS and most BSDs prefer kqueue() for event notification.
+// (Note that OpenBSD's kqueue(2) doesn't support user event filters yet)
#define KJ_USE_KQUEUE 1
#endif
#endif
--
2.49.0

View File

@@ -0,0 +1,13 @@
build: set minimum required CMake to 3.12
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -97,7 +97,7 @@
# FreeType explicitly marks the API to be exported and relies on the compiler
# to hide all other symbols. CMake supports a C_VISBILITY_PRESET property
# starting with 2.8.12.
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.12)
if (NOT CMAKE_VERSION VERSION_LESS 3.3)
# Allow symbol visibility settings also on static libraries. CMake < 3.3

View File

@@ -0,0 +1,71 @@
From 0cd1792332dce6a3afae6e2bc2939da69fea65fa Mon Sep 17 00:00:00 2001
From: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
Date: Sat, 31 May 2025 00:49:44 +0200
Subject: [PATCH 1/2] In cidr.c++, include <netinet/in.h> on all non-Windows
systems
The motivation for this commit is to fix the build for OpenBSD,
but it may also solves the same potential problem for other systems
without causing any harm.
Suggested already twice, see
https://github.com/capnproto/capnproto/pull/1846#discussion_r1399499535
https://github.com/capnproto/capnproto/pull/1907#discussion_r1452602424
---
c++/src/kj/cidr.c++ | 3 ---
1 file changed, 3 deletions(-)
diff --git a/c++/src/kj/cidr.c++ b/c++/src/kj/cidr.c++
index 6a1fa32e..9432b8f4 100644
--- a/c++/src/kj/cidr.c++
+++ b/c++/src/kj/cidr.c++
@@ -39,9 +39,6 @@
#else
#include <sys/socket.h>
#include <arpa/inet.h>
-#endif
-
-#if __FreeBSD__
#include <netinet/in.h>
#endif
--
2.49.0
From 2e76d17db3fc484061487c0779b16495939d30c3 Mon Sep 17 00:00:00 2001
From: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
Date: Sat, 31 May 2025 01:06:42 +0200
Subject: [PATCH 2/2] Don't set KJ_USE_KQUEUE on OpenBSD
OpenBSD doesn't support user event filters yet, hence
the build fails as it misses the symbol EVFILT_USER in
the kqueue implementation in async-unix.c++. Fix that
by not setting KJ_USE_KQUEUE on OpenBSD, so the poll()-
based implementation is used instead.
Suggested in
https://github.com/capnproto/capnproto/pull/1907/commits/829d3f03735f8f6762a50fc346db56bf02140f02#r1452600300
---
c++/src/kj/async-unix.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/c++/src/kj/async-unix.h b/c++/src/kj/async-unix.h
index 665305ea..e66ad8e4 100644
--- a/c++/src/kj/async-unix.h
+++ b/c++/src/kj/async-unix.h
@@ -37,8 +37,9 @@ KJ_BEGIN_HEADER
#if __linux__
// Default to epoll on Linux.
#define KJ_USE_EPOLL 1
-#elif __APPLE__ || __FreeBSD__ || __OpenBSD__ || __NetBSD__ || __DragonFly__
-// MacOS and BSDs prefer kqueue() for event notification.
+#elif __APPLE__ || __FreeBSD__ || __NetBSD__ || __DragonFly__
+// MacOS and most BSDs prefer kqueue() for event notification.
+// (Note that OpenBSD's kqueue(2) doesn't support user event filters yet)
#define KJ_USE_KQUEUE 1
#endif
#endif
--
2.49.0

View File

@@ -1,6 +1,6 @@
# FreeBSD Build Guide
**Updated for FreeBSD [14.0](https://www.freebsd.org/releases/14.0R/announce/)**
**Updated for FreeBSD [14.3](https://www.freebsd.org/releases/14.3R/announce/)**
This guide describes how to build bitcoind, command-line utilities, and GUI on FreeBSD.
@@ -41,7 +41,7 @@ Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compi
the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
```bash
pkg install qt6-buildtools qt6-core qt6-gui qt6-linguisttools qt6-testlib qt6-widgets
pkg install qt6-base qt6-tools
```
###### libqrencode

View File

@@ -56,7 +56,7 @@ SQLite is required for the descriptor wallet:
To build Namecoin Core without wallet, see [*Disable-wallet mode*](#disable-wallet-mode)
ZMQ dependencies (provides ZMQ API):
ZMQ-enabled binaries are compiled with `-DWITH_ZMQ=ON` and require the following dependency:
sudo apt-get install libzmq3-dev
@@ -107,7 +107,7 @@ SQLite is required for the descriptor wallet:
To build Namecoin Core without wallet, see [*Disable-wallet mode*](#disable-wallet-mode)
ZMQ dependencies (provides ZMQ API):
ZMQ-enabled binaries are compiled with `-DWITH_ZMQ=ON` and require the following dependency:
sudo dnf install zeromq-devel
@@ -115,7 +115,7 @@ User-Space, Statically Defined Tracing (USDT) dependencies:
sudo dnf install systemtap-sdt-devel
IPC-enabled binaries are compiled with `-DENABLE_IPC=ON` and require the following dependency.
IPC-enabled binaries are compiled with `-DENABLE_IPC=ON` and require the following dependency.
Skip if you do not need IPC functionality.
sudo dnf install capnproto

View File

@@ -784,38 +784,6 @@ Threads
- [ThreadI2PAcceptIncoming (`b-i2paccept`)](https://doxygen.bitcoincore.org/class_c_connman.html#a57787b4f9ac847d24065fbb0dd6e70f8)
: Listens for and accepts incoming I2P connections through the I2P SAM proxy.
Ignoring IDE/editor files
--------------------------
In closed-source environments in which everyone uses the same IDE, it is common
to add temporary files it produces to the project-wide `.gitignore` file.
However, in open source software such as Bitcoin Core, where everyone uses
their own editors/IDE/tools, it is less common. Only you know what files your
editor produces and this may change from version to version. The canonical way
to do this is thus to create your local gitignore. Add this to `~/.gitconfig`:
```
[core]
excludesfile = /home/.../.gitignore_global
```
(alternatively, type the command `git config --global core.excludesfile ~/.gitignore_global`
on a terminal)
Then put your favourite tool's temporary filenames in that file, e.g.
```
# NetBeans
nbproject/
```
Another option is to create a per-repository excludes file `.git/info/exclude`.
These are not committed but apply only to one repository.
If a set of tools is used by the build system or scripts the repository (for
example, lcov) it is perfectly acceptable to add its files to `.gitignore`
and commit them.
Development guidelines
============================
@@ -830,15 +798,6 @@ General Bitcoin Core
- *Rationale*: RPC allows for better automatic testing. The test suite for
the GUI is very limited.
- Make sure pull requests pass CI before merging.
- *Rationale*: Makes sure that they pass thorough testing, and that the tester will keep passing
on the master branch. Otherwise, all new pull requests will start failing the tests, resulting in
confusion and mayhem.
- *Explanation*: If the test suite is to be updated for a change, this has to
be done first.
Logging
-------
@@ -878,11 +837,6 @@ Note that the format strings and parameters of `LogDebug` and `LogTrace`
are only evaluated if the logging category is enabled, so you must be
careful to avoid side-effects in those expressions.
Wallet
-------
- Make sure that no crashes happen with run-time option `-disablewallet`.
General C++
-------------
@@ -1008,7 +962,7 @@ Strings and formatting
buffer overflows, and surprises with `\0` characters. Also, some C string manipulations
tend to act differently depending on platform, or even the user locale.
- For `strprintf`, `LogInfo`, `LogDebug`, etc formatting characters don't need size specifiers.
- For `strprintf`, `LogInfo`, `LogDebug`, etc formatting characters don't need size specifiers (hh, h, l, ll, j, z, t, L) for arithmetic types.
- *Rationale*: Bitcoin Core uses tinyformat, which is type safe. Leave them out to avoid confusion.
@@ -1032,7 +986,7 @@ Strings and formatting
- In cases where you do call `.c_str()`, you might want to additionally check that the string does not contain embedded '\0' characters, because
it will (necessarily) truncate the string. This might be used to hide parts of the string from logging or to circumvent
checks. If a use of strings is sensitive to this, take care to check the string for embedded NULL characters first
and reject it if there are any (see `ParsePrechecks` in `strencodings.cpp` for an example).
and reject it if there are any.
Shadowing
--------------
@@ -1159,27 +1113,7 @@ TRY_LOCK(cs_vNodes, lockNodes);
Scripts
--------------------------
Write scripts in Python rather than bash, when possible.
### Shebang
- Use `#!/usr/bin/env bash` instead of obsolete `#!/bin/bash`.
- [*Rationale*](https://github.com/dylanaraps/pure-bash-bible#shebang):
`#!/bin/bash` assumes it is always installed to /bin/ which can cause issues;
`#!/usr/bin/env bash` searches the user's PATH to find the bash binary.
OK:
```bash
#!/usr/bin/env bash
```
Wrong:
```bash
#!/bin/bash
```
Write scripts in Python or Rust rather than bash, when possible.
Source code organization
--------------------------
@@ -1189,12 +1123,6 @@ Source code organization
- *Rationale*: Shorter and simpler header files are easier to read and reduce compile time.
- Use only the lowercase alphanumerics (`a-z0-9`), underscore (`_`) and hyphen (`-`) in source code filenames.
- *Rationale*: `grep`:ing and auto-completing filenames is easier when using a consistent
naming pattern. Potential problems when building on case-insensitive filesystems are
avoided when using only lowercase characters in source code filenames.
- Every `.cpp` and `.h` file should `#include` every header file it directly uses classes, functions or other
definitions from, even if those headers are already included indirectly through other headers.
@@ -1222,24 +1150,6 @@ namespace {
- *Rationale*: Avoids confusion about the namespace context.
- Use `#include <primitives/transaction.h>` bracket syntax instead of
`#include "primitives/transactions.h"` quote syntax.
- *Rationale*: Bracket syntax is less ambiguous because the preprocessor
searches a fixed list of include directories without taking location of the
source file into account. This allows quoted includes to stand out more when
the location of the source file actually is relevant.
- Use include guards to avoid the problem of double inclusion. The header file
`foo/bar.h` should use the include guard identifier `BITCOIN_FOO_BAR_H`, e.g.
```c++
#ifndef BITCOIN_FOO_BAR_H
#define BITCOIN_FOO_BAR_H
...
#endif // BITCOIN_FOO_BAR_H
```
GUI
-----
@@ -1466,10 +1376,6 @@ A few guidelines for introducing and reviewing new RPC interfaces:
- *Rationale*: Integer verbosity allows for multiple values. Undocumented boolean verbosity is deprecated
and new RPC methods should prevent its use.
- Don't forget to fill in the argument names correctly in the RPC command table.
- *Rationale*: If not, the call cannot be used with name-based arguments.
- Add every non-string RPC argument `(method, idx, name)` to the table `vRPCConvertParams` in `rpc/client.cpp`.
- *Rationale*: `bitcoin-cli` and the GUI debug console use this table to determine how to
@@ -1501,17 +1407,6 @@ A few guidelines for introducing and reviewing new RPC interfaces:
until the wallet is caught up to the chainstate as of the RPC call's entry.
This also makes the API much easier for RPC clients to reason about.
- Be aware of RPC method aliases and generally avoid registering the same
callback function pointer for different RPCs.
- *Rationale*: RPC methods registered with the same function pointer will be
considered aliases and only the first method name will show up in the
`help` RPC command list.
- *Exception*: Using RPC method aliases may be appropriate in cases where a
new RPC is replacing a deprecated RPC, to avoid both RPCs confusingly
showing up in the command list.
- Use *invalid* bech32 addresses (e.g. in the constant array `EXAMPLE_ADDRESS`) for
`RPCExamples` help documentation.

View File

@@ -217,7 +217,7 @@ $ cd bitcoin/
$ git clone https://github.com/AFLplusplus/AFLplusplus
$ make -C AFLplusplus/ source-only
# If afl-clang-lto is not available, see
# https://github.com/AFLplusplus/AFLplusplus#a-selecting-the-best-afl-compiler-for-instrumenting-the-target
# https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/fuzzing_in_depth.md#a-selecting-the-best-afl-compiler-for-instrumenting-the-target
$ cmake -B build_fuzz \
-DCMAKE_C_COMPILER="$(pwd)/AFLplusplus/afl-clang-lto" \
-DCMAKE_CXX_COMPILER="$(pwd)/AFLplusplus/afl-clang-lto++" \
@@ -225,6 +225,8 @@ $ cmake -B build_fuzz \
$ cmake --build build_fuzz
# For macOS you may need to ignore x86 compilation checks when running "cmake --build". If so,
# try compiling using: AFL_NO_X86=1 cmake --build build_fuzz
# Also, it might be required to run "afl-system-config" to adjust the shared
# memory parameters.
$ mkdir -p inputs/ outputs/
$ echo A > inputs/thin-air-input
$ FUZZ=bech32 ./AFLplusplus/afl-fuzz -i inputs/ -o outputs/ -- build_fuzz/bin/fuzz

View File

@@ -0,0 +1,3 @@
- `-datacarriersize` is increased to 100,000 which effectively uncaps the limit (as the maximum transaction size limit will be hit first). It can be overridden with -datacarriersize=83 to revert to the limit enforced in previous versions. Both `-datacarrier` and `-datacarriersize` options have been marked as deprecated and are expected to be removed in a future release. (#32406)
- Multiple data carrier (OP_RETURN) outputs in a transaction are now permitted for relay and mining. The `-datacarriersize` limit applies to the aggregate size of the scriptPubKeys across all such outputs in a transaction, not including the scriptPubKey size itself. (#32406)

View File

@@ -34,33 +34,53 @@ You can use the `getnodeaddresses` RPC to fetch a number of onion peers known to
The first step is running Bitcoin Core behind a Tor proxy. This will already anonymize all
outgoing connections, but more is possible.
-proxy=ip:port Set the proxy server. If SOCKS5 is selected (default), this proxy
server will be used to try to reach .onion addresses as well.
You need to use -noonion or -onion=0 to explicitly disable
outbound access to onion services.
-proxy=ip[:port]
Set the proxy server. It will be used to try to reach .onion addresses
as well. You need to use -noonion or -onion=0 to explicitly disable
outbound access to onion services.
-onion=ip:port Set the proxy server to use for Tor onion services. You do not
need to set this if it's the same as -proxy. You can use -onion=0
to explicitly disable access to onion services.
------------------------------------------------------------------
Note: Only the -proxy option sets the proxy for DNS requests;
with -onion they will not route over Tor, so use -proxy if you
have privacy concerns.
------------------------------------------------------------------
-proxy=ip[:port]=tor
or
-onion=ip[:port]
Set the proxy server for reaching .onion addresses. You do not need to
set this if it's the same as the generic -proxy. You can use -onion=0 to
explicitly disable access to onion services.
------------------------------------------------------------------------
Note: The proxy for DNS requests is taken from
-proxy=addr:port or
-proxy=addr:port=ipv4 or
-proxy=addr:port=ipv6
(last one if multiple options are given). It is not taken from
-proxy=addr:port=tor or
-onion=addr:port.
If no proxy for DNS requests is configured, then they will be done using
the functions provided by the operating system, most likely resulting in
them being done over the clearnet to the DNS servers of the internet
service provider.
------------------------------------------------------------------------
-listen When using -proxy, listening is disabled by default. If you want
to manually configure an onion service (see section 3), you'll
need to enable it explicitly.
If -proxy or -onion is specified multiple times, later occurences override
earlier ones and command line overrides the config file. UNIX domain sockets may
be used for proxy connections. Set `-onion` or `-proxy` to the local socket path
with the prefix `unix:` (e.g. `-onion=unix:/home/me/torsocket`).
-connect=X When behind a Tor proxy, you can specify .onion addresses instead
-addnode=X of IP addresses or hostnames in these parameters. It requires
-seednode=X SOCKS5. In Tor mode, such addresses can also be exchanged with
other P2P nodes.
-listen
When using -proxy, listening is disabled by default. If you want to
manually configure an onion service (see section 3), you'll need to
enable it explicitly.
-onlynet=onion Make automatic outbound connections only to .onion addresses.
Inbound and manual connections are not affected by this option.
It can be specified multiple times to allow multiple networks,
e.g. onlynet=onion, onlynet=i2p, onlynet=cjdns.
-connect=X
-addnode=X
-seednode=X
When behind a Tor proxy, you can specify .onion addresses instead of IP
addresses or hostnames in these parameters. Such addresses can also be
exchanged with other P2P nodes.
-onlynet=onion
Make automatic outbound connections only to .onion addresses. Inbound
and manual connections are not affected by this option. It can be
specified multiple times to allow multiple networks, e.g. onlynet=onion,
onlynet=i2p, onlynet=cjdns.
In a typical situation, this suffices to run behind a Tor proxy:

View File

@@ -9,6 +9,7 @@ bugprone-lambda-function-name,
bugprone-unhandled-self-assignment,
misc-unused-using-decls,
misc-no-recursion,
modernize-deprecated-headers,
modernize-use-default-member-init,
modernize-use-emplace,
modernize-use-equals-default,
@@ -29,6 +30,8 @@ readability-redundant-string-init,
HeaderFilterRegex: '.'
WarningsAsErrors: '*'
CheckOptions:
- key: modernize-deprecated-headers.CheckHeaderFile
value: false
- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: false
- key: bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField

View File

@@ -9,8 +9,8 @@
#include <util/strencodings.h>
#include <util/string.h>
#include <assert.h>
#include <string.h>
#include <cassert>
#include <cstring>
#include <limits>

View File

@@ -1,5 +1,5 @@
// Copyright (c) 2017, 2021 Pieter Wuille
// Copyright (c) 2021-2022 The Bitcoin Core developers
// Copyright (c) 2021-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -7,7 +7,7 @@
#include <util/vector.h>
#include <array>
#include <assert.h>
#include <cassert>
#include <numeric>
#include <optional>

View File

@@ -1,5 +1,5 @@
// Copyright (c) 2017, 2021 Pieter Wuille
// Copyright (c) 2021 The Bitcoin Core developers
// Copyright (c) 2021-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -14,7 +14,7 @@
#ifndef BITCOIN_BECH32_H
#define BITCOIN_BECH32_H
#include <stdint.h>
#include <cstdint>
#include <string>
#include <vector>

View File

@@ -1,11 +1,11 @@
// Copyright (c) 2015-2022 The Bitcoin Core developers
// Copyright (c) 2015-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
// Extremely fast-running benchmark:
#include <math.h>
#include <cmath>
volatile double sum = 0.0; // volatile, global so not optimized away

View File

@@ -1,12 +1,13 @@
// Copyright (c) 2024- The Bitcoin Core developers
// Copyright (c) 2024-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <random.h>
#include <stddef.h>
#include <util/strencodings.h>
#include <cassert>
#include <cstddef>
#include <optional>
#include <vector>

View File

@@ -16,9 +16,9 @@
#include <uint256.h>
#include <algorithm>
#include <assert.h>
#include <cstdint>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <string>

View File

@@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Namecoin"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "namecoin-cli (JSON-RPC client for " CLIENT_NAME ")"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "namecoin-cli"

View File

@@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Bitcoin"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "bitcoin (Bitcoin wrapper executable that can call other executables)"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "bitcoin"

View File

@@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Namecoin"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "namecoin-tx (CLI Namecoin transaction editor utility)"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "namecoin-tx"

View File

@@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Bitcoin"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "bitcoin-util (CLI Bitcoin utility)"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "bitcoin-util"

View File

@@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Bitcoin"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "bitcoin-wallet (CLI tool for " CLIENT_NAME " wallets)"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "bitcoin-wallet"

View File

@@ -14,7 +14,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Namecoin"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", "namecoind (Namecoin node with a JSON-RPC server)"
VALUE "FileVersion", CLIENT_VERSION_STRING
VALUE "InternalName", "namecoind"

View File

@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2021 The Bitcoin Core developers
// Copyright (c) 2009-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -9,7 +9,7 @@
#include <tinyformat.h>
#include <util/chaintype.h>
#include <assert.h>
#include <cassert>
void SetupChainParamsBaseOptions(ArgsManager& argsman)
{

View File

@@ -6,11 +6,11 @@
#define BITCOIN_CLUSTER_LINEARIZE_H
#include <algorithm>
#include <cstdint>
#include <numeric>
#include <optional>
#include <stdint.h>
#include <vector>
#include <utility>
#include <vector>
#include <random.h>
#include <span.h>

View File

@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2022 The Bitcoin Core developers
// Copyright (c) 2009-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -17,8 +17,8 @@
#include <util/check.h>
#include <util/hasher.h>
#include <assert.h>
#include <stdint.h>
#include <cassert>
#include <cstdint>
#include <functional>
#include <unordered_map>

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2023 The Bitcoin Core developers
// Copyright (c) 2023-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -11,12 +11,12 @@
#include <util/chaintype.h>
#include <util/fs.h>
#include <cstdint>
#include <iosfwd>
#include <list>
#include <map>
#include <optional>
#include <set>
#include <stdint.h>
#include <string>
#include <variant>
#include <vector>

View File

@@ -1,13 +1,13 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2022 The Bitcoin Core developers
// Copyright (c) 2009-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CONSENSUS_CONSENSUS_H
#define BITCOIN_CONSENSUS_CONSENSUS_H
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
/** The maximum allowed size for a serialized block, in bytes (only for buffer size limits) */
static const unsigned int MAX_BLOCK_SERIALIZED_SIZE = 4000000;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2017-2021 The Bitcoin Core developers
// Copyright (c) 2017-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -7,7 +7,7 @@
#include <consensus/amount.h>
#include <stdint.h>
#include <cstdint>
#include <vector>
class CBlockIndex;

View File

@@ -1,10 +1,10 @@
// Copyright (c) 2016-2019 The Bitcoin Core developers
// Copyright (c) 2016-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <crypto/aes.h>
#include <string.h>
#include <cstring>
extern "C" {
#include <crypto/ctaes/ctaes.c>

View File

@@ -12,7 +12,7 @@
#include <algorithm>
#include <bit>
#include <string.h>
#include <cstring>
#define QUARTERROUND(a,b,c,d) \
a += b; d = std::rotl(d ^ a, 16); \

View File

@@ -9,8 +9,8 @@
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
#include <utility>
// classes for ChaCha20 256-bit stream cipher developed by Daniel J. Bernstein

View File

@@ -4,13 +4,13 @@
#include <crypto/chacha20poly1305.h>
#include <crypto/common.h>
#include <crypto/chacha20.h>
#include <crypto/common.h>
#include <crypto/poly1305.h>
#include <span.h>
#include <support/cleanse.h>
#include <assert.h>
#include <cassert>
#include <cstddef>
AEADChaCha20Poly1305::AEADChaCha20Poly1305(std::span<const std::byte> key) noexcept : m_chacha20(key)

View File

@@ -6,7 +6,7 @@
#define BITCOIN_CRYPTO_CHACHA20POLY1305_H
#include <cstddef>
#include <stdint.h>
#include <cstdint>
#include <crypto/chacha20.h>
#include <crypto/poly1305.h>

View File

@@ -1,11 +1,11 @@
// Copyright (c) 2018-2019 The Bitcoin Core developers
// Copyright (c) 2018-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <crypto/hkdf_sha256_32.h>
#include <assert.h>
#include <string.h>
#include <cassert>
#include <cstring>
CHKDF_HMAC_SHA256_L32::CHKDF_HMAC_SHA256_L32(const unsigned char* ikm, size_t ikmlen, const std::string& salt)
{

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2018-2022 The Bitcoin Core developers
// Copyright (c) 2018-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -7,8 +7,8 @@
#include <crypto/hmac_sha256.h>
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
/** A rfc5869 HKDF implementation with HMAC_SHA256 and fixed key output length of 32 bytes (L=32) */
class CHKDF_HMAC_SHA256_L32

View File

@@ -1,10 +1,10 @@
// Copyright (c) 2014-2018 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <crypto/hmac_sha256.h>
#include <string.h>
#include <cstring>
CHMAC_SHA256::CHMAC_SHA256(const unsigned char* key, size_t keylen)
{

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2022 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -7,8 +7,8 @@
#include <crypto/sha256.h>
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
/** A hasher class for HMAC-SHA-256. */
class CHMAC_SHA256

View File

@@ -1,10 +1,10 @@
// Copyright (c) 2014-2018 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <crypto/hmac_sha512.h>
#include <string.h>
#include <cstring>
CHMAC_SHA512::CHMAC_SHA512(const unsigned char* key, size_t keylen)
{

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2022 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -7,8 +7,8 @@
#include <crypto/sha512.h>
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
/** A hasher class for HMAC-SHA-512. */
class CHMAC_SHA512

View File

@@ -8,7 +8,7 @@
#include <serialize.h>
#include <uint256.h>
#include <stdint.h>
#include <cstdint>
class Num3072
{

View File

@@ -1,11 +1,11 @@
// Copyright (c) 2019 The Bitcoin Core developers
// Copyright (c) 2019-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <crypto/common.h>
#include <crypto/poly1305.h>
#include <string.h>
#include <cstring>
namespace poly1305_donna {

View File

@@ -8,8 +8,8 @@
#include <span.h>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
#define POLY1305_BLOCK_SIZE 16

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2019 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -6,7 +6,7 @@
#include <crypto/common.h>
#include <string.h>
#include <cstring>
// Internal implementation code.
namespace

View File

@@ -1,12 +1,12 @@
// Copyright (c) 2014-2022 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CRYPTO_RIPEMD160_H
#define BITCOIN_CRYPTO_RIPEMD160_H
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
/** A hasher class for RIPEMD-160. */
class CRIPEMD160

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2019 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -6,7 +6,7 @@
#include <crypto/common.h>
#include <string.h>
#include <cstring>
// Internal implementation code.
namespace

View File

@@ -1,12 +1,12 @@
// Copyright (c) 2014-2022 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CRYPTO_SHA1_H
#define BITCOIN_CRYPTO_SHA1_H
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
/** A hasher class for SHA1. */
class CSHA1

View File

@@ -1,12 +1,12 @@
// Copyright (c) 2014-2022 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CRYPTO_SHA256_H
#define BITCOIN_CRYPTO_SHA256_H
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
#include <string>
/** A hasher class for SHA-256. */

View File

@@ -1,10 +1,10 @@
// Copyright (c) 2017-2019 The Bitcoin Core developers
// Copyright (c) 2017-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifdef ENABLE_AVX2
#include <stdint.h>
#include <cstdint>
#include <immintrin.h>
#include <attributes.h>

View File

@@ -1,12 +1,12 @@
// Copyright (c) 2017-2022 The Bitcoin Core developers
// Copyright (c) 2017-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//
// This is a translation to GCC extended asm syntax from YASM code by Intel
// (available at the bottom of this file).
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
#if defined(__x86_64__) || defined(__amd64__)

View File

@@ -1,10 +1,10 @@
// Copyright (c) 2018-2019 The Bitcoin Core developers
// Copyright (c) 2018-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifdef ENABLE_SSE41
#include <stdint.h>
#include <cstdint>
#include <immintrin.h>
#include <attributes.h>

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2018-2022 The Bitcoin Core developers
// Copyright (c) 2018-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//
@@ -8,7 +8,7 @@
#if defined(ENABLE_SSE41) && defined(ENABLE_X86_SHANI)
#include <stdint.h>
#include <cstdint>
#include <immintrin.h>
#include <attributes.h>

View File

@@ -7,8 +7,8 @@
#include <span.h>
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
//! The Keccak-f[1600] transform.
void KeccakF(uint64_t (&st)[25]);

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2022 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -6,7 +6,7 @@
#include <crypto/common.h>
#include <string.h>
#include <cstring>
// Internal implementation code.
namespace

View File

@@ -1,12 +1,12 @@
// Copyright (c) 2014-2022 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CRYPTO_SHA512_H
#define BITCOIN_CRYPTO_SHA512_H
#include <cstdint>
#include <cstdlib>
#include <stdint.h>
/** A hasher class for SHA-512. */
class CSHA512

View File

@@ -5,7 +5,7 @@
#ifndef BITCOIN_CRYPTO_SIPHASH_H
#define BITCOIN_CRYPTO_SIPHASH_H
#include <stdint.h>
#include <cstdint>
#include <span.h>
#include <uint256.h>

View File

@@ -14,6 +14,7 @@
#include <node/database_args.h>
#include <node/interface_ui.h>
#include <tinyformat.h>
#include <undo.h>
#include <util/string.h>
#include <util/thread.h>
#include <util/translation.h>
@@ -143,9 +144,44 @@ static const CBlockIndex* NextSyncBlock(const CBlockIndex* pindex_prev, CChain&
return pindex;
}
// Since block is not in the chain, return the next block in the chain AFTER the last common ancestor.
// Caller will be responsible for rewinding back to the common ancestor.
return chain.Next(chain.FindFork(pindex_prev));
}
bool BaseIndex::ProcessBlock(const CBlockIndex* pindex, const CBlock* block_data)
{
interfaces::BlockInfo block_info = kernel::MakeBlockInfo(pindex, block_data);
CBlock block;
if (!block_data) { // disk lookup if block data wasn't provided
if (!m_chainstate->m_blockman.ReadBlock(block, *pindex)) {
FatalErrorf("%s: Failed to read block %s from disk",
__func__, pindex->GetBlockHash().ToString());
return false;
}
block_info.data = &block;
}
CBlockUndo block_undo;
if (CustomOptions().connect_undo_data) {
if (pindex->nHeight > 0 && !m_chainstate->m_blockman.ReadBlockUndo(block_undo, *pindex)) {
FatalErrorf("%s: Failed to read undo block data %s from disk",
__func__, pindex->GetBlockHash().ToString());
return false;
}
block_info.undo_data = &block_undo;
}
if (!CustomAppend(block_info)) {
FatalErrorf("%s: Failed to write block %s to index database",
__func__, pindex->GetBlockHash().ToString());
return false;
}
return true;
}
void BaseIndex::Sync()
{
const CBlockIndex* pindex = m_best_block_index.load();
@@ -191,20 +227,7 @@ void BaseIndex::Sync()
pindex = pindex_next;
CBlock block;
interfaces::BlockInfo block_info = kernel::MakeBlockInfo(pindex);
if (!m_chainstate->m_blockman.ReadBlock(block, *pindex)) {
FatalErrorf("%s: Failed to read block %s from disk",
__func__, pindex->GetBlockHash().ToString());
return;
} else {
block_info.data = &block;
}
if (!CustomAppend(block_info)) {
FatalErrorf("%s: Failed to write block %s to index database",
__func__, pindex->GetBlockHash().ToString());
return;
}
if (!ProcessBlock(pindex)) return; // error logged internally
auto current_time{std::chrono::steady_clock::now()};
if (last_log_time + SYNC_LOG_INTERVAL < current_time) {
@@ -254,8 +277,28 @@ bool BaseIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_ti
assert(current_tip == m_best_block_index);
assert(current_tip->GetAncestor(new_tip->nHeight) == new_tip);
if (!CustomRewind({current_tip->GetBlockHash(), current_tip->nHeight}, {new_tip->GetBlockHash(), new_tip->nHeight})) {
return false;
CBlock block;
CBlockUndo block_undo;
for (const CBlockIndex* iter_tip = current_tip; iter_tip != new_tip; iter_tip = iter_tip->pprev) {
interfaces::BlockInfo block_info = kernel::MakeBlockInfo(iter_tip);
if (CustomOptions().disconnect_data) {
if (!m_chainstate->m_blockman.ReadBlock(block, *iter_tip)) {
LogError("%s: Failed to read block %s from disk",
__func__, iter_tip->GetBlockHash().ToString());
return false;
}
block_info.data = &block;
}
if (CustomOptions().disconnect_undo_data && iter_tip->nHeight > 0) {
if (!m_chainstate->m_blockman.ReadBlockUndo(block_undo, *iter_tip)) {
return false;
}
block_info.undo_data = &block_undo;
}
if (!CustomRemove(block_info)) {
return false;
}
}
// In the case of a reorg, ensure persisted block locator is not stale.
@@ -316,17 +359,14 @@ void BaseIndex::BlockConnected(ChainstateRole role, const std::shared_ptr<const
return;
}
}
interfaces::BlockInfo block_info = kernel::MakeBlockInfo(pindex, block.get());
if (CustomAppend(block_info)) {
// Dispatch block to child class; errors are logged internally and abort the node.
if (ProcessBlock(pindex, block.get())) {
// Setting the best block index is intentionally the last step of this
// function, so BlockUntilSyncedToCurrentChain callers waiting for the
// best block index to be updated can rely on the block being fully
// processed, and the index object being safe to delete.
SetBestBlockIndex(pindex);
} else {
FatalErrorf("%s: Failed to write block %s to index",
__func__, pindex->GetBlockHash().ToString());
return;
}
}

View File

@@ -90,9 +90,11 @@ private:
/// getting corrupted.
bool Commit();
/// Loop over disconnected blocks and call CustomRewind.
/// Loop over disconnected blocks and call CustomRemove.
bool Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_tip);
bool ProcessBlock(const CBlockIndex* pindex, const CBlock* block_data = nullptr);
virtual bool AllowPrune() const = 0;
template <typename... Args>
@@ -107,6 +109,9 @@ protected:
void ChainStateFlushed(ChainstateRole role, const CBlockLocator& locator) override;
/// Return custom notification options for index.
[[nodiscard]] virtual interfaces::Chain::NotifyOptions CustomOptions() { return {}; }
/// Initialize internal state from the database and block index.
[[nodiscard]] virtual bool CustomInit(const std::optional<interfaces::BlockRef>& block) { return true; }
@@ -117,9 +122,8 @@ protected:
/// commit more index state.
virtual bool CustomCommit(CDBBatch& batch) { return true; }
/// Rewind index to an earlier chain tip during a chain reorg. The tip must
/// be an ancestor of the current best block.
[[nodiscard]] virtual bool CustomRewind(const interfaces::BlockRef& current_tip, const interfaces::BlockRef& new_tip) { return true; }
/// Rewind index by one block during a chain reorg.
[[nodiscard]] virtual bool CustomRemove(const interfaces::BlockInfo& block) { return true; }
virtual DB& GetDB() const = 0;

View File

@@ -13,7 +13,6 @@
#include <node/blockstorage.h>
#include <undo.h>
#include <util/fs_helpers.h>
#include <validation.h>
/* The index database stores three items for each block: the disk location of the encoded filter,
* its dSHA256 hash, and the header. Those belonging to blocks on the active chain are indexed by
@@ -112,6 +111,13 @@ BlockFilterIndex::BlockFilterIndex(std::unique_ptr<interfaces::Chain> chain, Blo
m_filter_fileseq = std::make_unique<FlatFileSeq>(std::move(path), "fltr", FLTR_FILE_CHUNK_SIZE);
}
interfaces::Chain::NotifyOptions BlockFilterIndex::CustomOptions()
{
interfaces::Chain::NotifyOptions options;
options.connect_undo_data = true;
return options;
}
bool BlockFilterIndex::CustomInit(const std::optional<interfaces::BlockRef>& block)
{
if (!m_db->Read(DB_FILTER_POS, m_next_filter_pos)) {
@@ -250,19 +256,7 @@ std::optional<uint256> BlockFilterIndex::ReadFilterHeader(int height, const uint
bool BlockFilterIndex::CustomAppend(const interfaces::BlockInfo& block)
{
CBlockUndo block_undo;
if (block.height > 0) {
// pindex variable gives indexing code access to node internals. It
// will be removed in upcoming commit
const CBlockIndex* pindex = WITH_LOCK(cs_main, return m_chainstate->m_blockman.LookupBlockIndex(block.hash));
if (!m_chainstate->m_blockman.ReadBlockUndo(block_undo, *pindex)) {
return false;
}
}
BlockFilter filter(m_filter_type, *Assert(block.data), block_undo);
BlockFilter filter(m_filter_type, *Assert(block.data), *Assert(block.undo_data));
const uint256& header = filter.ComputeHeader(m_last_header);
bool res = Write(filter, block.height, header);
if (res) m_last_header = header; // update last header
@@ -289,42 +283,37 @@ bool BlockFilterIndex::Write(const BlockFilter& filter, uint32_t block_height, c
}
[[nodiscard]] static bool CopyHeightIndexToHashIndex(CDBIterator& db_it, CDBBatch& batch,
const std::string& index_name,
int start_height, int stop_height)
const std::string& index_name, int height)
{
DBHeightKey key(start_height);
DBHeightKey key(height);
db_it.Seek(key);
for (int height = start_height; height <= stop_height; ++height) {
if (!db_it.GetKey(key) || key.height != height) {
LogError("%s: unexpected key in %s: expected (%c, %d)\n",
__func__, index_name, DB_BLOCK_HEIGHT, height);
return false;
}
std::pair<uint256, DBVal> value;
if (!db_it.GetValue(value)) {
LogError("%s: unable to read value in %s at key (%c, %d)\n",
__func__, index_name, DB_BLOCK_HEIGHT, height);
return false;
}
batch.Write(DBHashKey(value.first), std::move(value.second));
db_it.Next();
if (!db_it.GetKey(key) || key.height != height) {
LogError("%s: unexpected key in %s: expected (%c, %d)\n",
__func__, index_name, DB_BLOCK_HEIGHT, height);
return false;
}
std::pair<uint256, DBVal> value;
if (!db_it.GetValue(value)) {
LogError("%s: unable to read value in %s at key (%c, %d)\n",
__func__, index_name, DB_BLOCK_HEIGHT, height);
return false;
}
batch.Write(DBHashKey(value.first), std::move(value.second));
return true;
}
bool BlockFilterIndex::CustomRewind(const interfaces::BlockRef& current_tip, const interfaces::BlockRef& new_tip)
bool BlockFilterIndex::CustomRemove(const interfaces::BlockInfo& block)
{
CDBBatch batch(*m_db);
std::unique_ptr<CDBIterator> db_it(m_db->NewIterator());
// During a reorg, we need to copy all filters for blocks that are getting disconnected from the
// height index to the hash index so we can still find them when the height index entries are
// overwritten.
if (!CopyHeightIndexToHashIndex(*db_it, batch, m_name, new_tip.height, current_tip.height)) {
// During a reorg, we need to copy block filter that is getting disconnected from the
// height index to the hash index so we can still find it when the height index entry
// is overwritten.
if (!CopyHeightIndexToHashIndex(*db_it, batch, m_name, block.height)) {
return false;
}
@@ -334,8 +323,8 @@ bool BlockFilterIndex::CustomRewind(const interfaces::BlockRef& current_tip, con
batch.Write(DB_FILTER_POS, m_next_filter_pos);
if (!m_db->WriteBatch(batch)) return false;
// Update cached header
m_last_header = *Assert(ReadFilterHeader(new_tip.height, new_tip.hash));
// Update cached header to the previous block hash
m_last_header = *Assert(ReadFilterHeader(block.height - 1, *Assert(block.prev_hash)));
return true;
}

View File

@@ -52,13 +52,15 @@ private:
std::optional<uint256> ReadFilterHeader(int height, const uint256& expected_block_hash);
protected:
interfaces::Chain::NotifyOptions CustomOptions() override;
bool CustomInit(const std::optional<interfaces::BlockRef>& block) override;
bool CustomCommit(CDBBatch& batch) override;
bool CustomAppend(const interfaces::BlockInfo& block) override;
bool CustomRewind(const interfaces::BlockRef& current_tip, const interfaces::BlockRef& new_tip) override;
bool CustomRemove(const interfaces::BlockInfo& block) override;
BaseIndex::DB& GetDB() const LIFETIMEBOUND override { return *m_db; }

View File

@@ -128,19 +128,11 @@ CoinStatsIndex::CoinStatsIndex(std::unique_ptr<interfaces::Chain> chain, size_t
bool CoinStatsIndex::CustomAppend(const interfaces::BlockInfo& block)
{
CBlockUndo block_undo;
const CAmount block_subsidy{GetBlockSubsidy(block.height, Params().GetConsensus())};
m_total_subsidy += block_subsidy;
// Ignore genesis block
if (block.height > 0) {
// pindex variable gives indexing code access to node internals. It
// will be removed in upcoming commit
const CBlockIndex* pindex = WITH_LOCK(cs_main, return m_chainstate->m_blockman.LookupBlockIndex(block.hash));
if (!m_chainstate->m_blockman.ReadBlockUndo(block_undo, *pindex)) {
return false;
}
std::pair<uint256, DBVal> read_out;
if (!m_db->Read(DBHeightKey(block.height - 1), read_out)) {
return false;
@@ -164,7 +156,7 @@ bool CoinStatsIndex::CustomAppend(const interfaces::BlockInfo& block)
const auto& tx{block.data->vtx.at(i)};
// Skip duplicate txid coinbase transactions (BIP30).
if (IsBIP30Unspendable(*pindex) && tx->IsCoinBase()) {
if (IsBIP30Unspendable(block.hash, block.height) && tx->IsCoinBase()) {
m_total_unspendable_amount += block_subsidy;
m_total_unspendables_bip30 += block_subsidy;
continue;
@@ -197,7 +189,7 @@ bool CoinStatsIndex::CustomAppend(const interfaces::BlockInfo& block)
// The coinbase tx has no undo data since no former output is spent
if (!tx->IsCoinBase()) {
const auto& tx_undo{block_undo.vtxundo.at(i - 1)};
const auto& tx_undo{Assert(block.undo_data)->vtxundo.at(i - 1)};
for (size_t j = 0; j < tx_undo.vprevout.size(); ++j) {
Coin coin{tx_undo.vprevout[j]};
@@ -253,67 +245,43 @@ bool CoinStatsIndex::CustomAppend(const interfaces::BlockInfo& block)
}
[[nodiscard]] static bool CopyHeightIndexToHashIndex(CDBIterator& db_it, CDBBatch& batch,
const std::string& index_name,
int start_height, int stop_height)
const std::string& index_name, int height)
{
DBHeightKey key{start_height};
DBHeightKey key{height};
db_it.Seek(key);
for (int height = start_height; height <= stop_height; ++height) {
if (!db_it.GetKey(key) || key.height != height) {
LogError("%s: unexpected key in %s: expected (%c, %d)\n",
__func__, index_name, DB_BLOCK_HEIGHT, height);
return false;
}
std::pair<uint256, DBVal> value;
if (!db_it.GetValue(value)) {
LogError("%s: unable to read value in %s at key (%c, %d)\n",
__func__, index_name, DB_BLOCK_HEIGHT, height);
return false;
}
batch.Write(DBHashKey(value.first), std::move(value.second));
db_it.Next();
if (!db_it.GetKey(key) || key.height != height) {
LogError("%s: unexpected key in %s: expected (%c, %d)\n",
__func__, index_name, DB_BLOCK_HEIGHT, height);
return false;
}
std::pair<uint256, DBVal> value;
if (!db_it.GetValue(value)) {
LogError("%s: unable to read value in %s at key (%c, %d)\n",
__func__, index_name, DB_BLOCK_HEIGHT, height);
return false;
}
batch.Write(DBHashKey(value.first), std::move(value.second));
return true;
}
bool CoinStatsIndex::CustomRewind(const interfaces::BlockRef& current_tip, const interfaces::BlockRef& new_tip)
bool CoinStatsIndex::CustomRemove(const interfaces::BlockInfo& block)
{
CDBBatch batch(*m_db);
std::unique_ptr<CDBIterator> db_it(m_db->NewIterator());
// During a reorg, we need to copy all hash digests for blocks that are
// getting disconnected from the height index to the hash index so we can
// still find them when the height index entries are overwritten.
if (!CopyHeightIndexToHashIndex(*db_it, batch, m_name, new_tip.height, current_tip.height)) {
// During a reorg, copy the block's hash digest from the height index to the hash index,
// ensuring it's still accessible after the height index entry is overwritten.
if (!CopyHeightIndexToHashIndex(*db_it, batch, m_name, block.height)) {
return false;
}
if (!m_db->WriteBatch(batch)) return false;
{
LOCK(cs_main);
const CBlockIndex* iter_tip{m_chainstate->m_blockman.LookupBlockIndex(current_tip.hash)};
const CBlockIndex* new_tip_index{m_chainstate->m_blockman.LookupBlockIndex(new_tip.hash)};
do {
CBlock block;
if (!m_chainstate->m_blockman.ReadBlock(block, *iter_tip)) {
LogError("%s: Failed to read block %s from disk\n",
__func__, iter_tip->GetBlockHash().ToString());
return false;
}
if (!ReverseBlock(block, iter_tip)) {
return false; // failure cause logged internally
}
iter_tip = iter_tip->GetAncestor(iter_tip->nHeight - 1);
} while (new_tip_index != iter_tip);
if (!ReverseBlock(block)) {
return false; // failure cause logged internally
}
return true;
@@ -421,26 +389,30 @@ bool CoinStatsIndex::CustomCommit(CDBBatch& batch)
return true;
}
// Reverse a single block as part of a reorg
bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex)
interfaces::Chain::NotifyOptions CoinStatsIndex::CustomOptions()
{
interfaces::Chain::NotifyOptions options;
options.connect_undo_data = true;
options.disconnect_data = true;
options.disconnect_undo_data = true;
return options;
}
// Reverse a single block as part of a reorg
bool CoinStatsIndex::ReverseBlock(const interfaces::BlockInfo& block)
{
CBlockUndo block_undo;
std::pair<uint256, DBVal> read_out;
const CAmount block_subsidy{GetBlockSubsidy(pindex->nHeight, Params().GetConsensus())};
const CAmount block_subsidy{GetBlockSubsidy(block.height, Params().GetConsensus())};
m_total_subsidy -= block_subsidy;
// Ignore genesis block
if (pindex->nHeight > 0) {
if (!m_chainstate->m_blockman.ReadBlockUndo(block_undo, *pindex)) {
if (block.height > 0) {
if (!m_db->Read(DBHeightKey(block.height - 1), read_out)) {
return false;
}
if (!m_db->Read(DBHeightKey(pindex->nHeight - 1), read_out)) {
return false;
}
uint256 expected_block_hash{pindex->pprev->GetBlockHash()};
uint256 expected_block_hash{*block.prev_hash};
if (read_out.first != expected_block_hash) {
LogPrintf("WARNING: previous block header belongs to unexpected block %s; expected %s\n",
read_out.first.ToString(), expected_block_hash.ToString());
@@ -454,13 +426,15 @@ bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex
}
// Remove the new UTXOs that were created from the block
for (size_t i = 0; i < block.vtx.size(); ++i) {
const auto& tx{block.vtx.at(i)};
assert(block.data);
assert(block.undo_data);
for (size_t i = 0; i < block.data->vtx.size(); ++i) {
const auto& tx{block.data->vtx.at(i)};
for (uint32_t j = 0; j < tx->vout.size(); ++j) {
const CTxOut& out{tx->vout[j]};
COutPoint outpoint{tx->GetHash(), j};
Coin coin{out, pindex->nHeight, tx->IsCoinBase()};
Coin coin{out, block.height, tx->IsCoinBase()};
// Skip unspendable coins
if (coin.out.scriptPubKey.IsUnspendable()) {
@@ -484,7 +458,7 @@ bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex
// The coinbase tx has no undo data since no former output is spent
if (!tx->IsCoinBase()) {
const auto& tx_undo{block_undo.vtxundo.at(i - 1)};
const auto& tx_undo{block.undo_data->vtxundo.at(i - 1)};
for (size_t j = 0; j < tx_undo.vprevout.size(); ++j) {
Coin coin{tx_undo.vprevout[j]};

View File

@@ -39,18 +39,20 @@ private:
CAmount m_total_unspendables_scripts{0};
CAmount m_total_unspendables_unclaimed_rewards{0};
[[nodiscard]] bool ReverseBlock(const CBlock& block, const CBlockIndex* pindex);
[[nodiscard]] bool ReverseBlock(const interfaces::BlockInfo& block);
bool AllowPrune() const override { return true; }
protected:
interfaces::Chain::NotifyOptions CustomOptions() override;
bool CustomInit(const std::optional<interfaces::BlockRef>& block) override;
bool CustomCommit(CDBBatch& batch) override;
bool CustomAppend(const interfaces::BlockInfo& block) override;
bool CustomRewind(const interfaces::BlockRef& current_tip, const interfaces::BlockRef& new_tip) override;
bool CustomRemove(const interfaces::BlockInfo& block) override;
BaseIndex::DB& GetDB() const override { return *m_db; }

View File

@@ -109,7 +109,7 @@
#include <vector>
#ifndef WIN32
#include <signal.h>
#include <csignal>
#include <sys/stat.h>
#endif
@@ -556,11 +556,26 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
argsman.AddArg("-peerblockfilters", strprintf("Serve compact block filters to peers per BIP 157 (default: %u)", DEFAULT_PEERBLOCKFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-txreconciliation", strprintf("Enable transaction reconciliations per BIP 330 (default: %d)", DEFAULT_TXRECONCILIATION_ENABLE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port> (default: %u, testnet3: %u, testnet4: %u, signet: %u, regtest: %u). Not relevant for I2P (see doc/i2p.md). If set to a value x, the default onion listening port will be set to x+1.", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), testnet4ChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
const std::string proxy_doc_for_value =
#ifdef HAVE_SOCKADDR_UN
argsman.AddArg("-proxy=<ip:port|path>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled). May be a local file path prefixed with 'unix:' if the proxy supports it.", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION);
"<ip>[:<port>]|unix:<path>";
#else
argsman.AddArg("-proxy=<ip:port>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION);
"<ip>[:<port>]";
#endif
const std::string proxy_doc_for_unix_socket =
#ifdef HAVE_SOCKADDR_UN
"May be a local file path prefixed with 'unix:' if the proxy supports it. ";
#else
"";
#endif
argsman.AddArg("-proxy=" + proxy_doc_for_value + "[=<network>]",
"Connect through SOCKS5 proxy, set -noproxy to disable. " +
proxy_doc_for_unix_socket +
"Could end in =network to set the proxy only for that network. " +
"The network can be any of ipv4, ipv6, tor or cjdns. " +
"(default: disabled)",
ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION,
OptionsCategory::CONNECTION);
argsman.AddArg("-proxyrandomize", strprintf("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)", DEFAULT_PROXYRANDOMIZE), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-seednode=<ip>", "Connect to a node to retrieve peer addresses, and disconnect. This option can be specified multiple times to connect to multiple nodes. During startup, seednodes will be tried before dnsseeds.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-networkactive", "Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
@@ -637,10 +652,10 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
argsman.AddArg("-dustrelayfee=<amt>", strprintf("Fee rate (in %s/kvB) used to define dust, the value of an output such that it will cost more than its value in fees at this fee rate to spend it. (default: %s)", CURRENCY_UNIT, FormatMoney(DUST_RELAY_TX_FEE)), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
argsman.AddArg("-acceptstalefeeestimates", strprintf("Read fee estimates even if they are stale (%sdefault: %u) fee estimates are considered stale if they are %s hours old", "regtest only; ", DEFAULT_ACCEPT_STALE_FEE_ESTIMATES, Ticks<std::chrono::hours>(MAX_FILE_AGE)), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-bytespersigop", strprintf("Equivalent bytes per sigop in transactions for relay and mining (default: %u)", DEFAULT_BYTES_PER_SIGOP), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
argsman.AddArg("-datacarrier", strprintf("Relay and mine data carrier transactions (default: %u)", DEFAULT_ACCEPT_DATACARRIER), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
argsman.AddArg("-datacarrier", strprintf("(DEPRECATED) Relay and mine data carrier transactions (default: %u)", DEFAULT_ACCEPT_DATACARRIER), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
argsman.AddArg("-datacarriersize",
strprintf("Relay and mine transactions whose data-carrying raw scriptPubKey "
"is of this size or less (default: %u)",
strprintf("(DEPRECATED) Relay and mine transactions whose data-carrying raw scriptPubKeys in aggregate "
"are of this size or less, allowing multiple outputs (default: %u)",
MAX_OP_RETURN_RELAY),
ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
argsman.AddArg("-permitbaremultisig", strprintf("Relay transactions creating non-P2SH multisig outputs (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,
@@ -888,6 +903,10 @@ bool AppInitParameterInteraction(const ArgsManager& args)
InitWarning(_("Option '-checkpoints' is set but checkpoints were removed. This option has no effect."));
}
if (args.IsArgSet("-datacarriersize") || args.IsArgSet("-datacarrier")) {
InitWarning(_("Options '-datacarrier' or '-datacarriersize' are set but are marked as deprecated. They will be removed in a future version."));
}
// Error if network-specific options (-addnode, -connect, etc) are
// specified in default section of config file, but not overridden
// on the command line or in this chain's section of the config file.
@@ -1173,31 +1192,34 @@ bool CheckHostPortOptions(const ArgsManager& args) {
}
}
for ([[maybe_unused]] const auto& [arg, unix] : std::vector<std::pair<std::string, bool>>{
// arg name UNIX socket support
{"-i2psam", false},
{"-onion", true},
{"-proxy", true},
{"-rpcbind", false},
{"-torcontrol", false},
{"-whitebind", false},
{"-zmqpubhashblock", true},
{"-zmqpubhashtx", true},
{"-zmqpubrawblock", true},
{"-zmqpubrawtx", true},
{"-zmqpubsequence", true},
for ([[maybe_unused]] const auto& [param_name, unix, suffix_allowed] : std::vector<std::tuple<std::string, bool, bool>>{
// arg name UNIX socket support =suffix allowed
{"-i2psam", false, false},
{"-onion", true, false},
{"-proxy", true, true},
{"-bind", false, true},
{"-rpcbind", false, false},
{"-torcontrol", false, false},
{"-whitebind", false, false},
{"-zmqpubhashblock", true, false},
{"-zmqpubhashtx", true, false},
{"-zmqpubrawblock", true, false},
{"-zmqpubrawtx", true, false},
{"-zmqpubsequence", true, false},
}) {
for (const std::string& socket_addr : args.GetArgs(arg)) {
for (const std::string& param_value : args.GetArgs(param_name)) {
const std::string param_value_hostport{
suffix_allowed ? param_value.substr(0, param_value.rfind('=')) : param_value};
std::string host_out;
uint16_t port_out{0};
if (!SplitHostPort(socket_addr, port_out, host_out)) {
if (!SplitHostPort(param_value_hostport, port_out, host_out)) {
#ifdef HAVE_SOCKADDR_UN
// Allow unix domain sockets for some options e.g. unix:/some/file/path
if (!unix || !socket_addr.starts_with(ADDR_PREFIX_UNIX)) {
return InitError(InvalidPortErrMsg(arg, socket_addr));
if (!unix || !param_value.starts_with(ADDR_PREFIX_UNIX)) {
return InitError(InvalidPortErrMsg(param_name, param_value));
}
#else
return InitError(InvalidPortErrMsg(arg, socket_addr));
return InitError(InvalidPortErrMsg(param_name, param_value));
#endif
}
}
@@ -1562,33 +1584,66 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// Check for host lookup allowed before parsing any network related parameters
fNameLookup = args.GetBoolArg("-dns", DEFAULT_NAME_LOOKUP);
Proxy onion_proxy;
bool proxyRandomize = args.GetBoolArg("-proxyrandomize", DEFAULT_PROXYRANDOMIZE);
// -proxy sets a proxy for all outgoing network traffic
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
std::string proxyArg = args.GetArg("-proxy", "");
if (proxyArg != "" && proxyArg != "0") {
Proxy addrProxy;
if (IsUnixSocketPath(proxyArg)) {
addrProxy = Proxy(proxyArg, /*tor_stream_isolation=*/proxyRandomize);
} else {
const std::optional<CService> proxyAddr{Lookup(proxyArg, 9050, fNameLookup)};
if (!proxyAddr.has_value()) {
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
// -proxy sets a proxy for outgoing network traffic, possibly per network.
// -noproxy, -proxy=0 or -proxy="" can be used to remove the proxy setting, this is the default
Proxy ipv4_proxy;
Proxy ipv6_proxy;
Proxy onion_proxy;
Proxy name_proxy;
Proxy cjdns_proxy;
for (const std::string& param_value : args.GetArgs("-proxy")) {
const auto eq_pos{param_value.rfind('=')};
const std::string proxy_str{param_value.substr(0, eq_pos)}; // e.g. 127.0.0.1:9050=ipv4 -> 127.0.0.1:9050
std::string net_str;
if (eq_pos != std::string::npos) {
if (eq_pos + 1 == param_value.length()) {
return InitError(strprintf(_("Invalid -proxy address or hostname, ends with '=': '%s'"), param_value));
}
addrProxy = Proxy(proxyAddr.value(), /*tor_stream_isolation=*/proxyRandomize);
net_str = ToLower(param_value.substr(eq_pos + 1)); // e.g. 127.0.0.1:9050=ipv4 -> ipv4
}
if (!addrProxy.IsValid())
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
Proxy proxy;
if (!proxy_str.empty() && proxy_str != "0") {
if (IsUnixSocketPath(proxy_str)) {
proxy = Proxy{proxy_str, /*tor_stream_isolation=*/proxyRandomize};
} else {
const std::optional<CService> addr{Lookup(proxy_str, DEFAULT_TOR_SOCKS_PORT, fNameLookup)};
if (!addr.has_value()) {
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxy_str));
}
proxy = Proxy{addr.value(), /*tor_stream_isolation=*/proxyRandomize};
}
if (!proxy.IsValid()) {
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxy_str));
}
}
SetProxy(NET_IPV4, addrProxy);
SetProxy(NET_IPV6, addrProxy);
SetProxy(NET_CJDNS, addrProxy);
SetNameProxy(addrProxy);
onion_proxy = addrProxy;
if (net_str.empty()) { // For all networks.
ipv4_proxy = ipv6_proxy = name_proxy = cjdns_proxy = onion_proxy = proxy;
} else if (net_str == "ipv4") {
ipv4_proxy = name_proxy = proxy;
} else if (net_str == "ipv6") {
ipv6_proxy = name_proxy = proxy;
} else if (net_str == "tor" || net_str == "onion") {
onion_proxy = proxy;
} else if (net_str == "cjdns") {
cjdns_proxy = proxy;
} else {
return InitError(strprintf(_("Unrecognized network in -proxy='%s': '%s'"), param_value, net_str));
}
}
if (ipv4_proxy.IsValid()) {
SetProxy(NET_IPV4, ipv4_proxy);
}
if (ipv6_proxy.IsValid()) {
SetProxy(NET_IPV6, ipv6_proxy);
}
if (name_proxy.IsValid()) {
SetNameProxy(name_proxy);
}
if (cjdns_proxy.IsValid()) {
SetProxy(NET_CJDNS, cjdns_proxy);
}
const bool onlynet_used_with_onion{!onlynets.empty() && g_reachable_nets.Contains(NET_ONION)};
@@ -1609,7 +1664,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
if (IsUnixSocketPath(onionArg)) {
onion_proxy = Proxy(onionArg, /*tor_stream_isolation=*/proxyRandomize);
} else {
const std::optional<CService> addr{Lookup(onionArg, 9050, fNameLookup)};
const std::optional<CService> addr{Lookup(onionArg, DEFAULT_TOR_SOCKS_PORT, fNameLookup)};
if (!addr.has_value() || !addr->IsValid()) {
return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
}

View File

@@ -327,6 +327,17 @@ public:
virtual void chainStateFlushed(ChainstateRole role, const CBlockLocator& locator) {}
};
//! Options specifying which chain notifications are required.
struct NotifyOptions
{
//! Include undo data with block connected notifications.
bool connect_undo_data = false;
//! Include block data with block disconnected notifications.
bool disconnect_data = false;
//! Include undo data with block disconnected notifications.
bool disconnect_undo_data = false;
};
//! Register handler for notifications.
virtual std::unique_ptr<Handler> handleNotifications(std::shared_ptr<Notifications> notifications) = 0;

View File

@@ -15,10 +15,10 @@
#include <support/allocators/secure.h>
#include <util/translation.h>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <stddef.h>
#include <stdint.h>
#include <string>
#include <tuple>
#include <vector>

View File

@@ -1,10 +1,10 @@
// Copyright (c) 2023 The Bitcoin Core developers
// Copyright (c) 2023-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <kernel/disconnected_transactions.h>
#include <assert.h>
#include <cassert>
#include <core_memusage.h>
#include <memusage.h>
#include <primitives/transaction.h>

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2009-2022 The Bitcoin Core developers
// Copyright (c) 2009-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -16,11 +16,11 @@
#include <util/overflow.h>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <set>
#include <stddef.h>
#include <stdint.h>
class CBlockIndex;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2021 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -12,8 +12,8 @@
#include <util/strencodings.h>
#include <algorithm>
#include <assert.h>
#include <string.h>
#include <cassert>
#include <cstring>
/// Maximum witness length for Bech32 addresses.
static constexpr std::size_t BECH32_WITNESS_PROG_MAX_LEN = 40;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2009-2022 The Bitcoin Core developers
// Copyright (c) 2009-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -11,9 +11,9 @@
#include <util/sock.h>
#include <util/threadinterrupt.h>
#include <cstdint>
#include <functional>
#include <memory>
#include <stdint.h>
#include <string>
#include <type_traits>
#include <unordered_set>

View File

@@ -1,12 +1,12 @@
// Copyright (c) 2022 The Bitcoin Core developers
// Copyright (c) 2022-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_NODE_CONNECTION_TYPES_H
#define BITCOIN_NODE_CONNECTION_TYPES_H
#include <cstdint>
#include <string>
#include <stdint.h>
/** Different types of connections to a peer. This enum encapsulates the
* information we have available at the time of opening or accepting the

View File

@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2022 The Bitcoin Core developers
// Copyright (c) 2009-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -13,9 +13,9 @@
#include <txmempool.h>
#include <util/feefrac.h>
#include <cstdint>
#include <memory>
#include <optional>
#include <stdint.h>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/indexed_by.hpp>

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2022 The Bitcoin Core developers
// Copyright (c) 2022-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -9,11 +9,11 @@
#include <primitives/transaction.h>
#include <uint256.h>
#include <cstdint>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <stdint.h>
#include <vector>
class CFeeRate;

View File

@@ -76,7 +76,7 @@ std::vector<uint32_t> GetDust(const CTransaction& tx, CFeeRate dust_relay_rate)
return dust_outputs;
}
bool IsStandard(const CScript& scriptPubKey, const std::optional<unsigned>& max_datacarrier_bytes, TxoutType& whichType)
bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType)
{
std::vector<std::vector<unsigned char> > vSolutions;
whichType = Solver(scriptPubKey, vSolutions);
@@ -91,10 +91,6 @@ bool IsStandard(const CScript& scriptPubKey, const std::optional<unsigned>& max_
return false;
if (m < 1 || m > n)
return false;
} else if (whichType == TxoutType::NULL_DATA) {
if (!max_datacarrier_bytes || scriptPubKey.size() > *max_datacarrier_bytes) {
return false;
}
}
return true;
@@ -138,17 +134,22 @@ bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_dat
}
}
unsigned int nDataOut = 0;
unsigned int datacarrier_bytes_left = max_datacarrier_bytes.value_or(0);
TxoutType whichType;
for (const CTxOut& txout : tx.vout) {
if (!::IsStandard(txout.scriptPubKey, max_datacarrier_bytes, whichType)) {
if (!::IsStandard(txout.scriptPubKey, whichType)) {
reason = "scriptpubkey";
return false;
}
if (whichType == TxoutType::NULL_DATA)
nDataOut++;
else if ((whichType == TxoutType::MULTISIG) && (!permit_bare_multisig)) {
if (whichType == TxoutType::NULL_DATA) {
unsigned int size = txout.scriptPubKey.size();
if (size > datacarrier_bytes_left) {
reason = "datacarrier";
return false;
}
datacarrier_bytes_left -= size;
} else if ((whichType == TxoutType::MULTISIG) && (!permit_bare_multisig)) {
reason = "bare-multisig";
return false;
}
@@ -160,12 +161,6 @@ bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_dat
return false;
}
// only one OP_RETURN txout is permitted
if (nDataOut > 1) {
reason = "multi-op-return";
return false;
}
return true;
}

View File

@@ -73,10 +73,9 @@ static constexpr unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT_KVB{101};
/** Default for -datacarrier */
static const bool DEFAULT_ACCEPT_DATACARRIER = true;
/**
* Default setting for -datacarriersize. 80 bytes of data, +1 for OP_RETURN,
* +2 for the pushdata opcodes.
* Default setting for -datacarriersize in vbytes.
*/
static const unsigned int MAX_OP_RETURN_RELAY = 83;
static const unsigned int MAX_OP_RETURN_RELAY = MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR;
/**
* An extra transaction can be added to a package, as long as it only has one
* ancestor and is no larger than this. Not really any reason to make this
@@ -137,7 +136,7 @@ CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);
bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee);
bool IsStandard(const CScript& scriptPubKey, const std::optional<unsigned>& max_datacarrier_bytes, TxoutType& whichType);
bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType);
/** Get the vout index numbers of all dust outputs */
std::vector<uint32_t> GetDust(const CTransaction& tx, CFeeRate dust_relay_rate);

View File

@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2022 The Bitcoin Core developers
// Copyright (c) 2009-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -8,7 +8,7 @@
#include <consensus/params.h>
#include <stdint.h>
#include <cstdint>
class CBlockHeader;
class CBlockIndex;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2022 The Bitcoin Core developers
// Copyright (c) 2011-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -10,7 +10,7 @@
#include <interfaces/node.h>
#include <qt/initexecutor.h>
#include <assert.h>
#include <cassert>
#include <memory>
#include <optional>

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2022 The Bitcoin Core developers
// Copyright (c) 2011-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -23,7 +23,7 @@
#include <util/time.h>
#include <validation.h>
#include <stdint.h>
#include <cstdint>
#include <QDebug>
#include <QMetaObject>

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2022 The Bitcoin Core developers
// Copyright (c) 2011-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -18,7 +18,7 @@
#ifdef USE_DBUS
#include <QDBusMetaType>
#include <QtDBus>
#include <stdint.h>
#include <cstdint>
#endif
#ifdef Q_OS_MACOS
#include <qt/macnotificationhandler.h>

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2022 The Bitcoin Core developers
// Copyright (c) 2011-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -12,7 +12,7 @@
#include <QAbstractListModel>
#include <QFont>
#include <assert.h>
#include <cassert>
#include <variant>
struct bilingual_str;

View File

@@ -21,7 +21,7 @@ BEGIN
BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN
VALUE "CompanyName", "Namecoin"
VALUE "CompanyName", CLIENT_NAME " project"
VALUE "FileDescription", CLIENT_NAME " (GUI node for Namecoin)"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "namecoin-qt"

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2022 The Bitcoin Core developers
// Copyright (c) 2011-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -19,7 +19,7 @@
#include <validation.h>
#include <wallet/types.h>
#include <stdint.h>
#include <cstdint>
#include <string>
#include <QLatin1String>

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2022 The Bitcoin Core developers
// Copyright (c) 2011-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -12,7 +12,7 @@
#include <script/names.h>
#include <wallet/types.h>
#include <stdint.h>
#include <cstdint>
#include <QDateTime>

View File

@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2022 The Bitcoin Core developers
// Copyright (c) 2009-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -56,7 +56,7 @@
#include <validationinterface.h>
#include <versionbits.h>
#include <stdint.h>
#include <cstdint>
#include <condition_variable>
#include <iterator>

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2017-2022 The Bitcoin Core developers
// Copyright (c) 2017-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -13,7 +13,7 @@
#include <validation.h>
#include <any>
#include <stdint.h>
#include <cstdint>
#include <vector>
class CBlock;

Some files were not shown because too many files have changed in this diff Show More