Investigate removing RewindBlockIndex() #20643

issue jnewbery opened this issue on December 13, 2020
  1. jnewbery commented at 3:23 PM on December 13, 2020: member

    RewindBlockIndex() is a mechanism to allow nodes to be upgraded after segwit activation, while still keeping their chainstate/datadir in a consistent state. It works as follows:

    • A pre-segwit (i.e. v0.13.0 or older) node is running.
    • Segwit activates. The pre-segwit node remains sync'ed to the tip, but is not enforcing the new segwit rules.
    • The user upgrades the node to a segwit-aware version (v0.13.1 or newer).
    • On startup, in AppInitMain(), RewindBlockIndex() is called (https://github.com/bitcoin/bitcoin/blob/ade38b6ee8f91e441507c0ee7ffe6ca020748991/src/init.cpp#L1692). This walks the chain backwards from the tip, disconnecting and erasing blocks that from after segwit activation that weren't validated with segwit rules.
    • those blocks are then redownloaded (with witness data) and validated with segwit rules.

    This logic probably isn't required any more since:

    • Segwit activated at height 481824, when the block chain was 130GB and the total number of txs was 250 million. Today, we're at height 661100, the blockchain is around 315GB and the total number of txs is around 600 million. Even if 20% of that added data is witness data (a high estimate), then around 150GB of transactions would need to be rewound to get back to segwit activation height. It'd probably be faster to simply validate from genesis, especially since we won't be validating any scripts before the assumevalid block. It's also unclear whether rewinding 150GB of transactions would even work. It's certainly never been tested.
    • Bitcoin Core v0.13 is hardly used any more. https://luke.dashjr.org/programs/bitcoin/files/charts/software.html shows less than 50 nodes running it. The software was EOL on Aug 1st 2018. It's very unlikely that anyone is running 0.13 and will want to upgrade to 0.22.

    Removing this dead code would allow the following:

  2. jnewbery added the label Feature on Dec 13, 2020
  3. MarcoFalke commented at 8:39 AM on December 14, 2020: member

    How is this different from #17862 ?

  4. MarcoFalke removed the label Feature on Dec 14, 2020
  5. MarcoFalke added the label Brainstorming on Dec 14, 2020
  6. jnewbery commented at 8:51 AM on December 14, 2020: member

    Ah. I wasn't aware of #17862. I guess the only difference is that this one has a bit more explanation and motivation.

  7. jnewbery closed this on Dec 14, 2020

  8. DrahtBot locked this on Feb 15, 2022
Contributors

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: 2026-04-30 12:14 UTC

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