Skip to content

Commit e2a2bf1

Browse files
authored
op-deployer: Add design doc on using Forge (#325)
1 parent 03ae425 commit e2a2bf1

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Use Forge as the EVM for OP Deployer
2+
3+
## Summary
4+
5+
We propose switching out the Go-based EVM inside OP Deployer for a wrapper around Forge. This would reduce our
6+
maintenance burden and allow us to take advantage of new Forge features without requiring us to reimplement them.
7+
8+
## Problem Statement + Context
9+
10+
OP Deployer was developed on top of a Golang-based EVM. This allows OP Deployer to execute Forge scripts and
11+
simulate transactions prior to executing them like Forge does. Now that OP Deployer has been in production for over
12+
a year, we're running into several issues with this approach:
13+
14+
1. **Difficulty debugging.** Rather than outputting a trace of the error, OP Deployer simply panics with
15+
"revision ID 1 cannot be reverted." Users must then parse through the logs to determine the cause of the error.
16+
2. **Incomplete featureset compared to Forge.** OP Deployer is often compared to Forge, since both deploy contracts.
17+
Therefore, users perceive OP Deployer as incomplete from a feature perspective. For example, OP Deployer does not
18+
support verifying all the contracts it can deploy, and the contracts it _does_ support can only be verified on
19+
Etherscan.
20+
3. **Maintenance burden.** The Golang EVM is a significant maintenance burden. Every new cheatcode in Forge must be
21+
reimplemented in Go. Additionally, we must maintain a "bridge" to allow Golang to call into Solidity scripts.
22+
This is a lot of work that provides no user benefit since the Golang EVM is simply a backend that allows contracts to
23+
be deployed. This is table stakes for a deployment tool, and is much better solved in Forge.
24+
25+
We originally adopted the Golang solution because we wanted to avoid adding a dependency on Forge. However, there
26+
are many ways around this that do not incur the maintenance burdens described above.
27+
28+
## Proposed Solution
29+
30+
We propose switching all contract calls in OP Deployer to use Forge instead of the Golang EVM. OP Deployer would
31+
essentially become a thin, stateful wrapper around Forge. Think of it like an installer for our contracts. We've
32+
outlined some implementation details of this approach below.
33+
34+
### Getting Forge
35+
36+
OP Deployer will autodetect Forge based on the following heuristics:
37+
38+
1. If Forge is already on the user's machine, and it is a supported version, use it.
39+
2. Otherwise, download a pinned version of Forge and use that.
40+
41+
### Calling Forge
42+
43+
For now, OP Deployer will simply call the Forge binary as a CLI tool. To communicate with Forge, OP Deployer will
44+
parse Forge's standard output stream. This will require updating some of our smart contracts to output JSON. We may
45+
adopt solutions like calling Forge as a library via FFI, but that is currently out of scope.
46+
47+
Forge's output will otherwise be streamed directly to the user's terminal so that they can see the progress of the
48+
deployment.
49+
50+
## Impact on Developer Experience
51+
52+
This change should make maintaining OP Deployer much easier:
53+
54+
1. The Platforms team would no longer need to maintain the Golang EVM.
55+
2. Changes to Forge can be immediately adopted.
56+
3. Smart contract devs don't need to worry about how their contracts will be called from Golang anymore.
57+
4. Error messages and contract deployment output will be much better.
58+
59+
Users running OP Deployer in a container will either need to use a container that contains Forge, or allow that
60+
container to download the Forge binary. We can provide a prebuilt container with Forge installed to avoid this issue.
61+
62+
## Alternatives Considered
63+
64+
### Continue Maintaining the Golang EVM
65+
66+
This is our default path. However, we're getting asked to build things like Blockscout contract verification, which
67+
would be entirely duplicative of what Forge already does really well.
68+
69+
## Risks & Uncertainties
70+
71+
None really. This is a pretty straightforward change that reduces risk overall.

0 commit comments

Comments
 (0)