-
Notifications
You must be signed in to change notification settings - Fork 3
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
Change the chainHead
functions to have proper limits
#66
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactor on my end is going to be quite significant 😅 . However, I'm convinced that this is a much better approach. Thanks @tomaka !
@@ -8,28 +8,3 @@ Any missing parameter, or parameter with an invalid format, should result in a J | |||
|
|||
- "hexadecimal-encoded" designates a binary value encoded as hexadecimal. The value must either be empty, or start with `"0x"` and contain an even number of characters. | |||
- "SCALE-encoded" designates a value encoded using [the SCALE codec](https://docs.substrate.io/v3/advanced/scale-codec/). | |||
|
|||
## The `networkConfig` parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! With this, we'd simplify code from substrate's point of view! 👍
I've resolved the big conversation and pushed a bunch of commits for the second attempt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @tomaka !
src/api/chainHead_unstable_follow.md
Outdated
|
||
```json | ||
{ | ||
"event": "done", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should the event here be operation-body-done
to keep in sync with the explination from below and with "event": "operation-storage-items"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Thanks @tomaka! 👍
Generally looks good to me, and I appreciate the compromise on subscription bits which will give us time to re-think the JSON-RPC bits without blocking this stuff being implemented :) Just a couple of things I spotted:
|
The plan right now is work on and stabilize The
For this reason I'm leaving it lagging behind a bit right now.
This is something I've realized and I don't think it changes anything. From the point of view of the JSON-RPC client, at any point in time a body/call/storage request can return From the point of view of a light client server, the way it's implemented right now is: when body/call/storage is called, all the information necessary for the request is copied from the block and put in some local variables. Thanks to this, the request can continue even if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that all makes sense to me; happy to see this merge!
I just want to double-check my understanding here. In the event that the For the sake of clarity, it would be beneficial if the spec explicitly states this. It should either confirm that all operations will ultimately be either fulfilled or errored, or conversely, state that some operations may potentially be left "in limbo". If I were to express my preference, I'd ideally like the spec to rule out the possibility of operations being left "in limbo" 😅. EDIT:Upon further reflection, I'm considering whether it might be more logical in the event of a EDIT 2:I just noticed that in fact the spec is very clear about this:
This effectively means that all ongoing operations are being disjoined, right? |
Yes |
Close #58
Close #23
Close #22
Close #63
See discussion in #58
The list of changes are:
chainHead_storage
,chainHead_body
, andchainHead_call
are no longer subscriptions but simple request-responses.chainHead_storage
,chainHead_body
, andchainHead_call
now return a JSON object rather than just asubscriptionId
. This JSON object indicates whether the operation could be successfully started.chainHead_storage
,chainHead_body
andchainHead_call
are now generated by thechainHead_follow
instead, and now have anoperation-
prefix.chainHead_storageContinue
has been renamed tochainHead_continue
and must now be passed afollowSubscriptionId
.chainHead_stopBody
,chainHead_stopStorage
andchainHead_stopCall
have been merged intochainHead_stopOperation
and must now be passed afollowSubscriptionId
.chainHead_storage
, when a subscription successfully starts, is also indicated the number of items that were ignored. Note that it is possible for all items to be discarded, in which case the subscription will just end with"event": "done"
right after.networkConfig
from everywhere. This turned out to be too difficult to implement for the server when it needs to manage its own resources.disjoint
events fromchainHead_storage
,chainHead_body
, andchainHead_call
, and replace them with alimitReached
return value. Even though this situation is more appropriate as a return value, it was previously an event in order to make the API easier to use. Since we're switching to returning an object instead of just asubscriptionId
, might as well handledisjoint
the proper way as well.chainHead_follow
might now return a JSON-RPC error if there are already more than 2 active subscriptions.chainHead_storage
, it is no longer forbidden to generate anerror
event after someitems
notifications have been generated.Note that
error
is still events rather than a return value. In the case ofchainHead_unstable_call
, a light client must first download a bunch of stuff, and then only later anerror
might happen, and thus it is more appropriate as an event.In the case of
chainHead_unstable_storage
, theerror
could be a return value, but I kept it as an event for consistency.Remarks for JSON-RPC client developers
When it comes to
chainHead_follow
, there is a minimum of two activechainHead_follow
subscriptions per client. This means that you normally don't need to handle a situation where a JSON-RPC error is returned.When it comes to storage requests, body requests, and call requests, the requests to start should be treated as if they were a queue. If
limitReached
is returned ordiscardedItems
is non-zero, just pause the queue. If the queue is too large, you must either discard unnecessary entries or show error messages to the user. Maybe do read about queue theory on the Internet to understand what this is about.