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

feat: anvil API #313

Merged
merged 36 commits into from
Aug 27, 2024
Merged

feat: anvil API #313

merged 36 commits into from
Aug 27, 2024

Conversation

vbar
Copy link
Contributor

@vbar vbar commented Jul 11, 2024

What 💻

Added evm_setAccountNonce, anvil_setNonce, anvil_impersonateAccount, anvil_stopImpersonatingAccount, anvil_mine, anvil_reset, anvil_setBalance, anvil_setCode and anvil_setStorageAt as aliases to the corresponding hardhat_* methods.

Why ✋

Implements #160 .

Evidence 📷

Extended e2e tests, which pass.

@vbar vbar requested a review from a team as a code owner July 11, 2024 06:10
@AnastasiiaVashchuk
Copy link
Contributor

@vbar what about other endpoints?
I checked the endpoints list here - https://book.getfoundry.sh/reference/anvil/
There are many more methods.

@vbar
Copy link
Contributor Author

vbar commented Jul 31, 2024

@vbar what about other endpoints? I checked the endpoints list here - https://book.getfoundry.sh/reference/anvil/ There are many more methods.

Well, yes, but not all of them can be supported by the test node - so I wanted to start with the obvious aliases...

@MexicanAce
Copy link
Collaborator

@vbar what about other endpoints?
I checked the endpoints list here - https://book.getfoundry.sh/reference/anvil/
There are many more methods.

The point of having anvil endpoints is so tools like Rivet work with era-test-node. We shouldn't be adding anvil_ endpoints if they aren't being used upstream.

To that end, there's no need to implement every endpoint. I would spin up that chrome extension tool and see what's required

@vbar
Copy link
Contributor Author

vbar commented Jul 31, 2024

The point of having anvil endpoints is so tools like Rivet work with era-test-node. We shouldn't be adding anvil_ endpoints if they aren't being used upstream.

To that end, there's no need to implement every endpoint. I would spin up that chrome extension tool and see what's required

Err, do you have a cookbook? I tried that, and it didn't work at all...

@MexicanAce
Copy link
Collaborator

The point of having anvil endpoints is so tools like Rivet work with era-test-node. We shouldn't be adding anvil_ endpoints if they aren't being used upstream.

To that end, there's no need to implement every endpoint. I would spin up that chrome extension tool and see what's required

Err, do you have a cookbook? I tried that, and it didn't work at all...

Nope. They've made a lot of changes since I last got it barely working, so this requires some exploratory investigation

@AnastasiiaVashchuk
Copy link
Contributor

AnastasiiaVashchuk commented Jul 31, 2024

The point of having anvil endpoints is so tools like Rivet work with era-test-node. We shouldn't be adding anvil_ endpoints if they aren't being used upstream.
To that end, there's no need to implement every endpoint. I would spin up that chrome extension tool and see what's required

Err, do you have a cookbook? I tried that, and it didn't work at all...

Nope. They've made a lot of changes since I last got it barely working, so this requires some exploratory investigation

that's are endpoints probably used by River, but I am not sure. @vbar we need to check.

anvil_getLogs
anvil_getBlock
anvil_getTransaction
anvil_getReceipt
anvil_setBalance
anvil_mine
anvil_dropTransaction
anvil_impersonateAccount
anvil_stopImpersonatingAccount

Co-authored-by: AnastasiiaVashchuk <72273339+AnastasiiaVashchuk@users.noreply.github.com>
@AnastasiiaVashchuk
Copy link
Contributor

anvil_setStorageAt, anvil_impersonateAccount , anvil_stopImpersonatingAccount - are used by rivet.
JFYI.

Co-authored-by: AnastasiiaVashchuk <72273339+AnastasiiaVashchuk@users.noreply.github.com>
@AnastasiiaVashchuk AnastasiiaVashchuk merged commit 706d726 into matter-labs:main Aug 27, 2024
10 checks passed
vasyl-ivanchuk added a commit that referenced this pull request Sep 9, 2024
* fix: changed evm_setNextBlockTimestamp (#321)

* changed evm_setNextBlockTimestamp argument type to U64

* fixed caller of evm_setNextBlockTimestamp

* setting the timestamp of the next block in evm_setNextBlockTimestamp

* formatted

* updated comment

* fix: returning errors from fork handling (#335)

* not panicking in is_write_initial_internal

* not panicking in fork_network_and_client

* not panicking in get_earlier_transactions_in_same_block

* not panicking in get_block_gas_details

* Update src/fork.rs

Co-authored-by: AnastasiiaVashchuk <72273339+AnastasiiaVashchuk@users.noreply.github.com>

* more specific error message

* more specific error message

* added miniblock number to error message

---------

Co-authored-by: AnastasiiaVashchuk <72273339+AnastasiiaVashchuk@users.noreply.github.com>

* feat: anvil API (#313)

* added evm_setAccountNonce alias

* added anvil_setNonce alias

* added anvil_impersonateAccount & anvil_stopImpersonatingAccount aliases

* added anvil_mine alias

* added anvil_reset alias

* added anvil_setBalance alias

* added anvil_setCode alias

* added anvil_setStorageAt alias

* added anvil_* aliases

* added anvil_mine test

* modified hardhat_impersonateAccount & hardhat_stopImpersonatingAccount
to actually call hardhat_stopImpersonatingAccount, interfere less
with other tests

* added anvil_impersonateAccount & anvil_stopImpersonatingAccount test

* added anvil_setCode test

* added hardhat_setStorageAt and anvil_setStorageAt tests

* formatted

* removed links to anvil namespace

* split tables

* Revert "split tables"

This reverts commit 4a54fe8.

* renamed AnvilNamespaceT::hardhat_mine to anvil_mine

* Update SUPPORTED_APIS.md

Co-authored-by: AnastasiiaVashchuk <72273339+AnastasiiaVashchuk@users.noreply.github.com>

* added section for evm_setAccountNonce

* changed var to let to satisfy linter

* using random address in anvil_setCode test

* added semicolon

* named test account address

* changed var to let to satisfy linter

* Update src/namespaces/anvil.rs

Co-authored-by: AnastasiiaVashchuk <72273339+AnastasiiaVashchuk@users.noreply.github.com>

* removed to.be.within checks

* supressing TypeScript errors

* supressing TypeScript errors

* changed anvil_setCode code type

* using find instead of an explicit loop

---------

Co-authored-by: AnastasiiaVashchuk <72273339+AnastasiiaVashchuk@users.noreply.github.com>

* test: Add test for hardhat_reset (#333)

* add test and do follow up fixes

* run lint

* fix nits

* fix: Update gas estimation logic for forks (#339)

* fix: fork gas estimation

* Additional fixes

* chore: Update release version (#340)

* chore: fix tests after the gas changes

* test: fix unit tests

---------

Co-authored-by: Vaclav Barta <vbarta@mangrove.cz>
Co-authored-by: AnastasiiaVashchuk <72273339+AnastasiiaVashchuk@users.noreply.github.com>
Co-authored-by: Nicolas Villanueva <1890113+MexicanAce@users.noreply.github.com>
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.

3 participants