-
Notifications
You must be signed in to change notification settings - Fork 248
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
runtime upgrade stream API: fetched metadata is "outdated" when upgrade is applied #1319
Comments
It's possible to workaround this issue by using the upgrade low-level API, you can find an example here |
The chainHead APIs provide runtime updates in new block events, so with that API we should be able to be more precise about things. It's just the old APIs I'd guess that are a bit more problematic. In an ideal world, Subxt should probably store multiple metadatas/runtime infos for different blocks. If we store them at block heights, then we don't account for forks and so should only pay attention to updates at finalized blocks. For now though, the There will still be race conditions etc until we support multiple metadatas, because once we update to a newer metadata/runtime version we may fail to decode some older blocks all of a sudden. Also, working with blocks that haven't been finalized will always cause issues. Eventually, supporting multiple metadatas in Subxt will help to deal with this, so that then we can register the update against the exact block number and keep (some) older metadatas around to keep handling blocks before that. |
Yeah, I'm more in favor of removing the runtime update stream API completely and let the users decide how/when to upgrade the metadata because the current one will always lag behind what's on chain after at least one runtime upgrade has occurred. For instance in the staking-miner I decide to subscribe to |
Currently, I'm using the runtime update stream API in subxt as follows:
Thus, I'm expecting the metadata in the runtime upgrade to have been updated after
apply_update
returnsLogs from the code
After some investigation, I was able to track down that the issue is really that the fetched metadata in the runtime upgrade doesn't really contain the latest metadata. The reason is that
state_subscribeStorage
emits an runtime upgrade event before it's actually applied, and subxt's RuntimeUpgradeStream should really assert that the runtime upgrade has occurred at the block or earlier that the metadata is fetched at (with the exception for the initial runtime upgrade)With the following hack in subxt the issue goes away:
The text was updated successfully, but these errors were encountered: