Skip to content

backport: v0.26 bitcoin#28139, bitcoin#27866, bitcoin#28038, bitcoin#28039 - #81

Merged
DCG-Claude merged 6 commits into
developfrom
backport-0.26-b061-misc
Oct 15, 2026
Merged

DCG-Claude merged 6 commits into
developfrom
backport-0.26-b061-misc

Conversation

@DCG-Claude

@DCG-Claude DCG-Claude commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Automated Bitcoin Core v0.26 backports, batch backport-0.26-b061-misc.

upstream commit gates notes
bitcoin#28139 5d368c4c65 pick:pass build:pass tests:warn mech:warn tree:pass verify:pass Backports bitcoin#28139 by moving test_locked_wallet onto its own encrypted 'locked_wallet', funded from and returned to
bitcoin#27866 ae9819502b pick:pass build:pass tests:pass mech:warn tree:pass verify:pass Backports bitcoin#27866: BlockManager::FlushBlockFile and FlushUndoFile now return a bool, they and FindBlockPos are mar
bitcoin#28038 bcc22777a1 pick:pass build:pass tests:pass mech:pass tree:pass verify:pass This backports bitcoin#28038 completely: during wallet migration, 'send' address-book labels are now copied to both the
bitcoin#28039 3a183f4623 pick:pass build:pass tests:pass mech:pass tree:pass verify:pass Backports bitcoin#28039 in full: the BDB headers (db_cxx.h) are now included only from wallet/bdb.cpp and wallet/salvage
Provenance

Each commit passed: cherry-pick (adapted by an Opus lane only where conflicts existed), build, touched tests, a mechanical diff-of-diffs check (every upstream hunk landed; no added line without an upstream counterpart), and an independent Opus verification lane where anything was adapted. Gate rows and lane artifacts are in the backportsys DB.

@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

tracker#3470 closed by a human

@DCG-Claude DCG-Claude closed this Oct 13, 2026
@DCG-Claude DCG-Claude changed the title backport: v0.26 bitcoin#28139, bitcoin#28232, bitcoin#27866, bitcoin#28038, bitcoin#28039 backport: v0.26 bitcoin#28139, bitcoin#27866, bitcoin#28038, bitcoin#28039 Oct 13, 2026
@DCG-Claude
DCG-Claude force-pushed the backport-0.26-b061-misc branch from 182f468 to 3a183f4 Compare October 13, 2026 19:37
PastaPastaPasta and others added 6 commits October 15, 2026 12:10
…ing mnsync

On test networks a node only fetched sporks by sending GETSPORKS from the
mnsync tick. That request was skipped once mnsync finished, skipped for any
peer address with a still-valid "spork-sync" entry in netfulfilled.dat
(which survives restarts), and skipped for inbound peers on an active
masternode. A node that came up without sporks, e.g. after the sporks.dat
format change in v24, could therefore finish mnsync without them and never
ask again, leaving DKG and ChainLocks disabled until `mnsync reset`.

Announce every active spork as an inv to each relay-capable peer when the
handshake completes, in both directions. Peers request the ones they lack
with getdata, and a node that newly accepts a spork already relays it, so
the spork set converges without any opt-in or sync state. The GETSPORKS
handler is kept so v23 nodes can still ask us.

Fixes dashpay#7891

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… requesting them during mnsync

ce24c40 fix(net): announce sporks to new peers instead of requesting them during mnsync (pasta)

Pull request description:

  ## Issue being fixed or feature implemented
  Fixes dashpay#7891.

  On test networks (testnet, devnets, regtest), a node only fetched sporks by sending `GETSPORKS` from the mnsync tick. That request was skipped:
  - after mnsync finished, which on regtest and active masternodes is effectively permanent, because the 60-minute sync restart is disabled there;
  - for any peer address with a still-valid `spork-sync` entry in `netfulfilled.dat`, which survives restarts (it expires after 5 minutes on test chains);
  - for inbound peers on an active masternode, which in a small network are most of its peers.

  So a node that came up without sporks could finish mnsync without them and never ask again. One way that happens is v24 discarding v23's `sporks.dat` after its format change. Another is the peers it asked during sync having none themselves. Without SPORK_17/19 a masternode skips DKG, gets PoSe-banned, and ignores ChainLocks until someone runs `mnsync reset`.

  ## What was done?
  - In the `VERACK` handler, on test chains, a node now announces each active spork as an inv to every new peer that can relay. Both sides do this, so whichever side has the sporks hands them over regardless of connection direction or sync state. The peer requests only the sporks it lacks with `getdata`, and a node that accepts a new spork already relays it to its peers. The spork set therefore spreads through the network without any opt-in or saved state.
  - Removed the `spork-sync` / `GETSPORKS` request from `SyncManager::ProcessTick`.
  - Kept the `GETSPORKS` handler so older nodes can still ask us. New nodes no longer ask older peers. That only matters on test networks during the upgrade window, and an older node still sends its sporks to new nodes whenever it learns a new one.

  Overhead is about 36 bytes of inv per spork per new connection (at most 5 sporks). Signature checks happen only for sporks the node doesn't already have. Mainnet is unchanged.

  ## How Has This Been Tested?
  - Changed the existing scenario in `feature_sporks.py`: node 2 is forced to finish mnsync before node 1, which restored its sporks from cache, connects to it. Node 2 must then receive the spork. This replaces the `generate` the test previously needed to start mnsync.
    - Run against an unpatched `dashd` built from current develop, the test fails: it times out waiting for node 2's spork.
    - With this change it passes.
  - Also passing locally on macOS arm64 (debug build): `p2p_instantsend.py`, `feature_llmq_chainlocks.py`, `feature_asset_locks.py`, `feature_dip3_deterministicmns.py --descriptors`, `feature_llmq_signing.py`, `feature_llmq_signing.py --spork21`.
  - Every mininode connection in the functional tests (`P2PInterface`) now receives spork invs when sporks are set. I checked the tests that assert on `inv` messages or define their own `on_inv`: none of them set sporks, or they ignore spork invs.

  ## Breaking Changes
  None. Spork propagation on test networks moves from a request during mnsync to announcements at connect. The P2P messages involved are unchanged.

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [ ] I have made corresponding changes to the documentation
  - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

  🤖 Generated with [Claude Code](https://claude.com/claude-code)

Top commit has no ACKs.

Tree-SHA512: 7a88457a9a4c0bfb6ee87b2a6d94cc8df688f9b6a5fa56a5b9d927d40976aa58c188b56b7d8299f82045438c66091153eb3e32d5294c25f6a43b01c06a183046
…let case

c648bdb test: create wallet specific for test_locked_wallet case (furszy)

Pull request description:

  Coming from bitcoin#28089 (comment).

  Several test cases are relying on the node1 default wallet, which thanks to 'test_locked_wallet' is encrypted.
  And can be only accessed within a specific timeframe (100ms), a duration internally set by the same test.

  This situation introduces a potential race condition, where other tests must complete their operations within
  the specified 100ms window to pass (otherwise the wallet gets re-locked and they fail).

  This can be seen running the test in valgrind (bitcoin#28089), where other test cases fail due the wallet re-locking
  itself after the 100ms.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK c648bdb
  ishaanam:
    utACK c648bdb

Tree-SHA512: 01cde5a4a0cb3405adb9ea3c1f73841f3fa237d1162268ed06f0d49ca38541006b423a029e0b5e5955e1aa7e018c4600d894e555a68cf17ff60a4b8be58f4aa9

Dash adaptations:
- test/functional/wallet_fundrawtransaction.py: kept Dash's `pkh(...)` descriptors instead of upstream's `wpkh(...)` (Dash has no segwit)
- test/functional/wallet_fundrawtransaction.py: kept Dash's `walletpassphrase(..., 999000)` timeouts instead of upstream's 10/100/600 — Dash already carries the later bitcoin#28403 which bumped these, so restoring the small values would regress it
- test/functional/wallet_fundrawtransaction.py: kept Dash's amounts (sendtoaddress 12, output 11, balance delta 511.0000000) rather than upstream's 1.2/1.1/51.10000000 — Dash's block subsidy and this test's amounts are 10x
- test/functional/wallet_fundrawtransaction.py: did not add upstream's `wallet.getrawchangeaddress()` (keypool drain) or `wallet.keypoolrefill(8)` lines — those lines do not exist in Dash's copy of this test (they were never introduced in Dash history); only the self.nodes[1]->wallet rename part of those upstream hunks applies
- test/functional/wallet_fundrawtransaction.py: changeless-tx fee deduction is `0.00000500` instead of upstream's `0.00002200`. Upstream's constant is exactly the fee of a 110-vB segwit tx at Bitcoin's test fallbackfee of 0.0002/kB; Dash's test fallbackfee/min relay fee is 0.00001/kB (1 duff/byte) and the tx is a legacy 1-in/1-out ~192 bytes, so the required fee is ~192 duffs. With 2200 deducted the 2008-duff remainder exceeds min_viable_change (discard fee 10000/kB * 148 B + 1 = 1481 duffs), so the wallet would demand a change output and `fundrawtransaction` would fail with -4 on the locked wallet instead of returning changepos -1. 500 duffs covers the fee and leaves 308 < 1481, giving the changeless tx upstream intends. Dash's old 2200 (with its stale 'bnb doesn't work same way as in bitcoin' comment) was sized for the previous multi-input selection and no longer applies now that the wallet holds exactly one UTXO; replaced by upstream's comments plus a one-line note about the value.
d8041d4 blockstorage: Return on fatal undo file flush error (TheCharlatan)
f0207e0 blockstorage: Return on fatal block file flush error (TheCharlatan)
5671c15 blockstorage: Mark FindBlockPos as nodiscard (TheCharlatan)

Pull request description:

  The goal of this PR is to establish that fatal blockstorage flush errors should be treated as errors at their call site.

  Prior to this patch `FlushBlockFile` may have failed without returning in `Chainstate::FlushStateToDisk`, leading to a potential write from `WriteBlockIndexDB` that may refer to a block that is not fully flushed to disk yet. By returning if either `FlushUndoFile` or `FlushBlockFile` fail, we ensure that no further write operations take place that may lead to an inconsistent database when crashing. Add `[[nodiscard]]` annotations to them such that they are not ignored in future.

  Functions that call either `FlushUndoFile` or `FlushBlockFile`, need to handle these extra abort cases properly. Since `Chainstate::FlushStateToDisk` already produces an abort error in case of `WriteBlockIndexDB` failing, no extra logic for functions calling `Chainstate::FlushStateToDisk` is required.

  Besides `Chainstate::FlushStateToDisk`, `FlushBlockFile` is also called by `FindBlockPos`, while `FlushUndoFile` is only called by `FlushBlockFile` and `WriteUndoDataForBlock`. For both these cases, the flush error is not further bubbled up. Instead, the error is logged and a comment is provided why bubbling up an error would be less desirable in these cases.

  ---

  This pull request is part of a larger effort towards improving the shutdown / abort / fatal error handling in validation code. It is a first step towards implementing proper fatal error return type enforcement similar as proposed by theuni in this pull request [comment](bitcoin#27711 (comment)). For ease of review of these critical changes, a first step would be checking that `AbortNode` leads to early and error-conveying returns at its call site. Further work for enforcing returns when `AbortNode` is called is done in bitcoin#27862.

ACKs for top commit:
  stickies-v:
    re-ACK d8041d4
  ryanofsky:
    Code review ACK d8041d4

Tree-SHA512: 47ade9b873b15e567c8f60ca538d5a0daf32163e1031be3212a3a45eb492b866664b225f2787c9e40f3e0c089140157d8fd1039abc00c7bdfeec1b52ecd7e219

Dash adaptations:
- src/node/blockstorage.cpp: FlushUndoFile/FlushBlockFile keep Dash's AbortNode("Flushing ... failed...") instead of upstream's m_opts.notifications.flushError(...) — Dash has not backported the kernel notifications interface; only the added `return false;`/`success = false;` return-code handling from this PR was applied around it
7ecc29a test: wallet, add coverage for addressbook migration (furszy)
a277f83 wallet: migration bugfix, persist empty labels (furszy)
1b64f64 wallet: migration bugfix, clone 'send' record label to all wallets (furszy)

Pull request description:

  Addressing two specific bugs encountered during the wallet migration process, related to the address book, and improves the test coverage for it.

  Bug 1: Non-Cloning of External 'Send' Records
  The external 'send' records were not being correctly cloned to all wallets.

  Bug 2: Persistence of Empty Labels
  As address book entries without associated db label records can be treated as change (the `label` field inside the `CAddressBookData` class is optional, `nullopt` labels make `CAddressBookData ::IsChange()` return true), we must persist empty labels during the migration process.
  The user might have called `setlabel` with an "" string for an external address and that must be retained during migration.

ACKs for top commit:
  achow101:
    ACK 7ecc29a

Tree-SHA512: b8a8483a4178a37c49af11eb7ba8a82ca95e54a6cd799e155e33f9fbe7f37b259e28372c77d6944d46b6765f9eaca6b8ca8d1cdd9d223120a3653e4e41d0b6b7

Dash adaptations:
- src/wallet/wallet.cpp: kept Dash's string-based purpose line `if (purpose != "unknown") batch.WritePurpose(address, purpose);` plus its `auto purpose{...}` local instead of upstream's `if (addr_book_data.purpose) batch.WritePurpose(address, PurposeToString(*addr_book_data.purpose));` — that line is unchanged context in the upstream diff and reflects the AddressPurpose enum conversion Dash has not backported (CAddressBookData::purpose is still std::string defaulting to "unknown"); only the label change from this PR was applied
8b5397c wallet: bdb: include bdb header from our implementation files only (Cory Fields)
6e01062 wallet: bdb: don't use bdb define in header (Cory Fields)
004b184 wallet: bdb: move BerkeleyDatabase constructor to cpp file (Cory Fields)
b3582ba wallet: bdb: move SafeDbt to cpp file (Cory Fields)
e5e5aa1 wallet: bdb: move SpanFromDbt to below SafeDbt's implementation (Cory Fields)
4216f69 wallet: bdb: move TxnBegin to cpp file since it uses a bdb function (Cory Fields)
43369f3 wallet: bdb: drop default parameter (Cory Fields)

Pull request description:

  Only `#include` upstream bdb headers from our cpp files.

  It's generally good practice to avoid including 3rd party deps in headers as otherwise they tend to sneak into new compilation units. IMO this makes for a nice cleanup.

  There's a good bit of code movement here, but each commit is small and _should_ be obviously correct.

  Note: in the future, the buildsystem can add the bdb include path for `bdb.cpp` and `salvage.cpp` only, rather than all wallet sources.

ACKs for top commit:
  achow101:
    reACK 8b5397c
  hebasto:
    ACK 8b5397c

Tree-SHA512: 0ef6e8a9c4c6e2d1e5d6a3534495f91900e4175143911a5848258c56da54535b85fad67b6d573da5f7b96e7881299b5a8ca2327e708f305b317b9a3e85038d66

Dash adaptations:
- src/wallet/bdb.h: upstream removes a namespace-scope `SafeDbt` class; Dash still has it nested as `BerkeleyBatch::SafeDbt` (Dash predates the upstream refactor that hoisted it out). Since its `Dbt m_dbt;` member needs the complete BDB type, the nested class had to be removed from the header too — it is now defined at `wallet` namespace scope in bdb.cpp exactly as upstream's final state.
- src/wallet/bdb.cpp: the `BerkeleyBatch::SafeDbt::` out-of-line member definitions are unqualified to `SafeDbt::` to match the new namespace-scope class; all call sites are inside `BerkeleyBatch` members in this TU, so unqualified `SafeDbt` still resolves.
- src/wallet/bdb.cpp: the anonymous-namespace `SpanFromDbt` took `const BerkeleyBatch::SafeDbt&` in Dash; removed there and re-added as upstream's `static ... SpanFromDbt(const SafeDbt&)` after the class definition.
- src/wallet/bdb.h: the conflict hunk that deletes the old `SafeDbt` carried upstream's `BerkeleyCursor` class as context, which Dash does not have (Dash still uses `BerkeleyBatch::StartCursor/ReadAtCursor/CloseCursor`). Kept Dash's `BerkeleyDatabase::SupportsAutoBackup()` override and applied only the deletion the hunk actually makes — no BerkeleyCursor was introduced.
- src/wallet/salvage.cpp: took upstream's `env->TxnBegin(DB_TXN_WRITE_NOSYNC)` but kept Dash's `CWallet dummyWallet(/*chain=*/nullptr, /*coinjoin_loader=*/nullptr, "", gArgs, CreateDummyWalletDatabase())` plus `SetupLegacyScriptPubKeyMan()` — upstream's `DummyDatabase` one-liner is an unrelated, newer constructor signature.
- src/wallet/bdb.h: kept Dash's `namespace wallet {` / `struct WalletDatabaseFileId` adjacency (no blank line) rather than upstream's, purely cosmetic.
@PastaPastaPasta
PastaPastaPasta force-pushed the backport-0.26-b061-misc branch from 3a183f4 to acb58ed Compare October 15, 2026 17:24
@DCG-Claude
DCG-Claude merged commit f3ad665 into develop Oct 15, 2026
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

merged as dashpay#7863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants