chainHead/storage: Fix storage iteration using the query key (#1665)
This PR ensures that all storage keys under a prefix are returned by the
`chainHead_storage` method.
Before this PR, the `storage_keys` was used with just the `start_key`.
Before the pagination event was generated, the last reported key
`last_key` was saved internally.
When the pagination is resumed, the `last_key` will serve as the next
`start_key` to the `storage_keys` API.
However, this behavior does not function properly for non-prefixed
storage keys.
Entry keys `a`, `ab`, `abc` share a common prefix and therefore the `ab`
key leads to `abc`.
However, for `a`, `ab`, `aB` and `abc`, the `aB` key does not
immediately lead to `abc`.
To mitigate this, the PR saves the start key of the query, together with
the next pagination key.
Improve testing to ensure we have a key entry that doesn't share the
prefix with the descendant key.
@paritytech/subxt-team
---------
Signed-off-by: Alexandru Vasile <[email protected]>
Please register or sign in to comment