-
Notifications
You must be signed in to change notification settings - Fork 262
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
Allow online client to initialise at a particular block height #793
Comments
I ultimately agree that we should at least make it possible to initialise an older client to help with decoding older blocks etc, though we also need to be careful to make clear the potential gotchas:
I opened #794 as a suggestion for the APIs that we could add here (with appropriate warnings on each of them); lemme know what you think! |
I'm not sure what you really mean here, but I'd be curious to see what you think to my PR suggestion :) The way I see it is if you can instantiate an |
Agreed, thanks for writing those up.
Yeah so this is what I want to avoid. Currently the only way to get an What makes it nicer to allow for updating in-place rather than creating a new client, is that you don't need any of the client initialisers again, and you don't need to track what block number/hash you're on. By forcing the creation of a new |
Related to the above, creating a new |
Not sure if github buggy or you deleted your comment (because I can no longer see it):
I agree with this approach, just thought I was more likely to get buy in by using the updater approach haha. Updating directly with a set that then writes through the RwLock would be ideal 👌 |
Oh whoops! Yup so I pushed an update to my PR to expose As a tradeoff though, I've removed most of the |
It's not necessarily always the case that we only want to query things from the point after the latest runtime upgrade.
One use-case would be to scan all blocks from a particular block height until the latest. Let's take events in particular.
Currently the way to do this would be to use something like: #727 and pass in the metadata to the events query. In order to use this to scan from a particular block, you would probably wrap the
OnlineClient
and store the metadata alongside it, updating it when you hit a runtime upgrade boundary.However, this design is a little clunkier than it needs to be. For one, we're already storing metadata in the OnlineClient. Metadata we aren't using because we're behind in block number. And in the case our scanning reaches the latest runtime, we are now duplicating storage of the metadata.
Instead of doing this, simply allowing the initiation of the online client from a particular provided block height, means we can use
apply_upgrade
on theClientRuntimeUpdater
to bump the runtime version only in one place (and no need to introduce external state in the wrapper). It would also be necessary to introduce some constructor forUpdate
,new_from_raw()
as the name perhaps, to allude to the fact it's a little less safe than using the subscription util, which will always pair theruntime_version
andmetadata
for you. See #789 for the beginning of that discussion.Code changes would be pretty simple. Just another method that can construct an
OnlineClient
that would wrapfrom_rpc_client
. Orrrr could just have the one method, that takes anOption<BlockHash>
(open to ideas here).I'd be happy to do this PR, once there's buy in.
The text was updated successfully, but these errors were encountered: