Skip to content

Commit a5c15cb

Browse files
committed
Add bytecode verification doc
Add some polish
1 parent 996a2e8 commit a5c15cb

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# OPCM Bytecode Verification: Design Doc
2+
3+
| | |
4+
| ------------------ | ---------- |
5+
| Author | Maurelian |
6+
| Created at | 2025-06-04 |
7+
| Initial Reviewers | TBD |
8+
| Need Approval From | TBD |
9+
| Status | Draft |
10+
11+
## Purpose
12+
13+
Ensure that the contracts referenced in `OPContractsManager` (OPCM) are verifiably built from
14+
trusted source code by introducing a bytecode verification step into the release process.
15+
16+
## Summary
17+
18+
We propose integrating the `VerifyOPCM.s.sol` Foundry script into the release process via
19+
`op-deployer` to validate that deployed contract bytecode matches locally built artifacts. This
20+
prevents accidental or malicious mismatches and establishes trust in deployments originating from a
21+
known commit. The step will be automated in CI, and become part of the documented SDLC.
22+
23+
## Problem Statement + Context
24+
25+
Currently, there is no enforced mechanism to ensure that the OPCM used in an upgrade is built from a
26+
trusted commit, which should be one labelled as an `op-contracts/vX.Y.Z` tag, and approved by
27+
governance.
28+
29+
This creates a risk of human error or maliciousness leading to an upgrade performed by an incorrect
30+
version of the OPCM (or the implementation contracts it sets). It also presents a risk of a failed
31+
upgrade resulting from a misconfigured OPCM (ie. if any [constructor
32+
vars](https://github.com/ethereum-optimism/optimism/blob/a10fd5259a3af9a465955b035e16f516327d51d5/packages/contracts-bedrock/src/L1/OPContractsManager.sol#L266-L269)
33+
are set incorrectly).
34+
35+
We want to eliminate this risk by automating the [Contract's Release
36+
Verification](https://www.notion.so/oplabs/Contracts-Release-Checklist-1f8f153ee162805e8236f022ebb8c868?source=copy_linkhttps:/)
37+
process, making it easy to demonstrate that an OPCM at a given address corresponds to a trusted
38+
commit.
39+
40+
The solution should be:
41+
42+
- contained within the release commit in the monorepo
43+
- easily runnable locally with a single command accepting only an RPC URL and the address of the
44+
OPCM
45+
- runnable in CI in the `superchain-registry` repo
46+
- incorporated into the upgrade process in a way that ensures it is run by multiple people
47+
48+
## Proposed Solution
49+
50+
### Bytecode verification against the local source
51+
52+
A new command should be added to `op-deployer`.
53+
54+
```
55+
op-deployer verify-bytecode <opcm-address>
56+
57+
```
58+
59+
This command will invoke the `VerifyOPCM.s.sol` script's [default
60+
entrypoint](https://github.com/ethereum-optimism/optimism/blob/158e990b76a85acbb018577bd4079190b2d97281/packages/contracts-bedrock/scripts/deploy/VerifyOPCM.s.sol#L126-L129)
61+
to verify the OPCM.
62+
63+
```
64+
op-deployer verify-bytecode --single-contract <contract-name> <contract-address>
65+
```
66+
67+
This command will invoke the `VerifyOPCM.s.sol` script's [runSingle
68+
entrypoint](https://github.com/ethereum-optimism/optimism/blob/158e990b76a85acbb018577bd4079190b2d97281/packages/contracts-bedrock/scripts/deploy/VerifyOPCM.s.sol#L135)
69+
in order to verify any contracts involved in the upgrade which are not included in the OPCM (ie. the
70+
new `DeputyPauseModule` introduced in upgrade 16).
71+
72+
### Artifacts source
73+
74+
By default, `op-deployer verify-bytecode` will use locally build forge-artifacts to check bytecode.
75+
In order to facilitate quickly running in CI, without having to checkout and rebuild different
76+
commits, the command will also accept a tag locator, with the following invocation:
77+
78+
```
79+
op-deployer verify-bytecode --dangerously-use-remote-artifacts --artifacts-locator tag://op-contracts/vX.Y.Z
80+
81+
```
82+
83+
The flag `--dangerously-use-remote-artifacts` is intended to discourge the use of remote artifacts
84+
when running locally, while still enabling a fast mechanism to run in CI.
85+
86+
### OPCM config verification
87+
88+
`op-deployer verify-bytecode` will require one of the following groups of arguments to confirm the
89+
configuration of the OPCM.
90+
91+
Address flags:
92+
93+
```
94+
--upgrade-controller 0x... \
95+
--superchain-config 0x... \
96+
--protocol-versions 0x... \
97+
--superchain-proxy-admin 0x...
98+
```
99+
100+
Superchain-registry flag:
101+
102+
```
103+
--superchain-registry <path/to/registry/contracts/superchain-registry.json>
104+
```
105+
106+
The argument groups should be mutually exclusive, either all of the address flags or the
107+
superchain-registry flag should be provided, but not both.
108+
109+
### Integration points
110+
111+
It is important to ensure that the bytecode verification process is run by multiple people and on
112+
multiple different machines.
113+
114+
The specific points that we should include the process are:
115+
116+
1. Automated in superchain-registry CI (as discussed above).
117+
2. Included in the [contracts release checklist](https://www.notion.so/oplabs/Contracts-Release-Checklist-1f8f153ee162805e8236f022ebb8c868?source=copy_link#1f8f153ee16280998c6bfa1140a5854d) process.
118+
3. Additionally for consideration: run by signers during the upgrade process.
119+
120+
### Resource Usage
121+
122+
N/A
123+
124+
## Single Point of Failure and Multi Client Considerations
125+
126+
N/A
127+
128+
## Impact on Developer Experience
129+
130+
- No impact on app developers.
131+
- Protocol developers and release managers will have one additional verification step that is
132+
largely automated.
133+
134+
## Risks & Uncertainties
135+
136+
- Reliance on Etherscan APIs.
137+
- We exclude from this discussion the possibility that the code in the repo is malicious, and are
138+
only concerned with verifying the bytecode against a monorepo commit and a

0 commit comments

Comments
 (0)