#36266 rpc: Let dumptxoutset fail early on stale targets and concurrent runs
https://github.com/bitcoin/bitcoin/pull/36266 · · +57/-12 in 2 files, 2 commits · labels: RPC/REST/ZMQ
Goal
- Ensure snapshot generation fails immediately when given a stale block target
- Prevent concurrent snapshot calls from corrupting output files or prune locks
This pull request updates `dumptxoutset` to fail early on two edge cases. It verifies that a rollback target block index is actually on the active chain before copying UTXO data and disconnecting blocks, and it introduces a guard that restricts `dumptxoutset` to a single running instance to avoid file corruption and prune-lock collisions.
Problem: Currently, requesting a rollback to a stale block hash causes `dumptxoutset` to copy the full UTXO set and disconnect blocks down from the tip before ultimately failing. Additionally, initiating concurrent `dumptxoutset` calls results in both jobs writing to the same temporary `.incomplete` file and prematurely deleting or clobbering each other's prune locks.
Category: RPC / REST / ZMQ (#17 of 52)
P3 · bug fix
- P3 because the failure modes only occur in relatively rare edge cases
- Improves RPC reliability and prevents silent file corruption for node operators
- Limited impact because dumptxoutset is an infrequently used administrative command
Prevents data corruption of snapshot files and prune-lock invalidation during concurrent invocations of `dumptxoutset`, and eliminates redundant work when passed an invalid target on a stale branch. The scenarios are relatively rare, making the change worthwhile and clean without reaching category-critical urgency.
Membership: Modifies the `dumptxoutset` RPC in `src/rpc/blockchain.cpp` and adds RPC functional tests.
Factors: security/stability 1, bug 1, performance 0, user value 1, leverage 0
Reviewability: Ready
- Ready for review
The PR is small, mergeable, has passing tests, and is ready for review.
Author status: active
Agreement: Crickets
- No reviews or comments yet
- Recently opened with no feedback so far
No reviews or concept feedback yet
The PR was recently opened and has received no reviews or comments yet.
Review verdicts (DrahtBot): 0
Files
34 lines under test/bench/ci.
- src/rpc/blockchain.cpp +24/-11
- test/functional/rpc_dumptxoutset.py +33/-1
Card
This PR updates the `dumptxoutset` RPC to exit early when passed a rollback target that is not on the active chain and to reject concurrent executions. Without this change, rollback to a stale block executes an expensive UTXO copy before failing, and simultaneous invocations write to the same temporary file and clobber prune locks. The change is small, includes functional test coverage, and has not yet received review.