New overlays feature for doing ad-hoc simulations of existing contracts with modified bytecode #259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In this PR I'm adding so-called
overlays
for doing ad-hoc state simulations of contracts which replay the state with a modified bytecode for any given block range post-bedrock. I'm planning to port the same feature into the legacy optimism geth later and delegate the RPC calls to the historical RPC as well like it's being done for other RPC methods already.The new feature adds two new RPC methods:
overlay_callConstructor
andoverlay_getLogs
which can be used to patch a contract with new bytecode and get the modified logs for it.Tests
I've added a new postman collection for integration testing/refactoring which patches two contracts on OP mainnet which have been created with
CREATE
andCREATE2
. I've also added tests that retrieve all logs with the original bytecode and with the modified one and check the results.Additional context
Overlays allow you to add your custom logic to already deployed contracts and simulate on top of them. With overlays you can create new view functions, modify existing ones, change field visibility, emit new events and query the historical data of any contract with your modified source code.
Similar commercial products exist in the space and I believe making this feature opensource in op-geth will make it easier for everyone to tinker with it and build new cool things on top of it ✨
Usage
See README