-
Notifications
You must be signed in to change notification settings - Fork 683
Add evm_setCode
and evm_setStorageAt
RPC methods
#649
Comments
Ah this idea is great! |
I think this is related to the db_getHex, db_setHex, db_getString and db_setString rpc methods.. |
could utilize the MPT put method |
The |
Right, my bad. Still going through the codebase. |
These will likely land in the next major release or shortly thereafter. I played around with an experimental version here: https://github.com/trufflesuite/ganache-core/blob/4a081acfad686e2f94c49f6087df6bb9722d2d1d/src/chains/ethereum/src/api.ts#L224 but literally haven't even run the code to see it fail... I accidentally included it in a commit refactoring other parts of code. 😅 That branch I linked to is a rewrite of ganache-core into TypeScript and it will be some time before it is released (and will be a significant breaking change). For the time being I'm trying to maintain the current JavaScript code base as well, so if you want, you can port the work I started over to JS, and I'll likely merge and release it. |
ah okay that's cool |
These features are implemented by #2337. |
Expected Behavior
I would like to be able to insert bytecode at arbitrary addresses, and manipulate storage.
Possible Solution
I propose to add two new non-standard RPC methods:
evm_setCode
: takes two parameters. The first is the address where the bytecode is to be added, and the 2nd is the bytecode.evm_setStorageAt
: takes three parameters. The first is an address, the second is an offset, the third is a 32 byte hexstring to place at that address/offset.Context
With these methods it will be possible to recreate specific mainnet conditions so I can test against "sort-of production" without sacrificing performance (forking can be slow) or losing determinism.
It will also allow me to do things such as:
I think there are a lot of potential use cases here.
The text was updated successfully, but these errors were encountered: