Skip to content

feat[contracts]: slightly better account funding for hardhat accounts#1056

Closed
smartcontracts wants to merge 25 commits intoregenesis/0.4.0from
kelvin/hardhat-funding
Closed

feat[contracts]: slightly better account funding for hardhat accounts#1056
smartcontracts wants to merge 25 commits intoregenesis/0.4.0from
kelvin/hardhat-funding

Conversation

@smartcontracts
Copy link
Copy Markdown
Contributor

Description
Slightly improves the funding mechanism by (1) making it parallel and (2) making it always fund the default hardhat accounts instead of funding whichever accounts are present in the config.

ben-chain and others added 21 commits June 10, 2021 10:56
* add ovmCALLVALUE context

* add ovmBALANCE

* test success and revert cases

* test empty contract case

* chore: lint
* fix ovmDELEGATECALL type, update tests

* add ovmSELFBALANCE

* fix ovmDELEGATECALL jumping to CALL

* chore: lint
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jun 10, 2021

🦋 Changeset detected

Latest commit: 985cefc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eth-optimism/contracts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@smartcontracts
Copy link
Copy Markdown
Contributor Author

smartcontracts commented Jun 10, 2021

There is a bug in this PR. Attempting to fix it now. fixed

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Merging #1056 (d409889) into feat/OP759/value-calls (04cfd3a) will not change coverage.
The diff coverage is n/a.

❗ Current head d409889 differs from pull request most recent head 985cefc. Consider uploading reports for the commit 985cefc to get more accurate results
Impacted file tree graph

@@                   Coverage Diff                   @@
##           feat/OP759/value-calls    #1056   +/-   ##
=======================================================
  Coverage                   85.95%   85.95%           
=======================================================
  Files                          52       52           
  Lines                        1972     1972           
  Branches                      308      308           
=======================================================
  Hits                         1695     1695           
  Misses                        277      277           

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 04cfd3a...985cefc. Read the comment docs.

const depositAmount = balance.div(2) // Deposit half of the wallet's balance into L2.
await Proxy__OVM_L1ETHGateway.connect(wallet).deposit(8_000_000, '0x', {
value: depositAmount,
gasLimit: 2_000_000, // Idk, gas estimation was broken and this fixes it.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you think this a problem with the contract being non deterministic in its gas usage or a hardhat thing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seemed to be a hardhat thing that had to do with doing the transactions in parallel. Not exactly sure of the root cause but didn't seem important.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have also seen the enqueue gas burn mess with gas estimates before, I don't think this is a new issue.

hre,
'Proxy__OVM_L1ETHGateway',
{
iface: 'OVM_L1ETHGateway',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just a note that the order of merging of this against #988 will matter here.

Copy link
Copy Markdown
Collaborator

@ben-chain ben-chain left a comment

Choose a reason for hiding this comment

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

LGTM, commented one way this might potentially be sped up but looks good. Will approve once you respond and/or update.

)
const balance = await wallet.getBalance()
const depositAmount = balance.div(2) // Deposit half of the wallet's balance into L2.
await Proxy__OVM_L1ETHGateway.connect(wallet).deposit(8_000_000, '0x', {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

To make this go faster, I think we can consider removing this await entirely. Becuase the deposits do not matter until they are synced by l2geth, which has not even started yet when this process is going, it feels to me like there will not be a race condition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I originally did it because I was having some issues with hardhat not processing things properly in parallel. I can try removing the sleep but didn't really seem like we really needed to save the extra 4 seconds.

@ben-chain ben-chain force-pushed the feat/OP759/value-calls branch from ff0f828 to 057de77 Compare June 10, 2021 22:17
@smartcontracts smartcontracts requested a review from karlfloersch as a June 10, 2021 22:17
@ben-chain ben-chain force-pushed the feat/OP759/value-calls branch 3 times, most recently from f4ca0c3 to 3dc67db Compare June 10, 2021 22:53
@smartcontracts smartcontracts changed the base branch from feat/OP759/value-calls to regenesis/0.4.0 June 10, 2021 23:28
@smartcontracts smartcontracts changed the base branch from regenesis/0.4.0 to feat/OP759/value-calls June 10, 2021 23:29
Base automatically changed from feat/OP759/value-calls to regenesis/0.4.0 June 10, 2021 23:37
@K-Ho
Copy link
Copy Markdown
Contributor

K-Ho commented Jun 11, 2021

replaced with #1065 due to some crazy merge conflicts

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.

6 participants