<p>It is perfectly possible that the same block is stored twice in the Bitcoin Core blk*.dat files.; there is no guarantee that the files contain the blocks in sequential order, or continuously, and unused space may exist in them which contain (parts of) blocks as well, from the active chain or stale blocks.</p>
<p>Bitcoin Core maintains an index of where which block is to be found on disk. If you parse things yourself, you will need to figure out the relation between all the blocks you find, and determine which ones are valid. Since every block contains a hash of its parent, if you see the same block data twice, it is necessarily the same block, at the same height.</p>

CC BY-SA 4.0
2024-09-30T14:01:05.110Z
Short question: Does that space ever get cleaned up?
Mihai Popescu
CC BY-SA 4.0
2024-09-30T17:09:29.530Z
No, similar to how stale blocks never get cleaned up. If the few % extra space that these together may cause is an issue, you almost certainly just want to enable pruning, which deletes all block data after some time, stale or not.
Pieter Wuille
CC BY-SA 4.0
2024-09-29T18:22:51.137Z
2024-09-29T18:22:51.137Z
Pieter Wuille
<p>I created a parser and split the entire chain into pieces.</p>
<p>When inserting them into a database, to my surprise there were 187 blocks with the same hashes, so initially I thought there was something wrong with what I was doing, but after debugging, I found duplicates inside the blockchain.</p>
<p>I only investigated one block with the hash: 00000000000000000002927103A1BC8426DEFE05CFFA40BE468072B984C8876B.</p>
<p>I found the same block in two different .dat files: blk03361.dat, blk03363.dat.
I know for sure that the two blocks are identical because I split both dat files into blocks and compared the hashes:</p>
<pre><code>sha256sum 1/1_part_65.bin
d81340e3e1c1759e4b78dc1cd531230b55d1828fd14ed0f9ba8cd9269a7ee322  1/1_part_65.bin
sha256sum 3/3_part_77.bin
d81340e3e1c1759e4b78dc1cd531230b55d1828fd14ed0f9ba8cd9269a7ee322  3/3_part_77.bin
</code></pre>
<p>The first one has the height 772553 and the second 772776.
Is this normal?</p>

CC BY-SA 4.0
2024-09-29T12:06:51.947Z
This question is similar to: [How does the bitcoin network recover in case of a hash collision in the block hash?](https://bitcoin.stackexchange.com/questions/38384/how-does-the-bitcoin-network-recover-in-case-of-a-hash-collision-in-the-block-ha). If you believe it’s different, please [edit] the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.
RedGrittyBrick
CC BY-SA 4.0
2024-09-29T14:28:08.263Z
Quite similar but not identical. That question is referring the case where by chance a block will hash identical to a previous hash, meaning its transactions and all will differ.
Also the answer is saying that eventually that block will be ignored and marked as obsolete eventually. In my chain, the duplicated first block is dated "Wednesday, January 18, 2023 12:55:42 PM" which is some time ago...
In my chain I have 187 duplicate blocks, not by the hashes, but everything inside them are identical.
Mihai Popescu
<blockchain><block>
Duplicate blocks in Bitcoin blockchain
Mihai Popescu
# Duplicate blocks in Bitcoin blockchain

(Asked by: username_0 on 2024-09-29)

I created a parser and split the entire chain into pieces.

When inserting them into a database, to my surprise there were 187 blocks with the same hashes, so initially I thought there was something wrong with what I was doing, but after debugging, I found duplicates inside the blockchain.

I only investigated one block with the hash: 00000000000000000002927103A1BC8426DEFE05CFFA40BE468072B984C8876B.

I found the same block in two different .dat files: blk03361.dat, blk03363.dat.
I know for sure that the two blocks are identical because I split both dat files into blocks and compared the hashes:

```
sha256sum 1/1_part_65.bin
d81340e3e1c1759e4b78dc1cd531230b55d1828fd14ed0f9ba8cd9269a7ee322  1/1_part_65.bin
sha256sum 3/3_part_77.bin
d81340e3e1c1759e4b78dc1cd531230b55d1828fd14ed0f9ba8cd9269a7ee322  3/3_part_77.bin

```

The first one has the height 772553 and the second 772776.
Is this normal?

**Tags:** blockchain, block

> **Comments:**
> **username_1**: This question is similar to: [How does the bitcoin network recover in case of a hash collision in the block hash?](https://bitcoin.stackexchange.com/questions/38384/how-does-the-bitcoin-network-recover-in-case-of-a-hash-collision-in-the-block-ha). If you believe it’s different, please [edit] the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.  
> **username_0**: Quite similar but not identical. That question is referring the case where by chance a block will hash identical to a previous hash, meaning its transactions and all will differ. Also the answer is saying that eventually that block will be ignored and marked as obsolete eventually. In my chain, the duplicated first block is dated "Wednesday, January 18, 2023 12:55:42 PM" which is some time ago... In my chain I have 187 duplicate blocks, not by the hashes, but everything inside them are identical.  

---

## 1 answers

### Answer by username_2 on 2024-09-29. Score: 5 | Accepted answer

It is perfectly possible that the same block is stored twice in the Bitcoin Core blk\*.dat files.; there is no guarantee that the files contain the blocks in sequential order, or continuously, and unused space may exist in them which contain (parts of) blocks as well, from the active chain or stale blocks.

Bitcoin Core maintains an index of where which block is to be found on disk. If you parse things yourself, you will need to figure out the relation between all the blocks you find, and determine which ones are valid. Since every block contains a hash of its parent, if you see the same block data twice, it is necessarily the same block, at the same height.

> **Comments:**
> **username_0**: Short question: Does that space ever get cleaned up?  
> **username_2**: No, similar to how stale blocks never get cleaned up. If the few % extra space that these together may cause is an issue, you almost certainly just want to enable pruning, which deletes all block data after some time, stale or not.  

---

