-
Notifications
You must be signed in to change notification settings - Fork 29
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
Support openChannelWithDeposit from new contracts #2919
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2919 +/- ##
==========================================
+ Coverage 93.57% 93.66% +0.08%
==========================================
Files 116 116
Lines 6369 6394 +25
Branches 1149 1150 +1
==========================================
+ Hits 5960 5989 +29
+ Misses 354 350 -4
Partials 55 55
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
The later is simpler, receives saner parameters and includes more shared logic, like fetching balanceOf and allowance from token contract.
If channelOpen was requested with deposit and we're on the new contracts, instead of emitting a parallel channelDeposit.request with waitOpen=true, we ensureApprovedBalance$ inside channelOpenEpic and call `openChannelWithDeposit` directly, which should open and deposit in a single tx (faster); `channelEventsEpic` is able to handle deposits on the same block as open.
8622892
to
acac79e
Compare
acac79e
to
5883883
Compare
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.
Great!
Fixes #2891
Short description
raiden-contracts 0.39 supports a new method:
openChannelWithDeposit
, which does channel open + deposit in a single transaction, more efficient and faster to confirm than separate channelOpen + channelDeposit. This PR dynamically uses this method iff contracts being used support it, falling back to normalopen + confirmation + deposit + confirmation
as a fallback (so we can still suport 0.37 and 0.39+ contracts on the same codebase).This is transparent, and automatically done when deposit is requested together with open, if possible.
A small edge case to keep in mind (and tested by SP, and now with tests specific for it) is when two peers try to
openChannelWithDeposit
with each other at the same time; only one of the txs will succeed, making the "open" side of it to succeed for both clients but "deposit" only for the side which won the race; in this case, the losing side will detect it and fallback to emitting thechannelDeposit.request
as it was with the old mechanism, completing the deposit and succeeding theopen + deposit
operation, as expected by the user.Definition of Done
Steps to manually test the change (dApp)