Skip to content

backport: bitcoin#27556 - #7959

Merged
knst merged 1 commit into
dashpay:developfrom
thepastaclaw:backport-0.26-b200-misc
Oct 30, 2026
Merged

knst merged 1 commit into
dashpay:developfrom
thepastaclaw:backport-0.26-b200-misc

Conversation

@DCG-Claude

@DCG-Claude DCG-Claude commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

Backports 1 Bitcoin Core v0.26 pull request(s) to Dash.

What was done?

  • wallet: fix deadlock in bdb read write operation bitcoin/bitcoin#27556 — wallet: fix deadlock in bdb read write operation.
    Upstream: wallet: fix deadlock in bdb read write operation bitcoin/bitcoin#27556 (merge 6cc136b). Dash commit: f73e70b.
    Backports wallet: fix deadlock in bdb read write operation bitcoin/bitcoin#27556: BerkeleyCursor now always takes the batch so cursors use its transaction, and WalletBatch::EraseRecords runs inside a single transaction that is aborted on failure, with a test for BDB and SQLite. Dash adaptations: the ErasePrefix hunk is not needed because Dash's ErasePrefix already uses a raw cursor on the open transaction, the Dash-only transaction wrapper in DeleteRecords is removed because EraseRecords now opens its own, and the test uses TopUp() in place of SetupGe

    Dash adaptations:

    • src/wallet/bdb.cpp: ErasePrefix keeps Dash's raw-Dbc cursor, which already opens on activeTxn; the upstream this-›*this line has no counterpart in Dash's version
    • src/wallet/bdb.h, src/wallet/bdb.cpp: BerkeleyCursor goes from Dash's one-argument constructor (database only) to (database, const BerkeleyBatch&) and uses batch.txn(), instead of upstream's nullable BerkeleyBatch* argument
    • src/wallet/test/util.h: adds #include ‹wallet/db.h› so DATABASE_FORMATS has DatabaseFormat; upstream already had it from the MockableDatabase change (Introduce MockableDatabase for wallet unit tests bitcoin/bitcoin#26715)
    • src/wallet/test/walletdb_tests.cpp: legacy SPKM is set up with CanGenerateKeys() && TopUp(), since Dash has no SetupGeneration() (same idiom as Dash's walletload_tests)
    • src/wallet/scriptpubkeyman.cpp: DeleteRecords drops Dash's own TxnBegin/TxnCommit wrapper, because EraseRecords now opens the transaction and a second open fails

How Has This Been Tested?

Breaking Changes

None beyond the upstream changes themselves.

Checklist:

  • 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)

@DCG-Claude

DCG-Claude commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

Maintainer controls

Tick a box; backportsys acts within a few minutes, then clears it. For other requests, leave a review comment.

  • 🔒 Hands off — stop every automated update to this branch
  • 🔄 Rebase onto current develop
  • ❌ Close — abandon this batch and release its items

Hands off persists after its box clears: no automated branch updates until operator release (not tracker Release hold). Close abandons the batch and releases its items.

Adaptation and gates

Heavy: substantial adaptation; light: at most two invented lines (six counting functional-test/doc edits); faithful: identical to upstream apart from context. Mechanical checks compare upstream hunks, added lines and Dash-specific lines. Review warnings before merging.

Upstream Dash commit Adaptation Gates
bitcoin#27556 f73e70b heavy build:pass ci_upstream:warn mech:warn pick:pass tests:pass tree:pass verify:pass

Warning details

Fork gate: thepastaclaw#120 at f73e70b.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T19:44:34.347674Z f73e70b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@thepastaclaw

thepastaclaw commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Review not started yet because the new head is waiting for the 30-minute push debounce.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit f73e70b. Normal review starts when eligible; priority review starts as soon as a slot is available.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a4a54998-8677-4277-ba26-c6fa92e4ffeb
Commits

Reviewing files that changed from the base of the PR and between bcd1ef8 and f73e70b.

Files selected for processing: 3
  • src/wallet/test/util.h
  • src/wallet/test/wallet_tests.cpp
  • src/wallet/test/walletdb_tests.cpp
Files with no reviewable changes: 1
  • src/wallet/test/wallet_tests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

Berkeley cursors now use their batch transaction. EraseRecords runs in a transaction, checks erase results, aborts on iteration or erase failures, and returns the commit result. If cursor creation fails, it returns false without explicitly aborting. A wallet database test checks legacy record deletion for each enabled database format.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: knst

Merge Risk: Minimal · up to f73e7

No actionable merge-blocking risk remains in the reviewed wallet transaction changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title "backport: bitcoin#27556" names the backported upstream pull request, but it does not describe the change itself. The changeset fixes a read/write deadlock in BDB wallet operations by passin…
Description check Passed The description is directly related to the changeset. It states that it backports bitcoin#27556 and describes the BerkeleyCursor constructor change, the WalletBatch::EraseRecords transaction c…
Full details: Title check

Explanation

The title "backport: bitcoin#27556" names the backported upstream pull request, but it does not describe the change itself. The changeset fixes a read/write deadlock in BDB wallet operations by passing the batch's transaction to BerkeleyCursor and running EraseRecords in a single transaction. A reader must open the upstream PR to learn what the change does. The title is therefore partially related: it refers to the real change but gives no substantive aspect of it. It is not vague or generic, and it is not off-topic.

Full details: Description check

Explanation

The description is directly related to the changeset. It states that it backports bitcoin#27556 and describes the BerkeleyCursor constructor change, the WalletBatch::EraseRecords transaction change, the removed DeleteRecords transaction wrapper, and the added test. It also lists the Dash-specific adaptations and the test results.

Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 6 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The backport is correct and preserves the required Dash adaptations. The wallet transaction and Berkeley cursor changes are consistent across both database backends, the regression test exercises the relevant paths, and the CI retry change is applied to the applicable Dash script. Current CI has build and lint checks queued or in progress, with no failed code checks in the snapshot.

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: backport-reviewer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change modifies wallet Berkeley DB transaction and record-erasure logic plus associated tests, making it an ordinary behavior change in a storage-sensitive subsystem, while the CI adjustment is straightforward and it does not meet the defined critical-surface threshold.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — backport-reviewer (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — dash-core-commit-history (completed, effort high); agent phase2-reviewer

@thepastaclaw thepastaclaw added the pastaclaw:approved thepastaclaw's latest review approved this PR label Oct 29, 2026
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

CI failed at bcd1ef8 on dashpay/dash: linux64_multiprocess-test / Test source, x86_64-apple-darwin / Build depends

Both failures come from jobs this branch doesn't touch; it changes only ci/lint/04_install.sh (bitcoin#28643) and src/wallet BDB/walletdb code plus tests (bitcoin#27556). The x86_64-apple-darwin 'Build depends' job failed configuring gmp ('could not find a working compiler' with /usr/bin/clang and the Xcode SDK) after a depends cache miss, and nothing under depends/ or .github/ changed here. In linux64_multiprocess-test, feature_llmq_simplepose.py timed out waiting for masternode quorum connections in its close_mn_port PoSe phase; earlier quorums in the same run formed fine, so the wallet DB change was working, and feature_protx_version.py failed once then passed on retry, which suggests flaky quorum/P2P timing rather than this backport.


🤖 backportsys, on behalf of the Dash backport pipeline.

Comment thread ci/lint/04_install.sh Outdated
if [ ! -d "${PYTHON_PATH}/bin" ]; then
(
git clone https://github.com/pyenv/pyenv.git
${CI_RETRY_EXE} git clone https://github.com/pyenv/pyenv.git

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI_RETRY_EXE is not used at all in dash's CI; I suggest to skip 28643 complely.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, dropping bitcoin#28643 from this batch as you asked. Dash's CI doesn't rely on CI_RETRY_EXE, so adding it to the pyenv git clone in ci/lint/04_install.sh does nothing for Dash. Dropping bitcoin#28643 from this branch; it is being rewritten without it.


🤖 backportsys, on behalf of the Dash backport pipeline.

69d4390 test: add coverage for wallet read write db deadlock (furszy)
12daf6f walletdb: scope bdb::EraseRecords under a single db txn (furszy)
043fcb0 wallet: bugfix, GetNewCursor() misses to provide batch ptr to BerkeleyCursor (furszy)

Pull request description:

  Decoupled from bitcoin#26644 so it can closed in favor of bitcoin#26715.

  Basically, with bdb, we can't make a write operation while we are traversing the db with the same db handler. These two operations are performed in different txn contexts and cause a deadlock.

  Added coverage by using `EraseRecords()` which is the simplest function that executes this process.

  To replicate it, need bdb support and drop the first commit. The test will run forever.

ACKs for top commit:
  achow101:
    ACK 69d4390
  hebasto:
    re-ACK 69d4390

Tree-SHA512: b3773be78925f674e962f4a5c54b398a9d0cfe697148c01c3ec0d68281cc5c1444b38165960d219ef3cf1a57c8ce6427f44a876275958d49bbc0808486e19d7d

Dash adaptations:
- src/wallet/bdb.cpp: ErasePrefix keeps Dash's raw-Dbc cursor, which already opens on activeTxn; the upstream `this`->`*this` line has no counterpart in Dash's version
- src/wallet/bdb.h, src/wallet/bdb.cpp: BerkeleyCursor goes from Dash's one-argument constructor (database only) to (database, const BerkeleyBatch&) and uses batch.txn(), instead of upstream's nullable BerkeleyBatch* argument
- src/wallet/test/util.h: adds #include <wallet/db.h> so DATABASE_FORMATS has DatabaseFormat; upstream already had it from the MockableDatabase change (bitcoin#26715)
- src/wallet/test/walletdb_tests.cpp: legacy SPKM is set up with CanGenerateKeys() && TopUp(), since Dash has no SetupGeneration() (same idiom as Dash's walletload_tests)
- src/wallet/scriptpubkeyman.cpp: DeleteRecords drops Dash's own TxnBegin/TxnCommit wrapper, because EraseRecords now opens the transaction and a second open fails
@DCG-Claude
DCG-Claude force-pushed the backport-0.26-b200-misc branch from bcd1ef8 to f73e70b Compare October 30, 2026 19:40
@thepastaclaw thepastaclaw removed the pastaclaw:approved thepastaclaw's latest review approved this PR label Oct 30, 2026
@DCG-Claude DCG-Claude changed the title backport: bitcoin#28643, bitcoin#27556 backport: bitcoin#27556 Oct 30, 2026
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

Branch rewritten at f73e70b97e (1 backport(s)).


🤖 backportsys, on behalf of the Dash backport pipeline.

@knst knst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK f73e70b

@knst
knst merged commit 01f34d4 into dashpay:develop Oct 30, 2026
42 checks passed
@PastaPastaPasta PastaPastaPasta added this to the 24.1 milestone Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants