You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current key scraping implementation is is quite inefficient, fetching 1k keys at a time, waiting for each batch of 1k keys to be returned before asking for the next one
This is not so bad when fetching keys from a local node where latency is not a big factor, but can slow things down very significantly when using a remote node when most of the time spend fetching keys becomes latency rather than the node doing work.
Unfortunately, most nodes seem to have a hard limit imposed preventing more than 1k keys being fetched in a single request.
Original issue paritytech/polkadot-sdk#174
Motivation
The current key scraping implementation is is quite inefficient, fetching 1k keys at a time, waiting for each batch of 1k keys to be returned before asking for the next one
https://github.com/paritytech/substrate/blob/master/utils/frame/remote-externalities/src/lib.rs#L348-L392
This is not so bad when fetching keys from a local node where latency is not a big factor, but can slow things down very significantly when using a remote node when most of the time spend fetching keys becomes latency rather than the node doing work.
Unfortunately, most nodes seem to have a hard limit imposed preventing more than 1k keys being fetched in a single request.
Suggested solution
Rather than fetching all keys for the
prefix
in a singlerpc_get_keys_paged
request here https://github.com/paritytech/substrate/blob/master/utils/frame/remote-externalities/src/lib.rs#L528-L533, split theprefix
up into N parts and run therpc_get_keys_paged
tasks in parallel using async/await.e.g. two parallel tasks:
start_keys: 0x000000 end_keys: 0x777777
start_keys: 0x777777 end_keys: 0xffffff
Bonus (probably for a seperate issue/PR once this one is closed)
Fetch storage values for keys as they're pulled from the node, instead of waiting for all keys to be pulled before fetching values.
The text was updated successfully, but these errors were encountered: