Skip to content

Commit a6f3f30

Browse files
committed
Add bytecode verification doc
1 parent 996a2e8 commit a6f3f30

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# OPCM Bytecode Verification: Design Doc
2+
3+
4+
| | |
5+
| -------------------- | ------------ |
6+
| Author | Maurelian |
7+
| Created at | 2025-06-04 |
8+
| Initial Reviewers | TBD |
9+
| Need Approval From | TBD |
10+
| Status | Draft |
11+
12+
## Purpose
13+
14+
Ensure that the contracts referenced in `OPContractsManager` (OPCM) are verifiably built from 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 `op-deployer` to validate that deployed contract bytecode matches locally built artifacts. This prevents accidental or malicious mismatches and establishes trust in deployments originating from a known commit. The step will be automated in CI, and become part of the documented SDLC.
19+
20+
## Problem Statement + Context
21+
22+
Currently, there is no enforced mechanism to ensure that the OPCM used in an upgrade is built
23+
from a trusted commit, which should be one labelled as an `op-contracts/vX.Y.Z` tag, and approved
24+
by governance.
25+
26+
This creates a risk of human error or maliciousness leading to an upgrade performed by an incorrect
27+
version of the OPCM (or the implementation contracts it sets). It also presents a risk of a failed upgrade
28+
resulting from a misconfigured OPCM (ie. if any [constructor vars](https://github.com/ethereum-optimism/optimism/blob/a10fd5259a3af9a465955b035e16f516327d51d5/packages/contracts-bedrock/src/L1/OPContractsManager.sol#L266-L269) are set incorrectly).
29+
30+
We want to eliminate this risk by automating the [Contract's Release Verification](https://www.notion.so/oplabs/Contracts-Release-Checklist-1f8f153ee162805e8236f022ebb8c868?source=copy_linkhttps:/) process, making it
31+
easy to demonstrate that an OPCM at a given address corresponds to a trusted commit.
32+
33+
The solution should be:
34+
35+
- contained within the release commit in the monorepo
36+
- easily runnable locally with a single command accepting only an RPC URL and the address of the OPCM
37+
- runnable in CI in the `superchain-registry` repo
38+
- incorporated into the upgrade process in a way that ensures it is run by multiple people
39+
40+
## Proposed Solution
41+
42+
### Bytecode verification against the local source
43+
44+
A new command should be added to `op-deployer`.
45+
46+
```
47+
op-deployer verify-bytecode <opcm-address>
48+
49+
```
50+
51+
This command will invoke the `VerifyOPCM.s.sol` script's [default entrypoint](https://github.com/ethereum-optimism/optimism/blob/158e990b76a85acbb018577bd4079190b2d97281/packages/contracts-bedrock/scripts/deploy/VerifyOPCM.s.sol#L126-L129) to verify the OPCM.
52+
53+
```
54+
op-deployer verify-bytecode --single-contract <contract-name> <contract-address>
55+
```
56+
57+
This command will invoke the `VerifyOPCM.s.sol` script's [runSingle entrypoint](https://github.com/ethereum-optimism/optimism/blob/158e990b76a85acbb018577bd4079190b2d97281/packages/contracts-bedrock/scripts/deploy/VerifyOPCM.s.sol#L135) in order to verify any contracts involved in the upgrade which are not included in the OPCM (ie.
58+
the new `DeputyPauseModule` introduced in upgrade 16.
59+
60+
### Artifacts source
61+
62+
By default, `op-deployer verify-bytecode` will use locally build forge-artifacts to check bytecode.
63+
In order to facilitate quickly running in CI, without having to checkout and rebuild different commits, the command will also accept a tag locator, with the following invocation:
64+
65+
```
66+
op-deployer verify-bytecode --dangerously-use-remote-artifacts --artifacts-locator tag://op-contracts/vX.Y.Z
67+
68+
```
69+
70+
The flag `--dangerously-use-remote-artifacts` is intended to discourge the use of remote artifacts when running locally.
71+
72+
### OPCM config verification
73+
74+
Both of the commands above will accept the following arguments to confirm the configuration of
75+
76+
```
77+
--upgrade-controller 0x... \
78+
--superchain-config 0x... \
79+
--protocol-versions 0x... \
80+
--superchain-proxy-admin 0x...
81+
```
82+
83+
###
84+
85+
### Integration points
86+
87+
This script will:
88+
89+
- Build contract artifacts at the trusted commit.
90+
- Retrieve deployed bytecode via the OPCM.
91+
- Compare local vs deployed bytecode, including support for implementation, blueprint, and linked contracts.
92+
- Generate a verification artifact (e.g. JSON) that is checked into the monorepo and diffed in code review.
93+
94+
This step will be:
95+
96+
- Automated in CI (run in SCR or release-management repo).
97+
- Expected to be verified/redundantly run by multiple reviewers.
98+
99+
### Resource Usage
100+
101+
- Minimal: Only requires compilation and comparison of bytecode.
102+
- Optional Etherscan calls for constructor bytecode fetches (bounded network cost).
103+
104+
### Single Point of Failure and Multi Client Considerations
105+
106+
- No direct impact on clients like `op-geth` or `op-reth`.
107+
- Ensures that bytecode is consistent regardless of which client or deployer is used.
108+
109+
## Impact on Developer Experience
110+
111+
- No impact on app developers.
112+
- Protocol developers and release managers will have one additional verification step that is largely automated.
113+
114+
## Alternatives Considered
115+
116+
- A new op-deployer command. This approach would need to download artifacts and thus does not meet
117+
the requirement of building locally.
118+
119+
## Risks & Uncertainties
120+
121+
- Build non-determinism could cause false negatives.
122+
- Reliance on Etherscan APIs (when used).
123+
- Risk of CI misconfiguration allowing bypass of the check.
124+
- Trust assumption that the build system and commit used for verification are secure.

0 commit comments

Comments
 (0)