Consensys / teku

Open-source Ethereum consensus client written in Java
https://consensys.io/teku
Apache License 2.0
669 stars 283 forks source link

Improve block pre-state caching #5244

Open ajsutton opened 2 years ago

ajsutton commented 2 years ago

Description

Currently we cache the pre-state for blocks as a checkpoint state which means the states are held for longer than they are actually useful and compete for space with the states used for validating attestations.

We do want to ensure we continue precaching the epoch transition and could benefit from pre-computing and caching the slot transition for all blocks. However, we only need to maintain a relatively small number of these cached states to facilitate validating and importing newly received blocks. Once they are more than a couple of slots old they are unlikely to be required again.

We need to avoid applying too many empty slots in this cache and definitely don't do this preparation while syncing.

Given slot processing is quite fast so long as an epoch transition isn't required, it may be worth investigating dropping checkpoint states from the cache that are:

There may be better approaches - need to test in multiple scenarios, including long periods of non-finalization with multiple branches.

rolfyone commented 10 months ago

I haven't chased down exactly where this is, but it's something we should look at. I believe this is distinct from the caching work I did previously.