[website]: add info on `cache.preimages` to docs (#26436)

* + preimage to faq & note to GetModifiedAccount...

* Update docs/faq.md

* Apply suggestions from code review

Co-authored-by: Joseph Cook <33655003+jmcook1186@users.noreply.github.com>

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
This commit is contained in:
Joseph Cook 2023-01-05 13:45:45 +00:00 committed by GitHub
parent 6a45803ca8
commit b98a762cc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -95,3 +95,7 @@ These docs mainly cover how to set up Geth, but since the switch to proof-of-sta
## How do I update Geth? {#how-to-update-geth}
Updating Geth to the latest version simply requires stopping the node, downloading the latest release and restarting the node. Precisely how to download the latest software depends on the installation method - please refer to our [Installation pages](/docs/getting-started/installing-geth).
## What is a preimage?
Geth stores the Ethereum state in a [Patricia Merkle Trie](https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie/#state-trie). It contains `(key,value)` pairs with account addresses as keys and and [RLP](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/#top) encoded `account` as the value, where an account is an array containing essential account information, specifically: `nonce`, `balance`, `StorageRoot` and `codeHash`. Definitions for these parameters are available in the Ethereum whitepaper. However, Geth's state trie does not use the keys directly, instead account information is indexed using the SHA3 hash of the key. This means that looking up the account information for an address can be done by traversing the trie for `sha3(address)`, but querying addresses that contain certain data is not possible - the addresses themselves are not part of the trie. This problem is solved using preimages - these are mappings of addresses to their hashes. Geth generates these preimages during block-by-block sync as information is added to the trie but they are deleted once they reach a certain age (128 blocks by default). To retain the preimages, Geth should be started with `--cache.preimages=true`.

View File

@ -229,6 +229,8 @@ storage hash.
| Console | `debug.getModifiedAccountsByNumber(startNum uint64, endNum uint64)` |
| RPC | `{"method": "debug_getModifiedAccountsByNumber", "params": [startNum, endNum]}` |
<Note> Geth only keeps recent trie nodes and preimages of keys in memory - for older blocks this information is deleted by Geth's garbage collection. This means that calls to `debug_GetModifiedAccountsByNumber` on blocks that are old enough to be eligible for garbage collection will return an error due to the trie nodes and preimages being unavailable. To fix this, run Geth with `--cache.preimages=true` to prevent the relevant data being lost to the garbage collector </Note>
### debug_getRawReceipts
Returns the consensus-encoding of all receipts in a single block.