bitcoin core growth – What are the use instances the place very outdated rev*.dat information are wanted?

  1. they usually’re 1::1 with block information (i.e., for a given NNNNN the information blkNNNNN.dat and revNNNNN.dat maintain data for a similar
  2. they usually’re written and chunked within the order wherein blocks are acquired by the node (from the community)

This assumption is wrong. The rev*.dat information are literally written in top order. It is because they’re written at a special time. The undo information for a block is simply written after it has been related to the chain tip, so the undo information finally ends up being within the order that blocks are related. So for blocks that are downloaded however by no means related, undo information doesn’t exist for them (though this case is unlikely as blocks aren’t downloaded until they’re purported to be related).

Then: Are very outdated rev*.dat information ever used? Say, people who belong to blocks buried greater than 100 blocks deep from the highest of the chain? In the event that they are ever used what’s the use case?

Relating to the operation of the node, no, outdated undo information just isn’t truly getting used. Nonetheless it does have some makes use of outdoors of node operation, notably in analyzing the blockchain by way of RPC, and the creation of the block filter and the coin stats indices.

The RPC makes use of undo information in some locations as a result of it comprises the UTXOs that have been spend by that block. This permits getblock to calculate the transaction charges paid for every transaction within the block. Nonetheless this isn’t a tough requirement, and if the undo information just isn’t discovered, then it merely would not calculate the charges.

One other RPC that makes use of the undo information is getblockstats which makes use of the undo information to additionally calculate the charges for the block in addition to the change in dimension of the UTXO set that the block causes. If the undo doesn’t exist, then this RPC would fail.

For each the block filter and coin stats indices, the undo information is used to construct them as a result of it gives a snapshot of the UTXO set adjustments made. This permits the index to be populated with out having to trace the UTXO set whereas it’s being constructed, so it reduces the reminiscence utilization and will increase efficiency.

For node operation, undo information is simply wanted if the block have been to be disconnected from the tip. This solely happens when reorgs occur. Nonetheless Bitcoin is constructed with the chance that there could possibly be an especially giant work reorg that might reorg out issues which might be thought of historic historical past.

Nonetheless, outdated undo information is certainly not utilized in operation of the node, and there could possibly be a mode added which deletes them. On my node, this totals to 48 GB of information, so the area financial savings aren’t almost as vital as regular pruning.

(and, w.r.t. the reply here of the primary query within the following record, what’s the database corruption that happens – presumably to the UTXO state – if the rev information are all deleted and why is it essential to regenerate them?)

They have to be regenerated due to how the block index works. Because it additionally comprises the situation of the undo information, if that information have been to be lacking, the block index will discover that to be an error and thus require a reindex. If an choice have been added to permit the deletion of rev*.dat information, then that might clearly should be modified.

(bonus query: given a txindex: is there something within the rev*.dat file that may’t be regenerated just by wanting on the blocks within the corresponding blk*.dat file and utilizing the txindex to seek out earlier transactions?

Sure, however that might be fairly gradual.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button