matter-labs / era-test-node

In-memory node that can be used for integration testing and debugging.
https://matter-labs.github.io/era-test-node
Apache License 2.0
308 stars 75 forks source link

feat: anvil API #313

Closed vbar closed 1 month ago

vbar commented 2 months ago

What :computer:

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 :hand:

Implements https://github.com/matter-labs/era-test-node/issues/160 .

Evidence :camera:

Extended e2e tests, which pass.

AnastasiiaVashchuk commented 2 months ago

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

vbar commented 2 months ago

@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 commented 2 months ago

@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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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

vbar commented 2 months ago

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

anvil_getLogs

Where did you get that? Not even Google knows... :-)

anvil_dropTransaction

Ah yes, I remember discussing that - cannot be supported in the test node.

AnastasiiaVashchuk commented 2 months ago

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

Where did you get that? Not even Google knows... :-)

anvil_dropTransaction

Ah yes, I remember discussing that - cannot be supported in the test node.

cannot be supported in the test node.

why?

vbar commented 2 months ago

anvil_dropTransaction

Ah yes, I remember discussing that - cannot be supported in the test node.

cannot be supported in the test node.

why?

IIRC because it should remove a transaction from the pool, but the test node has no pool.

vbar commented 2 months ago

Trying the Rivet extension:

API status note
evm_setAccountNonce not used
anvil_setNonce needed
anvil_impersonateAccount not found
anvil_stopImpersonatingAccount not found probably gated by anvil_impersonateAccount
anvil_mine needed
anvil_reset not called against test node (but is against anvil) listed as "planned feature"
anvil_setBalance needed
anvil_setCode Deploy button found but all bytecode put into it fails (against both anvil and test node) listed as "planned feature"
anvil_setStorageAt not found listed as "planned feature"
AnastasiiaVashchuk commented 1 month ago

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