<p>No, they are not identical. There are various reasons for this:</p>

<ul>
<li><p>Different nodes may see blocks in a different order. Whenever a fork occurs, by definition some nodes on the network will have seen one block first, and others saw the other first. If they all saw the same blocks first, there wouldn't be any fork. As Bitcoin Core stores blocks in append-only block files, the order on disk reflects the order in which those blocks were seen in the network. Branches in forks that are reorganized out are kept on disk.</p></li>
<li><p>Different nodes may not even see all blocks another block sees. If there is a fork between block A and B, and A eventually is built upon further, the nodes that saw A first, and are not connected to any peers that saw B first, will likely never see B at all. This is true in particular for newly synchronized nodes, which typically don't hear about historical forks, and only downloaded the branch that won.</p></li>
<li><p>Different versions of Bitcoin Core manage the block files differently. Earlier versions would leave partially written blocks in the files when a crash occurred while writing a new block. Newer versions will reuse that space.</p></li>
</ul>

<p>However, despite all this, the <em>active</em> branch of the blockchain (which is the most-work chain that is valid according to the consensus rules) will converge over time across different nodes. This does not happen instantly (as forks may need resolving, which can take minutes or even hours), and does not imply that the files on disk are identical for the reasons above.</p>

CC BY-SA 3.0
2017-08-28T05:20:25.423Z
so why database that Bitcoin Core download a year ago (until now) is the same with database that downloaded a week ago?
Denis Leonov
CC BY-SA 3.0
2017-08-28T05:30:49.253Z
It isn't. I've answered that. The best chain they agree on will be identical (with very high probability), but their database _will not_.
Pieter Wuille
CC BY-SA 3.0
2017-08-28T05:45:18.803Z
but I have those two databases (files from blk00000.dat to blk00974.dat). And they are identical
Denis Leonov
CC BY-SA 3.0
2017-08-28T05:47:06.417Z
The files created while syncing the historical chain will be. The files creates while just running normally won't necessarily be.
Pieter Wuille
CC BY-SA 3.0
2017-08-28T06:37:36.347Z
So the question is about files in `blocks` dir. They are the equal?
Denis Leonov
CC BY-SA 3.0
2017-08-28T07:11:03.003Z
As I answered many times now: no, they are not necessarily identical. I'm afraid there is a language barrier that prevents me from explaining this.
Pieter Wuille
CC BY-SA 3.0
2017-08-28T07:15:32.553Z
You say `The files created while syncing the historical chain will be`. So I tell about this files.
Denis Leonov
CC BY-SA 3.0
2017-09-01T22:58:05.023Z
I don't know what more to say.
Pieter Wuille
CC BY-SA 3.0
2017-08-27T20:43:28.653Z
2017-08-27T20:43:28.653Z
Pieter Wuille
<p>All nodes pertaining to the same chain will have the same blocks database. That's the principle at the base of the blockchain being distributed. </p>

<p>Two nodes' databases may differ in the last block saved if a <a href="https://en.bitcoin.it/wiki/Vocabulary#Stale_Block" rel="nofollow noreferrer">stale block</a> is created. </p>

<p>One may have a different block in top of the chain until it realizes that the network has chosen another block. At that point the node will sync and its database will be the same as every other full node.</p>

<p><strong>Edit</strong></p>

<p>Sorry, my bad, I had read somewhere that all the stale blocks created were deleted after a while, so I tought that everyone had the smae *blk files apart from the last ones. Maybe that site was oversimplifying it.</p>

<p>Thanks for correcting me and letting me understand it correctly. </p>

CC BY-SA 3.0
2017-08-23T07:40:17.803Z
I mean files blk*.dat, except the last one (that is not full). Is this files are the same on all, or they differs?
Denis Leonov
CC BY-SA 3.0
2017-08-23T08:01:41.377Z
those files are the block database, which, as I stated in my answer, is shared and equal in all nodes
Ivano Donadi
CC BY-SA 3.0
2017-08-23T16:23:09.790Z
This is incorrect. While the longest chain will frequently be identical across nodes, the blk* files likely will not, as those also contain all forks your node has seen, and in what order. Different nodes see different forks.
Pieter Wuille
CC BY-SA 3.0
2017-08-24T05:23:34.837Z
Sorry, I had read somewhere that stale blocks were deleted after a while, so I thought that the files returned to be the same
Ivano Donadi
CC BY-SA 3.0
2017-08-27T21:02:39.913Z
When running with pruning, old stale blocks are indeed deleted (but so are non-stale ones).
Pieter Wuille
CC BY-SA 3.0
2017-08-23T07:35:05.250Z
2017-08-24T05:57:28.807Z
2017-08-24T05:57:28.807Z
Ivano Donadi
<p>Is it true that a full bitcoin database is not equal on each node?</p>

<p>I mean database (files) in <code>blocks</code> dir, which create official bitcoin client locally.</p>

<p>What is that bitcoin database?</p>

<blockchain><bitcoin-core><database>
Bitcoin full database is not equal on each node
Denis Leonov
# Bitcoin full database is not equal on each node

(Asked by: username_0 on 2017-08-23)

Is it true that a full bitcoin database is not equal on each node?

I mean database (files) in `blocks` dir, which create official bitcoin client locally.

What is that bitcoin database?

**Tags:** blockchain, bitcoin-core, database


---

## 2 answers

### Answer by username_1 on 2017-08-27. Score: 2 | Accepted answer

No, they are not identical. There are various reasons for this:

* Different nodes may see blocks in a different order. Whenever a fork occurs, by definition some nodes on the network will have seen one block first, and others saw the other first. If they all saw the same blocks first, there wouldn't be any fork. As Bitcoin Core stores blocks in append-only block files, the order on disk reflects the order in which those blocks were seen in the network. Branches in forks that are reorganized out are kept on disk.
* Different nodes may not even see all blocks another block sees. If there is a fork between block A and B, and A eventually is built upon further, the nodes that saw A first, and are not connected to any peers that saw B first, will likely never see B at all. This is true in particular for newly synchronized nodes, which typically don't hear about historical forks, and only downloaded the branch that won.
* Different versions of Bitcoin Core manage the block files differently. Earlier versions would leave partially written blocks in the files when a crash occurred while writing a new block. Newer versions will reuse that space.

However, despite all this, the *active* branch of the blockchain (which is the most-work chain that is valid according to the consensus rules) will converge over time across different nodes. This does not happen instantly (as forks may need resolving, which can take minutes or even hours), and does not imply that the files on disk are identical for the reasons above.

> **Comments:**
> **username_0**: so why database that Bitcoin Core download a year ago (until now) is the same with database that downloaded a week ago?  
> **username_1**: It isn't. I've answered that. The best chain they agree on will be identical (with very high probability), but their database _will not_.  
> **username_0**: but I have those two databases (files from blk00000.dat to blk00974.dat). And they are identical  
> **username_1**: The files created while syncing the historical chain will be. The files creates while just running normally won't necessarily be.  
> **username_0**: So the question is about files in `blocks` dir. They are the equal?  
> **username_1**: As I answered many times now: no, they are not necessarily identical. I'm afraid there is a language barrier that prevents me from explaining this.  
> **username_0**: You say `The files created while syncing the historical chain will be`. So I tell about this files.  
> **username_1**: I don't know what more to say.  

---

### Answer by username_2 on 2017-08-23. Score: 0

All nodes pertaining to the same chain will have the same blocks database. That's the principle at the base of the blockchain being distributed.

Two nodes' databases may differ in the last block saved if a [stale block](https://en.bitcoin.it/wiki/Vocabulary#Stale_Block) is created.

One may have a different block in top of the chain until it realizes that the network has chosen another block. At that point the node will sync and its database will be the same as every other full node.

**Edit**

Sorry, my bad, I had read somewhere that all the stale blocks created were deleted after a while, so I tought that everyone had the smae \*blk files apart from the last ones. Maybe that site was oversimplifying it.

Thanks for correcting me and letting me understand it correctly.

> **Comments:**
> **username_0**: I mean files blk*.dat, except the last one (that is not full). Is this files are the same on all, or they differs?  
> **username_2**: those files are the block database, which, as I stated in my answer, is shared and equal in all nodes  
> **username_1**: This is incorrect. While the longest chain will frequently be identical across nodes, the blk* files likely will not, as those also contain all forks your node has seen, and in what order. Different nodes see different forks.  
> **username_2**: Sorry, I had read somewhere that stale blocks were deleted after a while, so I thought that the files returned to be the same  
> **username_1**: When running with pruning, old stale blocks are indeed deleted (but so are non-stale ones).  

---

