use state cache to optimise historical state lookup (#4228)

## Issue Addressed

#3873

## Proposed Changes

add a cache to optimise historical state lookup.

## Additional Info

N/A


Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
int88
2023-05-05 00:51:57 +00:00
parent 45835f6a6b
commit 6d8d212da8
8 changed files with 90 additions and 8 deletions

View File

@@ -58,6 +58,16 @@ the `--slots-per-restore-point` flag:
lighthouse beacon_node --slots-per-restore-point 32
```
### Historic state cache
Lighthouse includes a cache to avoid repeatedly replaying blocks when loading historic states. Lighthouse will cache a limited number of reconstructed states and will re-use them when serving requests for subsequent states at higher slots. This greatly reduces the cost of requesting several states in order, and we recommend that applications like block explorers take advantage of this cache.
The historical state cache size can be specified with the flag `--historic-state-cache-size` (default value is 1):
```bash
lighthouse beacon_node --historic-state-cache-size 4
```
## Glossary
* _Freezer DB_: part of the database storing finalized states. States are stored in a sparser