-
Notifications
You must be signed in to change notification settings - Fork 6
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: Remove IncreaseAllowance & Add shared nonce (#1) #43
Conversation
I would probably have split this PR into two separate PRs for the two main changes here, but for the sake of time, we'll just use this single PR here. |
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.
I have some other remarks to the ERC20 Depositor, which I will just fix in a different branch in perun-network and will then create another PR there.
Edit: I'm not really able to write my suggestions as there are some more uncertainties regarding the implementation, so I'll add my questions in this PR.
channel/erc20_depositor.go
Outdated
tx2, err := assetholder.Deposit(opts, req.FundingID, req.Balance) | ||
err = cherrors.CheckIsChainNotReachableError(err) | ||
return []*types.Transaction{tx1, tx2}, errors.WithMessage(err, "AssetHolderERC20 depositing") | ||
return tx2, err |
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.
Rename tx2 to just tx.
channel/erc20_depositor.go
Outdated
var err1 error | ||
lockAndUnlock(lock, func() { | ||
allowance, err := token.Allowance(&callOpts, req.Account.Address, req.Asset.EthAddress()) | ||
if err != nil { |
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.
If any of these ifs should be true, which means that an error has occurred, the function will still continue to execute
* channel: Include shared Nonce object, incrementing the nonce of an account while the transaction is broadcast. Implement sync.Mutex, locking the nonce incrementals. In erc20_depositor.go, the depositing process is locked during the "Approve" function call with ```lockKey```. The function ```(d *ERC20Depositor) Deposit``` is renamed to `````(d *ERC20Depositor) DepositOnly` * client: To avoid timeouts caused by the added locking mechanism during ERC20 deposits, ```context.WithTimeout``` and ```twoPartyTestTimeout``` has been increased in fund_test.go and payment_test.go. * client/test: Timeouts have been increased to avoid premature timeout errors due to the locking mechanism above. --------- Signed-off-by: Ilja von Hoessle <ilja@perun.network> Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
Remove unused SharedNonceMtx. Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
refactor(erc20_depositor): - Create seperate function for Approval. - Rename lock and mutex. Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
- Add description to Approve function. - Put Error as last return element in Approve function. fix(erc20_depositor): - remove unnecessary locking of depositLocksMtx. Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
Fix comment and Argument order for Linter. Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
Co-authored-by: Philipp Lehwalder <philipp.lehwalder@gmail.com> Signed-off-by: Sophia <118169531+sophia1ch@users.noreply.github.com>
- Change SharedMutex to SharedExpectedNoncesMutex. refactor(erc20_depositor): - Return directly if Approval returns error. - Fix comments. Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
Change position of bracket. Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
This PR enables Perun clients to
|
This PR fixes #41 and modifies the depositing mechanism of the Ethereum backend for ERC20 assets. Both changes enable the backend to handle multiple payment channels for one Perun client.