#36047 rpc: handle createNewBlock() returning nullptr during shutdown
| Reviewability | Reviews | Agreement | Size | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| #36047 rpc: handle createNewBlock() returning nullptr during shutdown | Author silent 73d | 0 | Crickets | 6 + 34 tests | ||||||
|
|
|
|
| ||||||
Reviewability: ReadyStalePaused Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs. Size: lines added or modified outside tests, then in tests; greener = smaller. | ||||||||||
Goal
Fixes mining RPC handling when createNewBlock() returns nullptr on node shutdown. Instead of failing a CHECK_NONFATAL assertion and reporting an internal bug, getblocktemplate and generateblock throw a standard RPC_CLIENT_NOT_CONNECTED ("Shutting down") error, and generateBlocks stops mining cleanly.
Problem: When getblocktemplate or generateblock is executed or waiting on longpoll during node shutdown, createNewBlock() returns nullptr. Previously, CHECK_NONFATAL treated this benign shutdown condition as an internal bug.
Reviewability
Stale · Author silent 73d
No author activity for 73 days; a review may wait a long time for a response.
Waiting on (from the thread read):
- author: rebase 2026-10-19
Agreement
Crickets
no substantive comment either way
Thread notes: Initial record. Only statement is a process ping from sedited requesting a rebase. / Initial record. No reviews or substantive comments yet, only a rebase ping from sedited.
Objections, suggestions, and questions: none recorded.
Participants:
- sedited (member, neutral, 1 statements 2026-10-19 to 2026-10-19): pinged for rebase
Files
35 lines under test/bench/ci.
- test/functional/mining_getblocktemplate_longpoll.py +34/-1
- src/rpc/mining.cpp +6/-3
Card
The short text the ranking pass compares across PRs.
This PR handles createNewBlock() returning nullptr during shutdown in getblocktemplate, generateblock, and generateBlocks, replacing a CHECK_NONFATAL assertion with a standard 'Shutting down' RPC error. This resolves issue #34262 where miners using longpolling hit spurious 'Internal bug detected' errors when stopping bitcoind. The PR includes functional test coverage for getblocktemplate longpoll shutdown behavior. It is currently unreviewed.
Data
thread read through 2026-10-19 (1 statements), head b1fa37ea86
labels: RPC/REST/ZMQ, Needs rebase
Categories
Mining
P3 · bug fix (ranking pass: Moved up: it is the only fix for a user-reported failure (#34262) miners hit in normal operation, so it leads the P3 block ahead of tooling and refactors.)
Fixes mining RPCs to cleanly handle shutdown rather than triggering a CHECK_NONFATAL assertion. When getblocktemplate longpolls or runs during node shutdown, createNewBlock() returns nullptr, which previously raised a non-fatal assertion reporting an internal bug.
Membership: Changes getblocktemplate and generateblock error handling in src/rpc/mining.cpp when createNewBlock() returns nullptr.
Factors: security/stability 1, bug 1, performance 0, user value 1, leverage 0
RPC / REST / ZMQ
P3 · bug fix (ranking pass: Moved up 12: spurious 'Internal bug detected' responses to mining clients at shutdown is a user-visible false error, not cosmetic.)
Ensures standard RPC error codes are returned instead of internal assertion errors during shutdown. Rather than reporting a non-fatal internal bug, getblocktemplate and generateblock throw standard RPC_CLIENT_NOT_CONNECTED ('Shutting down') errors.
Membership: Labeled RPC/REST/ZMQ and modifies error handling in src/rpc/mining.cpp to return standard RPC_CLIENT_NOT_CONNECTED on shutdown.
Factors: security/stability 1, bug 1, performance 0, user value 1, leverage 0