change(state): Check database format is valid on shutdown, to catch format errors in new block code #7606
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.
Motivation
We want to catch format errors in new block code. But currently that code is only tested when Zebra adds new blocks, then shuts down, then opens the same state. So PRs can merge with bugs in that code.
Instead, we check the format is valid before Zebra shuts down. This tells users early if they need to re-sync their state, rather than surprising them the next time they launch Zebra.
It also prevents us writing invalid cached states in CI.
Close #7570.
Complex Code or Requirements
I think a panic on shutdown should fail CI, but I haven't checked to make sure. Do you think it's worth doing that manually?
Solution
Related Refactors:
Review
This is optional for the release.
Reviewer Checklist
Follow Up Work
We could replace a whole lot of
config
arguments with the database and version paths, but that can happen later if needed. Storing anArc<Config>
isn't that expensive.