<p>The <code>chainstate/</code> directory contains a LevelDB database. There is no guarantee whatsoever that two LevelDB databases with the same content are identical (or even have the same size).</p>
<p>LevelDB internally structures their database storage as a number of table files, each containing keys of some range of keys with the corresponding values. Multiple files can cover overlapping ranges of keys. There are heuristics internally in the database logic to determine when these table files get merged and compacted into new ones, but there are hard to predict, as they depend on the exact order things were written in.</p>
<p>And it's very much expected that was what written to these two databases you observe differs, even if their contents is identical. One node has been running for years, so it'll have generally a write with updates once per block or per few blocks at most. The node that just recently completed initial block download (IBD) will have seen far fewer (but bigger) writes matching many blocks at once, as Bitcoin Core flushes much less frequently during IBD for performance reasons. Furthermore, due to internal in-memory caching in Bitcoin Core, many UTXOs will have been created and spent between two updates in the IBD case, causing them to never hit disk at all.</p>

CC BY-SA 4.0
2023-03-02T21:10:40.593Z
2023-03-02T21:14:48.463Z
2023-03-02T21:14:48.463Z
Pieter Wuille
<p>I run 2 nodes:</p>
<ol>
<li>a non-pruned, txindex=1 node that has been running for years (I can't tell exactly but I think I have been moving the same datadir around since 2014/15), core v23.0.0</li>
<li>a pruned node that I synced last week, core v24.0.1</li>
</ol>
<p>They are both synced.</p>
<p>I noticed that the chainstate of node 1 is 4.9G and node 2 is 5.5G (measured with <code>du -h chainstate</code>).</p>
<p>Number of files in each dir is also different, 2677 for node 1 and 3081 for node 2 (<code>ls -A chainstate | wc -l</code>).</p>
<p>I didn't expect that, because as far as I understand chainstate should be identical between nodes (I know that <code>blocks/</code> dir can vary significatively in size because of <code>revXXXX.blk</code> files).</p>
<p>So I'm curious about what's in the chainstate and how it can vary by that much between nodes.</p>

CC BY-SA 4.0
2023-03-02T20:15:35.673Z
Are there any `log` or `lock` files in either directory?
bigjosh
CC BY-SA 4.0
2023-03-02T20:16:49.643Z
Also, since different nodes can see transactions come in different order, maybe this is causing the indexes to build differently (even though then end up logically the same)?
bigjosh
<bitcoin-core><blockchain><storage-footprint>
Size of the `chainstate/` dir vary from node to node
Sosthène
# Size of the `chainstate/` dir vary from node to node

(Asked by: username_0 on 2023-02-28)

I run 2 nodes:

1. a non-pruned, txindex=1 node that has been running for years (I can't tell exactly but I think I have been moving the same datadir around since 2014/15), core v23.0.0
2. a pruned node that I synced last week, core v24.0.1

They are both synced.

I noticed that the chainstate of node 1 is 4.9G and node 2 is 5.5G (measured with `du -h chainstate`).

Number of files in each dir is also different, 2677 for node 1 and 3081 for node 2 (`ls -A chainstate | wc -l`).

I didn't expect that, because as far as I understand chainstate should be identical between nodes (I know that `blocks/` dir can vary significatively in size because of `revXXXX.blk` files).

So I'm curious about what's in the chainstate and how it can vary by that much between nodes.

**Tags:** bitcoin-core, blockchain, storage-footprint

> **Comments:**
> **username_1**: Are there any `log` or `lock` files in either directory?  
> **username_1**: Also, since different nodes can see transactions come in different order, maybe this is causing the indexes to build differently (even though then end up logically the same)?  

---

## 1 answers

### Answer by username_2 on 2023-03-02. Score: 3 | Accepted answer

The `chainstate/` directory contains a LevelDB database. There is no guarantee whatsoever that two LevelDB databases with the same content are identical (or even have the same size).

LevelDB internally structures their database storage as a number of table files, each containing keys of some range of keys with the corresponding values. Multiple files can cover overlapping ranges of keys. There are heuristics internally in the database logic to determine when these table files get merged and compacted into new ones, but there are hard to predict, as they depend on the exact order things were written in.

And it's very much expected that was what written to these two databases you observe differs, even if their contents is identical. One node has been running for years, so it'll have generally a write with updates once per block or per few blocks at most. The node that just recently completed initial block download (IBD) will have seen far fewer (but bigger) writes matching many blocks at once, as Bitcoin Core flushes much less frequently during IBD for performance reasons. Furthermore, due to internal in-memory caching in Bitcoin Core, many UTXOs will have been created and spent between two updates in the IBD case, causing them to never hit disk at all.


---

