dumptxoutset rollback feature does not take forks into account #32817

issue sipa openend this issue on June 26, 2025
  1. sipa commented at 12:35 pm on June 26, 2025: member

    In the dumptxoutset RPC, when the rollback feature is used with a height H, it will issue an InvalidateBlock on the active-chain block at height H+1. However, if an inactive branch of the chain exists that forks off at height H or below, and extends to block H+1 or later (or has equivalent PoW to that), InvalidateBlock will reorg there, and dump will be for the tip of that branch, rather than the height-H ancestor of the main chain.

    I have not tested this to verify, so it is possible I am missing something.

  2. Sjors commented at 2:03 pm on June 26, 2025: member
    cc @fjahr
  3. fjahr commented at 3:55 pm on June 26, 2025: contributor
    Sigh, yeah, that’s probably right. When taken to an extreme (aka Testnet4) that’s a really annoying problem as I have experienced in #31117. Since I have to deal with this anyway so I will address this soon.
  4. maflcko commented at 3:59 pm on June 26, 2025: member

    Isn’t this addressed by the throw here?

    https://github.com/bitcoin/bitcoin/blob/67ea4b9994e668dcea5e5d0f62f886d92e3737dc/src/rpc/blockchain.cpp#L3111

    I think there is still a race when calling submitblock, but this doesn’t seem related to forks per se.

  5. sipa commented at 4:03 pm on June 26, 2025: member
    @maflcko Right! So indeed, it won’t (ignoring race conditions) dump the wrong thing - but if you have a fork at a certain height, you’ll just be unable to dump at that height.
  6. maflcko commented at 4:08 pm on June 26, 2025: member

    you’ll just be unable to dump at that height.

    Could do a manual invalidateblock of the low-work forks to work around the error, but yea, could be annoying if the forks are more than 1, or longer than 1 block.

  7. maflcko added the label RPC/REST/ZMQ on Jun 26, 2025
  8. mzumsande commented at 4:48 pm on June 26, 2025: contributor
    We could also automate it: Iterate over the block index to find all fork blocks at the target height and invalidate those too, only then do the invalidation on the main chain block / do the dump, and finally reconsider everything. Though I’m not sure if that would be overkill.
  9. Sjors commented at 9:51 am on June 27, 2025: member
    This goes back to the discussion in #29565 that we shouldn’t be using block invalidation as a hack to trigger the chain state manager into rolling back. Instead we should perform the rollback directly (though no need for a new RPC).

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-07-07 21:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me