Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Allow for childstate queries for multiple child keys #9203

Closed
jacogr opened this issue Jun 25, 2021 · 1 comment · Fixed by #9459
Closed

Allow for childstate queries for multiple child keys #9203

jacogr opened this issue Jun 25, 2021 · 1 comment · Fixed by #9459
Labels
J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

Comments

@jacogr
Copy link
Contributor

jacogr commented Jun 25, 2021

Current we have childstate queries for single keys,

getStorage(
  childKey: PrefixedStorageKey,
  key: StorageKey,
  at: Option<Hash>
): Option<StorageData>

This approach work quite well. However in places where we do use childstate (e.g. crowdloans) we actually want to get multiple entries. For instance, I have 4 accounts for contributed to a specific crowdloan and to retrieve the values need to do 4 individual requests. This is in the cases where I know that the specific accounts have contributed.

Now look at the case where I may want to check if some of my accounts contributed to a specific loan. To do this would need to make X indv. RPC calls (where X = number of available accounts). For an RPC-user perspective and from an Node overhead perspective, it would potentially be much more optimal to have a signature such as -

/// getStorages? getEntries? Not sure about the naming...
getEntries(
  childKey: PrefixedStorageKey,
  keys: Vec<StorageKey>,
  at: Option<Hash>
): Vec<Option<StorageData>>

Which would allow us to query a specific childtrie to retrieve the values for more than one key in a single request.

@bkchr bkchr added J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. labels Jun 28, 2021
@hirschenberger
Copy link
Contributor

On which level needs this to be implemented? Is it enough to just call the client's child_storage function for each key, collect the data and return it or is there also a new Trie-Backend function required which is probably more efficient by reducing database operations?

hirschenberger added a commit to hirschenberger/substrate that referenced this issue Jul 29, 2021
@ghost ghost closed this as completed in #9459 Sep 13, 2021
ghost pushed a commit that referenced this issue Sep 13, 2021
* Add storage query functions for multiple keys

fixes #9203

* Query all keys in one request and add more tests

* Make it compatible with stable release channel

* Update to new futures

* Update client/rpc/src/state/state_full.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/rpc/src/state/state_full.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/rpc/src/state/state_full.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/rpc/src/state/state_full.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/rpc/src/state/state_full.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/rpc/src/state/state_light.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/rpc/src/state/state_light.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Satisfy borrowck

* Remove non-RPC `storage_entries` functions.

* Revert "Remove non-RPC `storage_entries` functions."

This reverts commit d840015.

* Revert "Revert "Remove non-RPC `storage_entries` functions.""

This reverts commit 5813b43.

* Finally some formatting

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants