-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cnidarium: sound prefix queries on substores (#4653)
## Describe your changes This PR contains a minimal reproduction for a bug in cnidarium's prefix query handling. It also contains a sketch for a fix that we can workshop. The bug was introduced in the original substore implementation PR (#3131). ## Minimal reproduction of the prefix range cache bug. **Context** `cnidarium`, our storage layer, supports prefix storage. This allows users to configure independent storage units, each with their own merkle tree, nonverifiable sidecar, and separate namespace. Routing is done transparently without the user having to worry about the details. **Overview** Prefix queries return tuples of (key, value)s, but instead of returning the full key, they return the substore key. This is a layering violation, and indeed causes a bug in the cache interleaving logic. **Terminology** - a `full_key`: a key that contains a substore prefix, a delimiter, and a substore key. - a `substore_key`: a key with a stripped prefix. **Walkthrough** `StateDelta` index changes using full keys, as it is not aware of the particular substore configuration that it is working against, by design. As part of the cache interleaving logic, the `StateDetla` will try look for new writes or covering deletions. However, since the base prefix implementation returns substore keys, the cache will build an incoherence range and panic (or miss data). ## Checklist before requesting a review - [x] If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason: > Consensus breaking in the sense that the chain won't halt if we hit this.
- Loading branch information
Showing
3 changed files
with
134 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters