My understanding is that the archival node stores the state tree for each block -- that's the reason the size is so big. Can someone validate my understanding?
-
the state is unique for the entire blockchain, only modifications are stored on each block, but never the state is rewritten again with each block. (just to make it clear)– NulikFeb 13, 2018 at 22:05
-
yes there is no doubt that state is unique. but my understanding is , every block in archival node has a corresponding state trie which captures that state of blockchain at that point of time.– Manish RanjanFeb 14, 2018 at 1:27
2 Answers
The state of archival node (compared to Full node) is much bigger because every change to the State is kept in your disk. This way if you issue eth.getBalance(address)
you can call it with a block number as parameter, for example: eth.getBalance(address,block_number) and it will give you the balance of the account after all transactions for that block were executed. With Full node you can't do this. Full node only tracks 128 last states (in memory only, you can increase this constant modifying core/blockchain.go:TriesInMemory
constant) and you can only query the latest balance of an account.
Added to this, the state is so big (compared to other cryptocurrencies) because it stores contract data. Contract data is like a binary executable .exe in Windows, it contains instructions to be executed and this takes much bigger space than a signed transaction or an account record. All the invocations to contracts also kept with input
stored in tx.Data() field. The data of input for a contract will be much much bigger than its code, over time. The storage of the contract (all the variables it is storing internally) is also participating in the hashing algorithm of the merkle trie, so it is also kept in the State. Also, contracts are immutable , once you uploaded it , you can't modify it, so a new version of the executable must be fully uploaded if you have to apply some changes. This is the reason Ethereum's state is so big. It is like a hard disk where files are created but never deleted. In the future this is going to get worse.
Why would you need an archival node?
- You are a white hacker and you want to trace what happened quickly after the attack was discovered
- You have your front running robot and you need to test it with past data. (or any other development task which needs to run transaction on a State of a particular block)
- You are running an Explorer service, like Etherscan and you need to query older data.
Most people don't need archival nodes. However you can find articles in Medium stating that nobody runs archival nodes even the Ethereum Foundation doesn't have them. This is not true. Lots of people are running archival nodes. If nobody would be running archival nodes, you wouldn't be able to download block bodies, which contain all transaction data.
-
-
@porton I would say it rather incomplete, updated the answer, check it– NulikJan 16, 2021 at 23:57
-
"Contract data is like a binary executable .exe in Windows" is wrong. In fact, contract data is like the disk files created by a binary executable .exe in Windows.– portonJan 17, 2021 at 8:39
-
@porton everything is correct. what I mean by contract data is everything about smart contracts, i.e. the
code
+data
(input + storage) The word "data" in the first sentence is meant: contract as a concept, with all it contains– NulikJan 17, 2021 at 17:11 -
.exe
is code, not quitecode
+data
. Well,.exe
does contain data (as well as, for example, EVM contract contains constants), but that's not what you meant.– portonJan 18, 2021 at 6:08
Yes, you're correct. An Ethereum archival node is a geth full node. A full node will download/maintain block header + block data + perform full data validation. This process takes a more time and storage.
For more details, see the answer to this question: What is the parity light pruning mode?