forked from foundry-rs/foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Tweak #3
Open
sambacha
wants to merge
146
commits into
manifoldfinance:master
Choose a base branch
from
MEDGA-eth:tweak
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Tweak #3
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Forge clone
Test: fix rate limit issue for forge clone tests
Add `clone.toml` metadata to forge clone
Improve clone metadata
[WIP] it is a complex sync and may induce bugs
Fixed `.clone.meta` file deserialization bug
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Foundry with on-chain contract Tweak!
Tweak allows users/developers to alter the code of an on-chain contract with the on-chain state untouched.
Almost any modification is allowed, as long as the storage layout is preserved.
With Tweak, you can:
console.log()
in any on-chain contracts with source code available on Etherscan.Tweaking on-chain contracts are especially useful when:
Here's the demo!
Installation
This project is a fork of foundry.
The easiest way to install is to compile this project and replace the foundry toolchain originally on your machine.
The executables are available in
target/debug
folder.All the tools that you are familiar in foundry are still there.
What is enhanced is the
cast
andforge
command.Usage 1: Clone a verified contract code from Etherscan
forge clone
is a new feature that downloads the source code of a verified contract at<address>
from Etherscan (or other block explorers supported by foundry) and save as a foundry project in the specified<path>
.The cloned project is fully compilable foundry project, guaranteed to generate exactly the same bytecode as the on-chain contract.
Usage 2: Tweak one on-chain contract and replay a historical transaction invoking it
If the current working directory is a foundry project created by
forge clone
, then the commandforge replay
is available to replay a historical transaction with the on-chain contract's code tweaked by the current project.Note that the cloned project "knows" which contract address it should tweak.
You may want to modify the code of the cloned contract (e.g., add
console.log
s) before runningforge replay
.Usage 3: Tweak multiple on-chain contracts and replay a historical transaction invoking them
cast run
is also enhanced by allowing specified cloned projects to tweak the code of multiple on-chain contracts.Note that each cloned project "knows" which contract address it should tweak.
Disclaimer
The Tweak feature is still under active development as part of the EtherDebug project, whose ultimate goal is improve the overall development and debugging experience of EVM-compatibla smart contracts.
The functionality is not stable yet and may suffer from breaking change in the future.
Any contribution (bug reports, PRs, documentation, etc.) is welcome and greatly appreciated.
Acknowledgement
Contributed by @Troublor and @ZhangZhuoSJTU with passion.