3
1
Let's say bitcoin node has 100 blocks. Then he recieve another two blocks. Now it have 102 blocks. But now he recieve block 103. And this block is from another chain and our node have to remove blocks 101 and 102 and replace them with this chain with block 101, 102 and 103.
So now it must rewind UTXO set back to node 100 and update with transactions from newly recieved nodes 101..103.
How nodes making this rollback in utxo set?
and how was this before v0.8? and for how many blocks are undo files hold? – Michal – 2019-05-26T20:12:59.577
2Before 0.8 an entirely different design was used, where instead of a UTXO set, a database was kept with for every output ever created whether it was spent, and if so, where it was spent. Rolling back just required marking those database entries as unspent again. – Pieter Wuille – 2019-05-26T20:15:23.957
2Undo data is kept for every block that is kept (undo files are around 10x smaller than the corresponding block files). If you prune your node, both old blocks and old undo data are pruned. – Pieter Wuille – 2019-05-26T20:16:21.077