-
Notifications
You must be signed in to change notification settings - Fork 31
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
Refactor TokenNetwork events fetching #1822
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1822 +/- ##
==========================================
- Coverage 95.41% 95.28% -0.14%
==========================================
Files 153 153
Lines 5387 5426 +39
Branches 1039 1052 +13
==========================================
+ Hits 5140 5170 +30
- Misses 193 200 +7
- Partials 54 56 +2
Continue to review full report at Codecov.
|
Ok, testing this PR by hand, it definitely improved the situation by ensuring we're able to recover from lost events upon restarts, which is nice to have/keep, but not essential if we get the events fetching working properly, plus the good performance improvements. Unfortunately, while testing it, I've seen the event loss happening even on top of this PR. I've tested with a local ethereum node (geth.goerli.ethnodes...) and couldn't reproduce it there, only on Metamask + Infura. My best bet is that this is caused by how Fortunately, if the above is the case, there's a nice way to fix it: implement my own algorithm on top of ether's provider to register filters locally and, on new blocks, perform |
@andrevmatos How do we proceed with this PR, do we merge it and you do the new algorithm implemented in a new one? It would make sense for that to go to a new PR since this is already big. |
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.
Like I commented I would suggest merging that and implementing the new algorithm in a new PR.
Also, a question I have is, do we know if ethers event filters have improved in ethers v5?
Ok, I agree, let's merge this and do a follow-up PR with the additional fixes, they're complementary anyway. Thanks |
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.
Really good work! I think this has potential so solve many issues by their root cause. 👍
Oh my review took to long... 😂 |
Fix #1787
Fix #1780
Should fix #1792
Short description
Complete rewrite of TokenNetwork events monitoring logic.
This should not have drawbacks, and UX shouldn't be changed (besides things just working™)
Before:
tokenMonitoredEpic
was responsible for monitoring ChannelOpened events, was stateful on which blocks it had already seen and couldn't recover it network errors made it lose events (issue 1780 & 1787)channelMonitoredEpic
then, for each channel, did a getLogs call on every startup (narrowed by channelId) and kept 1 filterNow:
channelEventsEpic
: a single epic per TokenNetworkCosts per TokenNetwork monitored (N is number of channels):
Before:
(1 + N) * (getLogs, filters)
(plus first TN getLogs could be very expensive)Now:
2..3 * getLogs + 1 * filter
(all getLogs are as specific as possible)Definition of Done
Steps to manually test the change (dApp)