-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
state_getKeysPaged
times out (with small pages)
#692
Comments
What do you mean by "timed out"? Is it a timeout enforced by PolkadotJS? This RPC call is implemented by downloading every single key of the prefix then keeping only the appropriate count and the ones that follow the start key. |
Nope. I'm not using PolkadotJS, please have a look at the demo that I've provided. The response that I get from smoldot for the problematic request is: {
"jsonrpc":"2.0",
"id":"thisOneFails",
"error":{"code":-32000,"message":"Storage query errors:\n- Timeout\n- Timeout"}
}
🤔 then I don't quite understand why that request is failing, since that request is only asking for the first 2 keys... I found this on the docs section of the metadata entry of The map from nominator stash key to their nomination preferences, namely the validators that
they wish to support.
Note that the keys of this storage map might become non-decodable in case the
[`Config::MaxNominations`] configuration is decreased. In this rare case, these nominators
are still existent in storage, their key is correct and retrievable (i.e. `contains_key`
indicates that they exist), but their value cannot be decoded. Therefore, the non-decodable
nominators will effectively not-exist, until they re-submit their preferences such that it
is within the bounds of the newly set `Config::MaxNominations`.
This implies that `::iter_keys().count()` and `::iter().count()` might return different
values for this map. Moreover, the main `::count()` is aligned with the former, namely the
number of keys that exist.
Lastly, if any of the nominators become non-decodable, they can be chilled immediately via
[`Call::chill_other`] dispatchable by anyone.
TWOX-NOTE: SAFE since `AccountId` is a secure hash.
That would be amazing! Because having the ability of iterating over the Staking.Nominators entries (even if had to be done very slowly) is quite a critical functionality for some dApss 🙏 Thanks @tomaka ! |
The time out is probably caused by the fact that the response is too large. This would be solved by finishing the transition to |
Sorry, but I'm not following, could you please elaborate on this? 🙏
🤔 how could that be done from the side of the consumer? The demo that I provided is only requesting for 2 keys... |
These are just notes for myself, not addressed to you as reporter of the issue. |
FWIW querying the values of this exact same storage key with the new JSON-RPC API seems to work perfectly fine. |
I take this back... 😞 I mistakenly tried it against the Trying a I get that fixing this could be pretty challenging, and I don’t want to be that person, but this issue is kinda holding up a demo I’m working on. If it's a big pain to sort out, I can shift the demo around a bit. Any chance you could let me know if this is fixable, and what the timeline might look like? Thanks a ton! 🙏 |
Unfortunately v2.0.4 does not only not fix this issue, but it also breaks some storage requests that were previously working. Basically, what I'm experiencing is: I receive an |
2.0.5 fixed the issue introduced by 2.0.4. Unfortunately, though, with 2.0.5 I still get the |
Please provide some |
here you go: |
Is this all? I don't see any event being sent back regarding the |
The last log:
is the |
Here, I enhanced the smoldot logs with my own logs. I hope that helps EDIT: I just updated the logs with a small improvement. |
Ah right I forgot that the storage events were now reported as |
Unfortunately I can't figure out the problem from these logs, it seems to actually not be related to what I've been saying earlier and might be caused by for example a failure to decode the networking response or something like that. |
Note for self: here's the small demo tweak I use to test this: defaultChain.then(async (chain) => {
chain.sendJsonRpc('{"jsonrpc":"2.0","id":1,"method":"chainHead_unstable_follow","params":[true]}');
const subId = JSON.parse(await chain.nextJsonRpcResponse()).result;
const finHash = JSON.parse(await chain.nextJsonRpcResponse()).params.result.finalizedBlockHash;
chain.sendJsonRpc('{"jsonrpc":"2.0","id":2,"method":"chainHead_unstable_storage","params":["1","' + finHash + '",[{"key":"0x5f3e4907f716ac89b6347d15ececedca9c6a637f62ae2af1c7e31eed7e96be04","type":"descendantsValues"}],null]}');
while (true) {
const resp = JSON.parse(await chain.nextJsonRpcResponse());
if (resp.params && resp.params.result.event.startsWith('operation'))
console.log(resp);
}
}); It might become useful later. |
It seems that 2.0.6 fixes this issue 🎉 Should I close this @tomaka ? |
In some instances the
state_getKeysPaged
RPC call times out, even when requesting very small items.For instance, when trying to retrieve the keys of the storage entry
Staking.Nominators
, the following request:always fails.
However, the equivalent request for the
Staking.Validators
entry:works perfectly fine.
Here you can find a demonstration of this issue
The text was updated successfully, but these errors were encountered: