-
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
Fetching events from blocks previous than the runtime upgrade Kusama/9320 is broken #725
Comments
Hi, The decoding error from your example is coming from the The metadata changed between the block number Running the example with trace logs enabled:
The old metadata contains:
While the latest metadata:
Adding some debug logs the decoding error originates from:
subxt/subxt/src/events/events_type.rs Lines 191 to 200 in 15ffbb6
|
From the event documentation, the events at older blocked are not entirely supported subxt/subxt/src/events/events_client.rs Lines 43 to 48 in 15ffbb6
To unblock this, have created patch #727 to sync the metadata with the given block hash. With the prior patch the dynamic events are properly decoded and can be inspected as: for event in events.iter() {
let event = event?;
println!(
"pallet_name: {} variant_name: {}",
event.pallet_name(),
event.variant_name()
); However you will have to make sense of the Let us know if we could offer further help here. |
@lexnv many thanks for the help, the patch is working great! |
One reason I've been pretty hesitant about introducing this sort of change (and instead just warning users) is that we don't have a sane way (afaik) to find out which metadata version would apply for some range of blocks and download it. Instead, we have to do what the linked PR does and download metadata doe every single block requested, when an explicit hash is given, just incase it is different. This of course causes a huge amount of extra overhead. I'd rather that for now, we think of a way to help facilitate this use case without adding that sort of overhead per block fetched. This might simply mean that, to do this sort of thing, you have to manually obtain older metadata and pass it in to the events stuff or something, and perhaps we need to tweak some APIs to make that possible :)
And this sort of limitation is the sort of thing that shouldn't exist in a public API that we provide either, I reckon. So let's make it possible but not necessarily "easy" to do this (to avoid making such tradeoffs in the "common path") |
Sorry, but actually when tested earlier all blocks before the runtime upgrade are fetched correctly but it still fails on the block 15426015 which is the one that contains the Democracy::PreimageUsed event and not Democracy::Seconded as per subscan. current error at block 15426015:
example:
|
That behavior is strange indeed. I believe for that exact block let block_hash_md = api.rpc().block_hash(Some((block_number - 1).into())).await?.expect("valid num; qed");
let metadata = api.rpc().metadata(Some(block_hash_md)).await?
let events = Events::new_from_client(metadata, block_hash, api.clone()).await?; The previous example is updated to reflect the changes in #727. |
That's great! Thanks again for the quick support. For me this new API works well, it will be nice to leave it available in future subxt releases. output:
example:
|
I was clearly looking into a different block in my previous comment. The exception seems to be only with block 15426015 where events are only decoded correctly if metadata is previously fetched from the previous block, i'll creation an exception for this case in my end. Thank you |
Glad to hear that solves your problem! Let us know if there is anything else we could help with! |
After the last runtime upgrade on Kusama/9320 is no longer possible to fetch events from blocks before the runtime upgrade.
When fetching for the events at block 15426015 where the runtime upgrade was enacted we get the following error:
For any block number smaller than 15426015 we get the following error:
Below is just the example to demonstrate the error when fetching a block:
Output:
Is there a workaround for this? Or do you think this could be fixed within subxt?
Thank you
The text was updated successfully, but these errors were encountered: