-
Notifications
You must be signed in to change notification settings - Fork 47
op-deployer: Add design doc on using Forge #325
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Use Forge as the EVM for OP Deployer | ||
|
||
## Summary | ||
|
||
We propose switching out the Go-based EVM inside OP Deployer for a wrapper around Forge. This would reduce our | ||
maintenance burden and allow us to take advantage of new Forge features without requiring us to reimplement them. | ||
|
||
## Problem Statement + Context | ||
|
||
OP Deployer was developed on top of a Golang-based EVM. This allows OP Deployer to execute Forge scripts and | ||
simulate transactions prior to executing them like Forge does. Now that OP Deployer has been in production for over | ||
a year, we're running into several issues with this approach: | ||
|
||
1. **Difficulty debugging.** Rather than outputting a trace of the error, OP Deployer simply panics with | ||
"revision ID 1 cannot be reverted." Users must then parse through the logs to determine the cause of the error. | ||
2. **Incomplete featureset compared to Forge.** OP Deployer is often compared to Forge, since both deploy contracts. | ||
Therefore, users perceive OP Deployer as incomplete from a feature perspective. For example, OP Deployer does not | ||
support verifying all the contracts it can deploy, and the contracts it _does_ support can only be verified on | ||
Etherscan. | ||
3. **Maintenance burden.** The Golang EVM is a significant maintenance burden. Every new cheatcode in Forge must be | ||
reimplemented in Go. Additionally, we must maintain a "bridge" to allow Golang to call into Solidity scripts. | ||
This is a lot of work that provides no user benefit since the Golang EVM is simply a backend that allows contracts to | ||
be deployed. This is table stakes for a deployment tool, and is much better solved in Forge. | ||
|
||
We originally adopted the Golang solution because we wanted to avoid adding a dependency on Forge. However, there | ||
are many ways around this that do not incur the maintenance burdens described above. | ||
|
||
## Proposed Solution | ||
|
||
We propose switching all contract calls in OP Deployer to use Forge instead of the Golang EVM. OP Deployer would | ||
mslipper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
essentially become a thin, stateful wrapper around Forge. Think of it like an installer for our contracts. We've | ||
outlined some implementation details of this approach below. | ||
|
||
### Getting Forge | ||
|
||
OP Deployer will autodetect Forge based on the following heuristics: | ||
|
||
1. If Forge is already on the user's machine, and it is a supported version, use it. | ||
2. Otherwise, download a pinned version of Forge and use that. | ||
mslipper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Calling Forge | ||
|
||
For now, OP Deployer will simply call the Forge binary as a CLI tool. To communicate with Forge, OP Deployer will | ||
parse Forge's standard output stream. This will require updating some of our smart contracts to output JSON. We may | ||
adopt solutions like calling Forge as a library via FFI, but that is currently out of scope. | ||
|
||
Forge's output will otherwise be streamed directly to the user's terminal so that they can see the progress of the | ||
deployment. | ||
|
||
## Impact on Developer Experience | ||
|
||
This change should make maintaining OP Deployer much easier: | ||
|
||
1. The Platforms team would no longer need to maintain the Golang EVM. | ||
2. Changes to Forge can be immediately adopted. | ||
3. Smart contract devs don't need to worry about how their contracts will be called from Golang anymore. | ||
4. Error messages and contract deployment output will be much better. | ||
|
||
Users running OP Deployer in a container will either need to use a container that contains Forge, or allow that | ||
container to download the Forge binary. We can provide a prebuilt container with Forge installed to avoid this issue. | ||
|
||
## Alternatives Considered | ||
|
||
### Continue Maintaining the Golang EVM | ||
|
||
This is our default path. However, we're getting asked to build things like Blockscout contract verification, which | ||
would be entirely duplicative of what Forge already does really well. | ||
|
||
## Risks & Uncertainties | ||
|
||
None really. This is a pretty straightforward change that reduces risk overall. | ||
mslipper marked this conversation as resolved.
Show resolved
Hide resolved
mslipper marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Uh oh!
There was an error while loading. Please reload this page.