make service use both finalized and non-finalized state #1239
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
The implementation of the state service was not updated fully when we added the NonFinalizedState component. Most of the requests still exclusively queried the FinalizedState. This caused bugs with syncing where block locators would not include the most recent blocks in the current best chain because they're only stored in the non-finalized state, which was being ignored.
Solution
This PR adds all the functions previously only exported on
FinalizedState
to theService
andNonFinalizedState
components. It then implements each of the Service methods as first attempting to retrieve a piece of information from the memory state, if it exists, and if it doesn't falling back to the FinalizedState.This PR also fixes some inconsistency issues with how we were doing error handling for
sled
errors anddeserialization
errors when reading from sled. All of these errors are indicative of bugs, and removing them greatly simplifies the composition of the sled and mem lookup calls.The code in this pull request has:
Review
Related Issues
Follow Up Work