Draft
Conversation
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
|
The CI pipeline was cancelled due to failure one of the required jobs. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Port of paritytech/substrate#14747
This MR implements
StorageListandStoragePagedNMap. Only the latter contains code, the former is an adapter type of it. Alike it should be possible to use it asStoragePagedDoubleMapandStoragePagedMap. All variants are counted, so the Counted prefix is omitted.API
The core API of a
StoragePagedNMapis given by the traitStorageKeyedList<K, V>and very similar to a paged list - just with an additional key argument.It does currently not support partial key iterations, but i think it should be possible to add it.
Storage Layout
The
StoragePagedNMapaccepts a tuple of key generators in its type signature and a tuple of matching keys in every of its functions. TheKeyGeneratorthen allows to encode that tuple of keys to a proper storage key. We use this here, denoted asKEY. Note that since aStoragePagedListis just a special instance of a NMap, theKEYcan be constructed by passing()into theKeyGenerator.The
Metadatais located attwox128(PALLET_PREFIX) ++ twox128(STORAGE_PREFIX) ++ KEY ++ "meta".Each page with index
INDEXis located at:twox128(PALLET_PREFIX) ++ twox128(STORAGE_PREFIX) ++ KEY ++ "page" ++ INDEX.It looks a bit like this, because a "Paged NMap" basically maps a key to a "Paged List":
Metadata
The metadata of a
StoragePagedList<Value>is currently set to the metadata of aStorageMap<u32, Vec<Value>>. This is correct on the storage level, since it maps the page-index (u32) to a page (Vec<Value>). But when reading the page, it is unclear to the reader what offset to use within the page to avoid reading removed values.FRAME metadata V17 would be needed to fix this properly so that the reader is aware of the metadata field in storage.