Full node sync only preserve the last 128 history states

2018-02-23 10:32:41

While researching on the different sync modes and their behaviors, I learned that geth full sync will replay all transactions from the genesis and preserve all history states, while fast sync will only download block data without statedb until around 100 blocks before the latest block head, and then perform as a full node.

I decided to verify these behaviors in this way:

I started a private network, and mined 2000 blocks with no transactions (but the balance of the miner should keep increasing because of the coinbase transactions).

Then I started other geth instances with different dirs and ports. Connected them to the private network node in full and fast sync.

Here's what I discovered:

In full sync geth instance, I'm able to query the state(by calling eth.getBalance(eth.accounts[0], )) only for the last 128 blocks.

In fast sync geth instance, I'm able to query the state only for the last 64 blocks.

In both cases, querying states from old