Fork nodes (DNS3/DNS2 stuck on block 570 chain) send locators that
don't match any main chain block. Instead of disconnecting/ banning
after 3 failed getblocks attempts, this change:
- Serves main chain blocks from genesis when locator has no match
- Resets nIncompatibleGetblocks counter after 10 (so we never ban)
- Fork nodes will receive, validate, and automatically reorg to the
longer/higher-work main chain once they see it
This fixes the 'no common blocks' deadlock while preserving chain
integrity — only a genuinely longer chain can trigger the reorg.
The base class CTxDBBase declares NewIterator() public, but both
backends overrode it in their protected: section. That narrowed the
static access through the derived type, so the migration utility
(which holds concrete CTxDB / CRocksTxDB instances) couldn't call it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CSyncManager extracts the headers-first IBD planner from main.cpp into
its own translation unit. main.cpp loses ~570 lines of file-scope state
and helper functions; the headers handler, block-delivery latency
tracking, stall-recovery, and per-peer Tick cadence now route through
g_syncManager.
MaybeMigrateLevelDbToRocksDb() is now reachable via -migratechaindb /
-migratechaindbforce in init.cpp. Reads from <datadir>/txleveldb and
writes byte-for-byte identical records into <datadir>/rocksdb via a
new CRocksTxDB::WriteRawRecordForMigration() shim over WriteRaw.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Trim mainnet and testnet checkpoint tables to the 2,000,000 entry.
Clears the snapshot-hash entry at 2,203,594 since its corresponding
checkpoint is now gone (per the invariant noted in the comment block).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Internal refactor milestone for the C++20 modernization series.
No protocol or on-disk format change (version.h untouched).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Latent header-hygiene bug: crypter.h calls OPENSSL_cleanse at lines 99-100
but never declared the dependency. Built fine because the precompiled
header on triangles_common pulled in <openssl/crypto.h> transitively, so
every translation unit that included crypter.h also got the symbol.
Surfaced by enabling -DBUILD_TESTS=ON: test_triangles is configured
without REUSE_FROM the PCH, so test/sigopcount_tests.cpp fails to find
OPENSSL_cleanse when crypter.h is reached transitively via key.h/wallet.h.
Adding the explicit include is the principled fix — headers should
declare their own dependencies rather than rely on the consumer's
precompiled-header configuration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contabo seed nodes now have persistent Tor hidden service volumes.
New onion addresses:
- seed-1: vmepp7...qtpfad
- seed-2: nsldmf...uykqd
- seed-3: on4nok...y3eqd
- seed-4: 3uyzlt...iqad
Also added Hetzner Helsinki (nawqqo...j26taid).
Reconciles two parallel implementations of multi-backend chain DB:
local kept its MakeChainDB factory + std::filesystem + unconditional
RocksDB + abstracted utxosnapshot, since those are downstream of the
boost-cleanup, smessage-RocksDB-port, and CTxDBBase abstraction work.
Preserved from origin (Krystie's branch):
- Block 2,203,594 checkpoint and matching mapSnapshotHashes entry
for P2P snapshot verification (src/checkpoints.cpp)
- Headers-first IBD stall-recovery path: during IBD, replace the
legacy PushGetBlocks fallback with RequestHeaderSyncRefillAllPeers
+ QueueHeaderSyncBlocksParallel so a stall on a weak peer set
doesn't park at a low common ancestor (src/main.cpp SendMessages)
Discarded from origin:
- src/txdb.cpp (CActiveTxDB wrapper) — superseded by txdb-factory.cpp
- BUILD_ROCKSDB-gated paths and inline LevelDB+RocksDB code in
utxosnapshot.cpp — already factored out behind CTxDBBase
- Public ReadRawBytes/WriteRawBytes/... wrappers added to
CTxDBBase for CActiveTxDB; no remaining callers
- GetActiveChainDbDirName / UseRocksDbBackend in bootstrap.cpp;
switched to GetChainDataDir()
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Aligns the recorded commit with the v0.7.1 tag actually checked out
in the working tree. Carrying forward; no code change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add libsecp256k1 v0.7.1 as src/secp256k1 submodule and introduce
crypto_ecdsa / crypto_ecdh wrappers as drop-in replacements for the
OpenSSL ECDSA_verify / ECDSA_sign / ECDH_compute_key call sites used
by key.cpp and smessage.cpp. Wrappers preserve on-chain compatibility
(lax DER parsing, 65-byte recoverable compact sigs, SEC1 priv-key
DER round-trip, raw-X ECDH output for smsg KDF).
CMake wires the submodule and new sources into the build. Mid-refactor;
landing as a checkpoint before stacking sync-pipeline work on top.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pre-v5.10 the secure-messaging store was backed by LevelDB at
<datadir>/smsgDB/. Phase 3a switched it to RocksDB; existing nodes
upgrading to v5.10 would otherwise lose their pubkey cache and
inbox/outbox because RocksDB can't open a LevelDB tree.
Detection: presence of CURRENT without IDENTITY in smsgDB/. RocksDB
writes IDENTITY on first open; LevelDB never does.
Migration path:
1. Atomic rename smsgDB/ → smsgDB.leveldb-backup/
2. Open backup with leveldb::DB (read-only)
3. Open smsgDB/ with rocksdb::DB (create_if_missing)
4. Iterate every key, copy in 5000-entry batches
5. Leave the backup in place — never deleted by the migration code,
so the user can roll back manually if needed
Triggered lazily inside SecMsgDB::Open so no separate flag or RPC is
needed. Already-migrated nodes (IDENTITY present) skip the path. Once
all users are on v5.10+ the helper and the leveldb headers it pulls
in can be dropped.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bignum.h calls std::reverse and std::reverse_copy unqualified, relying
on ADL plus <algorithm> being transitively pulled in by an earlier
header. The Qt build path on Windows MSYS2 doesn't satisfy that
assumption — the moc-generated TUs reach bignum.h before <algorithm>
shows up via any other include. Add the explicit include.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1. rocksdb::WriteBatch::Handler typeinfo missing on Ubuntu's librocksdb-dev.
Both SecMsgBatchScanner (smessage.cpp) and CRocksBatchScanner
(txdb-rocksdb.cpp) inherited from Handler to scan an active WriteBatch
for pending writes/deletes; that subclass-based scan fails to link
because Ubuntu's package hides the parent's typeinfo. Replaced both
scanners with a parallel std::map<std::string, std::optional<std::string>>
maintained alongside each WriteBatch — Put adds a value entry, Delete
adds a nullopt entry, ScanBatch becomes an O(log n) map lookup. Same
semantics, no Handler dependency.
2. macOS Homebrew's RocksDB 10.x removed the raw DB** overload of
DB::Open; only std::unique_ptr<DB>* remains. txdb-rocksdb.cpp called
the raw form, breaking the macOS build. Added the same SFINAE Open
wrapper used in smessage.cpp (commit 4265343) that picks whichever
overload the linked rocksdb actually has.
3. CSignal<>'s SignalState::slots member collided with Qt's `#define slots`
to empty, stripping the member name in any TU that pulls in <QtCore>
(e.g. moc-generated files that include util_signal.h transitively).
Renamed to slot_map.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two issues surfaced once configure stopped failing:
1. CTxDBBase::NewIterator() was protected, but the snapshot dump/load
code (commits 76579e3, ccfada5) calls it externally. Moved to public —
the iterator interface is intentional public API.
2. RocksDB DB::Open's raw DB** overload was removed in newer releases.
Homebrew's macOS package (10.x) only exposes the std::unique_ptr<DB>*
form; Ubuntu 22.04 (rocksdb 6.x) and MSYS2 (8/9.x) still expose DB**.
Added a SFINAE wrapper OpenSmsgDB() in smessage.cpp that picks
whichever overload the linked rocksdb actually has, so we don't need
version macros or per-distro #ifdefs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
C++20 broke two things in the prior bump:
1. std::allocator no longer exposes pointer/const_pointer/reference/
const_reference member typedefs, and the 2-arg allocate(n, hint) was
removed. Both secure_allocator and zero_after_free_allocator inherited
these from std::allocator. Define the typedefs ourselves and switch
the secure_allocator allocate() to the single-arg form.
2. Bundled src/leveldb uses `std::memory_order::memory_order_relaxed`
which was valid in C++17 but became a hard error in C++20 (memory_order
is now a scoped enum class — the values are at namespace scope or
memory_order::relaxed, not memory_order::memory_order_relaxed). LevelDB
itself only needs C++11, so pin its targets to C++17 in BuildLevelDB.cmake
instead of patching vendored code.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Walks the active chain in [start_height, end_height] and runs the existing
VerifySignature path on every non-coinbase input. Returns counts plus the
first 100 failures.
Intended use: capture a pre-migration baseline (should be all-zero
failures), then re-run after switching the underlying ECDSA primitive
(e.g. OpenSSL EC -> libsecp256k1) to catch behavioural regressions before
they hit IBD on a peer.
Defaults: start = max(1, tip-1000), end = tip.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two CI failures from the prior push:
1. MSYS2 mingw64's RocksDB headers (8.x+) use `using enum` and defaulted
operator== on user-defined types — both C++20-only. Bumped
CMAKE_CXX_STANDARD from 17 to 20 across the project. GCC 11.4 (Ubuntu),
GCC 14.x (MSYS2), and Apple Clang 16 all support what we need.
2. Ubuntu 22.04's librocksdb-dev ships neither a CMake config package nor
a rocksdb.pc file, so both find_package(RocksDB CONFIG) and
pkg_check_modules(rocksdb) fail. Added a manual find_path/find_library
fallback that creates a RocksDB::rocksdb IMPORTED target from the
raw header dir + .so, with a clear FATAL_ERROR if all three probes miss.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
LoadSnapshot previously opened LevelDB directly at <datadir>/txleveldb to
write the snapshot in. Refactored to use the CTxDBBase abstraction:
- WipeChainDataDir() removes the configured backend's chain DB dir
- MakeChainDB("c+") opens fresh via the factory
- High-level methods (WriteBlockIndex, WriteUtxo, WriteHashBestChain,
WriteVersion, WriteDbFormat) replace manual key/value construction
- TxnBegin/Commit cycles every 1000 headers / 50000 UTXOs preserve the
prior batching cadence
The IsRocksDbChainBackend() guard added in 76579e3 is dropped — snapshot
loading now works on either backend.
Two adjacent paths in init.cpp also hardcoded "txleveldb": the snapshot
auto-load guard (Step 6c) and the -reindex datadir wipe. Both updated to
GetChainDataDir() / WipeChainDataDir() so they pick the right directory
for the configured backend.
Helpers added to txdb.h / txdb-factory.cpp:
- GetChainDataDir(): on-disk path of the configured backend's chain DB
- WipeChainDataDir(): rm -rf the same path
Bootstrap archive paths (bootstrap.cpp lines 721+) intentionally still
reference txleveldb specifically — the prebuilt-index distribution
remains LevelDB-format until that pipeline is ported separately.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The secure-messaging store (smsgDB) used the LevelDB API directly. Mass-
mapped to the equivalent RocksDB types: leveldb::DB/Status/WriteBatch/
Iterator/Slice/ReadOptions/WriteOptions/WriteBatch::Handler -> rocksdb::*.
The RocksDB API surface for our usage is binary-compatible — pure namespace
substitution, no semantic changes. Consumers in rpcsmessage.cpp and
qt/messagemodel.cpp updated to match.
RocksDB now becomes a hard build dependency (was optional behind
BUILD_ROCKSDB). The chain-DB rocksdb backend is consequently always
available; -chaindb=leveldb remains the default until the Phase-4
LevelDB retirement. Removed the BUILD_ROCKSDB cmake option, the
#ifdef BUILD_ROCKSDB guards in txdb*, and the runtime error path
that triggered when the flag was off.
CI updated: librocksdb-dev (Ubuntu), mingw-w64-x86_64-rocksdb (MSYS2),
and rocksdb (Homebrew) added to all build jobs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>