fix: database prepare on startup #341
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
We run into an issue in which, on startup, we do not correctly clear batches and set the starting L2 safe block. This edge case occurs when multiple batches are present in the same L1 block. This led to an invalid reorg.
Previously, we would only clear the latest batch, but when we resync the L1 and process the L1 block, it would trigger an L1 consolidation of all batches contained in the L1 block instead of just the latest, which was deleted. As such, we now delete all batches included in the L1 block on startup.