## Why do two different fully synced Bitcoin Core nodes differ in the blockchain size?

4

The size_on_disk printed when executing getblockchaininfo is 1.2 GB smaller than other nodes are reporting at the same time/block.

txindex=1

What could it be?? I've asked to other peers on twitter to check if anyone else experiencing the same and everyone has more data in their ledger than me. (https://twitter.com/bitdov/status/1231915231368163328)

Here's all the info printed with getblockchaininfo on my node:

{
"chain": "main",
"blocks": 618824,
"bestblockhash": "0000000000000000000a1fb0ec42e380215bb58698a1321d2953ee5d1b7b                                                                                                                                                  685d",
"difficulty": 15546745765529.37,
"mediantime": 1582569829,
"verificationprogress": 0.9999950821417113,
"chainwork": "00000000000000000000000000000000000000000cfea65b1b3c9262e87778b8                                                                                                                                                  ",
"size_on_disk": 299006763199,
"pruned": false,
"softforks": {
"bip34": {
"type": "buried",
"active": true,
"height": 227931
},
"bip66": {
"type": "buried",
"active": true,
"height": 363725
},
"bip65": {
"type": "buried",
"active": true,
"height": 388381
},
"csv": {
"type": "buried",
"active": true,
"height": 419328
},
"segwit": {
"type": "buried",
"active": true,
"height": 481824
}
},
"warnings": ""
}


Running Satoshi 0.19.0.1 protocolversion 70015 – bitdov – 2020-02-24T19:30:16.717

4

The difference in size is due to the number of stale blocks that your node stores. Stale blocks are blocks that once formed the part of the main chain but is not belong to the main chain now.

For example, if say two blocks are mined at height 102 at the same time. When the miner relays the block through the gossip network, the network that is closer to miner 1 will receive its block (102a) first as compared to block mined by miner 2 (102b). Bitcoin core adds the first received valid block to the tip of the chain. The blocks received at the same height after that are not deleted but kept in the database just in case a reorganization happens. So, if the next block 103 is mined on top of block 102b then the node that received 102a first will reorganize its chain to one that contains 102b as shown below.

101 -->102a
\
\
102b --> 103 -->104


Bitcoin Core does not delete any valid block that it receives from its peers. It is stored in your database forever in the file blocks/blk****.dat (which is also same for blocks in the main chain). However, the software does not relay stale blocks. In order to receive stale blocks, you need to be online at the time when your peer broadcasted a block to you from different chain view. Peers will only broadcast those blocks that they view form the current active chain from their perspective. So you will only have the stale blocks that you received when you were online. This also mean you will need to be connected to peers that view one the tip of the chain that is different from other peers. Due to this variability, many nodes will have different view of the sizes of the Bitcoin blockchain

Thanks for the detailed explanation. To sum up, it would be correct to assume that the longer I'm online, the closest I'm to miners, and the better my connectivity with other peers - the more stale blocks I will be storing and the higher my size_on_disk will be? – bitdov – 2020-02-25T07:32:32.110

1@bitdov yes, that would be a correct way to think of it. More your connectivity the higher the stale blocks you will receive. – Ugam Kamat – 2020-02-25T07:38:49.587

4

The size of the blockchain on disk can vary depending on how many stale blocks your node has seen. Stale blocks are not part of the main chain, but they are still stored on disk by your node. A new node will have fewer stale blocks than an old, long running, node. Well connected nodes are more likely to see stale blocks than less well connected nodes. So it is possible that your node simply has not seen as many stale blocks as other people's nodes.

Thanks, that makes sense, since my node is probably a very peripheral one and also this specific instance has only been running for around 3 months – bitdov – 2020-02-25T07:26:35.280