Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Is it intentional that if the target leaves the active chain between these two points, the operation can still reach I reproduced this on regtest by blocking the first Would it make sense to revalidate the target against the pinned tip immediately after if (tip->GetAncestor(target->nHeight) != target) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block is not in main chain");
}With this check, the same reproduction returns Tested on regtest, head 31000db, Linux aarch64 (Debian 13), GCC 14.2.0, Release. |
31000db to
755a45b
Compare
Not a big problem but it seemed worth addressing. I moved the check there instead of adding a second one, so there is still only one check now and it runs against the pinned tip. This also covers The one draw-back of this that I ran into: Since the check now runs after the output file is opened, a stale target would leave an empty |

This improves handling of two edge cases where
dumptxoutsetcurrently only fails after doing unnecessary and possibly incorrect work:Stale rollback target (first commit):
ParseHashOrHeightaccepts any known block hash, and the rollback path never checks the target is on the active chain. The full UTXO set is copied and blocks are disconnected back from the tip only to fail when the target block height is reached. This is now rejected before all that as an invalid param, matching the check ingetchaintxstatsandscanblocks. This is a pretty unlikely scenario but the fix is also very small.Concurrent calls (second commit): Nothing prevented triggering two runs at once and since this is a relatively long running operation I don't think it is that unlikely that this might happen by accident or that users think this might actually be a possible thing to do if you want two different dumps. On master currently both runs would write to
<path>.incomplete, so the second dump to the same path corrupts the file the first one reports as successfully written. And also the prune lock has a fixed name, so the second run overwrites the first's height and the first to finish deletes the others lock mid-rollback. A second call now fails immediately with "dumptxoutset is already running".TemporaryPruneLockis extended and renamed toDumptxoutsetGuardand handles both the general running of multiple instances and the lock management. The alternative to this approach would be to allow for concurrent runs and fix that behavior but it seemed to me like that would be overengineering considering that the audience for this functionality should be very small.