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

GasLimit to 0 #46

Merged
merged 18 commits into from
Feb 20, 2024
Merged

GasLimit to 0 #46

merged 18 commits into from
Feb 20, 2024

Conversation

sophia1ch
Copy link
Contributor

Description:

This PR sets the GasLimit to a given argument in the ERC20_Depositor, ETH_Depositor and ContractBackend. This allows us to set the gas limit to 0 for all chains that support the dynamic gasLimit estimation.

@sophia1ch sophia1ch marked this pull request as draft February 8, 2024 15:22
sophia1ch and others added 11 commits February 15, 2024 15:31
* 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>
so that it is dynamically calculated by the wallet.

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>
Signed-off-by: sophia1ch <sophia.koehler@outlook.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>
- GasLimit is set when adjudicator and depositors are created.
- This way we can differentiate between tests and production.

Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
sophia1ch and others added 2 commits February 15, 2024 15:35
Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
Signed-off-by: Sophia <118169531+sophia1ch@users.noreply.github.com>
@sophia1ch sophia1ch marked this pull request as ready for review February 15, 2024 14:42
Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
Add default gas limits to tests.
Refactor for Linter.

Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
Signed-off-by: sophia1ch <sophia.koehler@outlook.com>
// Use an ERC20 depositor with random addresses at index 1.
token := wallettest.NewRandomAddress(rng)
depositors[1] = ethchannel.NewERC20Depositor(ethwallet.AsEthAddr(token))
depositors[1] = ethchannel.NewERC20Depositor(ethwallet.AsEthAddr(token), 100000)
Copy link
Contributor

Choose a reason for hiding this comment

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

This gaslimit value is already defined above as txGasLimit. You can use that value.
In fact, both depositors, the NewETHDepositor and the NewERC20Depositor could use constants defined above: Instead of txGasLimit, you can set txERC20GasLimit and txETHGasLimit for both cases, with 100000 and 50000, respectively.

Copy link
Contributor

@iljabvh iljabvh left a comment

Choose a reason for hiding this comment

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

This PR introduces the gas limit as a non-constant input parameter for contract calls. Good work!

@iljabvh iljabvh merged commit b6f550b into hyperledger-labs:main Feb 20, 2024
6 checks passed
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.

2 participants