What is `--gcmode=archive` in geth
1
I have been running a geth node, mostly to see event logs fired by my contracts. I ran the node with syncmode=fast and finally the node is synced. I can successfully read the logs.
Now, I read here the option --gcmode=archive described as:
Trie pruning is enabled on all --syncmode variations (including --syncmode=full). If you are running an archive node where you would like to retain all historical data, you should disable pruning via --gcmode=archive.
What does the historical data mean here? Is it more than the normal logs that are created by events fired during transactions? What does it include and when should I use --gcmode=archive?
Archive mode means that all states of values in smart contracts as well as all balances of an account are stored.
e.g. if the value of a string in a contract changes from XYZ in block 6000000 to ABC in 6000001, you can recall that string's state from block 6000000 with web3.eth.call, providing the blocknumber (as hex value with 0x prefix) as one of the function parameters of this web3 function. This is only possible in archive sync, other syncmodes which prune the past states will have only the latest value available, to be called with the above mentioned function providing "latest" as the blocknumber parameter.
As far as I know, Parity even offers a sync mode where only a defined amount of past states are logged, limiting the size of the synced chain data.
本文探讨了在Geth中使用--gcmode=archive选项的意义,解释了归档模式如何保存智能合约的所有状态变化及账户余额历史,对比了其他同步模式下状态修剪的限制。归档模式确保了所有历史数据的保留,允许用户通过提供特定区块号调用web3.eth.call来访问过去的状态。

358

被折叠的 条评论
为什么被折叠?



