4

I am running a full geth node and was interested in the blockchain size.

Therefore, I compared the sum of all blocks' sizes with the actual disk size the blockchain copy consumes.

While the chaindata folder is 136 GiB large, the sum over all block sizes is just under 5 GiB. Where does this difference come from?

Obtaining Disk Size

$ du -hs geth/chaindata/
136G    geth/chaindata/

Obtaining Block Sizes

Here, I use the JSON-RPC interface and query each block (eth_getBlockByHash), going backwards from the best block I know (using the eth_getBlockByNumber API call).

From each block, I get the size value (which is in bytes according to the wiki). However, the sum of all size attributes is only roughly 4.76 GiB.

What am I missing here?

(I know I could just fetch each block by its number, but this is irrelevant for the question.)

2 Answers 2

3

The difference you're seeing is due to the state data, which is stored separately to the block data.

The blocks themselves are composed of a header, a list of the contained transactions, and a list of ommers. This is the block data. This accounts for your ~5GB value.

All other data - e.g. account data, such as contract code, balances, nonces, together with other data, such as logs and receipts - is considered state data, and not kept in the blocks themselves. (It is still downloaded by all "full" nodes.) This accounts for the remaining ~130GB you're seeing.

For further details on this, see the following:

Where is the state data stored?

Also perhaps of use is the below picture, from the following previous thread:

Ethereum block architecture

The block itself is shown on the right, with the header containing values derived from the state data, which is shown in the big square box in the middle.

enter image description here

Note:

I got a similar figure of ~5GB by downloading a CSV of the average block sizes from Etherscan, and extrapolating for the number of blocks per day given an average block time: https://etherscan.io/chart/blocksize

2
1

Are you on a Mac? It's my experience that 'du' on Mac will report significantly larger disc usage than you would get by adding up file sizes in bytes. Search Google. You'll see.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.