Skip to content
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

fix: keep processing a block's events after encountering a dispatch error #310

Merged

Conversation

sander2
Copy link
Contributor

@sander2 sander2 commented Nov 4, 2021

When processing a block, the code immediately returned any encountered errors. Any events produced in the block after the error would be silently dropped. This pr changes the behavior: an error is now handled in the same way as events. That is, they are added to the VecDeque and are returned only when they get popped from there. This ensures that all events from the block are correctly processed

@sander2 sander2 force-pushed the fix/subscription-event-after-error branch from 4f690b7 to 56c82d0 Compare November 4, 2021 15:29
@h4x3rotab
Copy link
Contributor

I have the impression we have made some similar fix locally. In the original code, it recognizes an error produced by any extrinsic including the one we don't care and fails too early.

Copy link
Contributor

@ascjones ascjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

This seems to be another hangover from when this block of code was designed only to return the events triggered by a specific extrinsic, in which case it wouldn't have been a bug since it would have skipped over any events/errors which were not for that extrinsic.

We should consider adding some unit tests for this block of code since it is so critical and has had a few bugs in it. One way to do it would be to add a Mock variant to EventStorageSubscription.

@sander2
Copy link
Contributor Author

sander2 commented Nov 9, 2021

We have an integration test for this in our client code, but I wasn't able to replicate the test in the subxt repo - I didn't manage to create a single block with 1 failing and 1 succeeding tx. Fwiw, we've been using this patch locally for a long time, so it's been somewhat battle-tested already. I'll look into adding a unit test though

@sander2
Copy link
Contributor Author

sander2 commented Nov 10, 2021

@ascjones I added some unit tests. I had to refactor a little bit, because not only did I need to mock EventStorageSubscription, but also the event decoder.

I also added a modified version of #283 based on your comment, so that I could integrate the test for it right away. If you prefer separate prs, I'm happy to remove the last commit here.

@sander2 sander2 force-pushed the fix/subscription-event-after-error branch from 72078c6 to 902d94c Compare November 10, 2021 13:57
@ascjones
Copy link
Contributor

If you prefer separate prs, I'm happy to remove the last commit here.

Yes separate PR please

@sander2 sander2 force-pushed the fix/subscription-event-after-error branch from 902d94c to acb1a3f Compare November 11, 2021 17:16
@sander2
Copy link
Contributor Author

sander2 commented Nov 11, 2021

Yes separate PR please

Ok, updated. I'll update the other pr after this one is merged then.

Copy link
Contributor

@insipx insipx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ascjones ascjones merged commit 57ab87b into paritytech:master Nov 12, 2021
0623forbidden pushed a commit to DEIPworld/substrate-subxt that referenced this pull request Feb 15, 2022
…rror (paritytech#310)

* fix: keep processing a block's events after encountering a dispatch error

* test: unit test for subscription
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants