The contracts/
directory consists of two things:
-
The
ZKL2OutputOracle.sol
contract, a diff of Optimism'sL2OutputOracle.sol
contract with the necessary changes to support ZK validity proofs. -
The
ZKUpgrader.s.sol
script, which deploys theZKL2OutputOracle.sol
implementation contract, upgrades an existingL2OutputOracleProxy
to point to it, and initializes the new contract with values fromzkconfig.json
.
To deploy and upgrade the contract, run the following command (where ADMIN_PK
is the private key of the admin address for the L1 proxy contracts):
forge script script/ZKUpgrader.s.sol:ZKUpgrader --rpc-url <L1_RPC> --private-key <ADMIN_PK> --verify --verifier etherscan --etherscan-api-key <ETHERSCAN_API_KEY> --broadcast --slow --vvvv
Since the ZKL2OutputOracle.sol
contract requires valid ZK proofs to transition the state, the contract must be seeded with an honest first value to be able to honestly prove transitions.
For existing contracts upgrading, they already have honest values in the contract. For new chains, the ZKUpgrader
script will initialize the contract as follows:
- The
zkconfig.json
file includes a starting output block number, as well as an L2 Rollup RPC. - The script queries the rollup node and gets the corresponding output root and timestamp for that block.
- It uses these three values to seed the contract, and all future output roots posted must be proved against this starting state.
To retrieve these values manually, use:
cast rpc --rpc-url <OP NODE RPC> optimism_outputAtBlock $(cast 2h <BLOCK NUMBER>) | jq '.outputRoot .blockRef.timestamp'
New chains will likely use a starting output block number of 0 (genesis) and prove all transitions against this state.
The ZKL2OutputOracle.sol
contract requires a verification key to be able to verify the validity proofs.
This key can be generated by running the following command from the root of the repo:
cargo run --bin vkey --release