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

sdk: fix fromEthersEvent ranges fetching in case of temporary connectivity loss #1924

Merged
merged 1 commit into from
Jul 20, 2020

Conversation

andrevmatos
Copy link
Contributor

@andrevmatos andrevmatos commented Jul 19, 2020

Fixes #1923
Follow-up of #1832

Short description
This PR fixes the issue by using a fromBlock queue, instead of a single value, so we always keep track of "[range] successful requests in the past", and can proceed with the correct ranges even in case of connectivity loss or exceptions thrown.
Also, the queue is only walked over (i.e. popping the front we just queried, pushing to the back the new block for future range request) if the request didn't throw, allowing us to safely ignore any network error/exception thrown while scanning ranges and retrying the previous fromBlock when a new block event is emitted, which indicates connectivity was restored.

Definition of Done

  • Steps to manually test the change have been documented
  • Acceptance criteria are met
  • Change has been manually tested by the reviewer (dApp)

Steps to manually test the change (dApp)

  1. Disconnect the browser from internet while dApp is connected and monitoring some channel/tokenNetwork
  2. Do some transaction which would show up on an event (e.g. a deposit on partner)
  3. Wait more than 5 blocks after transaction, then connect back to internet
  4. See event got picked up properly, network failures didn't error/shutdown the SDK

@andrevmatos andrevmatos added sdk 🖥 optimization ⚡ Optimizations for the implementation or protocol security Pull requests that address a security vulnerability labels Jul 19, 2020
@andrevmatos andrevmatos self-assigned this Jul 19, 2020
@codecov
Copy link

codecov bot commented Jul 19, 2020

Codecov Report

Merging #1924 into master will decrease coverage by 0.13%.
The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1924      +/-   ##
==========================================
- Coverage   95.74%   95.61%   -0.14%     
==========================================
  Files         155      155              
  Lines        5809     5816       +7     
  Branches     1094     1095       +1     
==========================================
- Hits         5562     5561       -1     
- Misses        189      197       +8     
  Partials       58       58              
Flag Coverage Δ
#dapp 91.82% <ø> (ø)
#sdk 97.19% <93.75%> (-0.20%) ⬇️
#sdk_e2e 65.71% <93.75%> (+0.18%) ⬆️
#sdk_integration ?
#sdk_unit 86.37% <93.75%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
raiden-ts/src/utils/ethers.ts 97.53% <93.75%> (-1.12%) ⬇️
raiden-ts/src/polyfills.ts 71.42% <0.00%> (-28.58%) ⬇️
raiden-ts/src/raiden.ts 91.52% <0.00%> (-0.25%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51970e4...57f6d6b. Read the comment docs.

@andrevmatos andrevmatos force-pushed the fix/error_handle_fromEthersEvent branch from a50f22a to 68548b7 Compare July 19, 2020 19:33
@andrevmatos andrevmatos force-pushed the fix/error_handle_fromEthersEvent branch from 68548b7 to 57f6d6b Compare July 19, 2020 19:34
@andrevmatos andrevmatos removed the security Pull requests that address a security vulnerability label Jul 20, 2020
Copy link
Contributor

@weilbith weilbith left a comment

Choose a reason for hiding this comment

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

I need a call for this. The queue functionality is not clear to me. Sorry 😑

raiden-ts/src/utils/ethers.ts Show resolved Hide resolved
raiden-ts/src/utils/ethers.ts Show resolved Hide resolved
Copy link
Contributor

@weilbith weilbith left a comment

Choose a reason for hiding this comment

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

We had a pretty good call together. This algorithm is much more complex and beautiful than I initially thought. I had some misconceptions in my mind. Thanks for helping me out. Now I'm confident that is a really good fix!! 🚀

@andrevmatos andrevmatos merged commit 8937a0b into master Jul 20, 2020
@andrevmatos andrevmatos deleted the fix/error_handle_fromEthersEvent branch July 20, 2020 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization ⚡ Optimizations for the implementation or protocol sdk 🖥
Projects
None yet
2 participants