Properly handle deep reorgs in engine experimental #10398
Labels
C-enhancement
New feature or request
S-needs-triage
This issue needs to be labelled
S-stale
This issue/PR is stale and will close with no further activity
Describe the feature
In the new version of the engine developed here #8742 we remove disk writes from the hot path by adding an in-memory data structure that keeps track of the most recent blocks. We need to give this data structure a concrete size to balance the increase in performance by keeping this part of the state in memory with the amount of memory required to do so. At some point, the engine will flush to disk the in-memory state persisting it in static files.
When a reorg happens, it is usually handled very efficiently in the in-memory part of the state. The problem arises when the depth of the reorg exceeds the size of the in-memory data structure, we are returning an error but instead, we should properly handle it and update the in-memory and on-disk parts of the state accordingly.
This is also problematic just by creating a fork starting on a block not present in memory.
This issue has been brought up by executing hive tests against a reth instance with enabled
--engine.experimental
flag. By default, the number of blocks kept in memory by the engine is 2 and the tests that are failing are exercising reorgs of depth 9 or 10, for instanceInvalid Missing Ancestor ReOrg, StateRoot, EmptyTxs=False, Invalid P9 (Cancun) (reth)
defined here https://github.com/ethereum/hive/blob/f47eebb89be85cee2c9d3fd2d0afbe209ad3e77e/simulators/ethereum/engine/suites/engine/invalid_ancestor.goAdditional context
No response
The text was updated successfully, but these errors were encountered: