Bootstrapping
The first step to deploying a custom OP Stack is to bootstrap it onto an L1. This process will:- Deploy shared management contracts like
SuperchainConfigandSuperchainVersions. - Deploy contract implementations that will be shared among all OP Chains in this deployment.
- Set up ownership so that you can control the deployment.
bootstrap family of commands on op-deployer to do this.
Bootstrap Shared Contracts
Every OP Chain belongs to a logical deployment group. This group consists of a set of shared contracts that control the behavior of a group of OP Chains. This includes:- Pausing bridges
- Signaling which protocol versions are required and recommended
- Use Gnosis SAFEs for ownership roles like
guardianandsuperchain-proxy-admin-owner. The owner must be a smart contract to support future upgrades, so a SAFE is a sensible default. - Use a regular EOA as the deployer. It will not have any control over the deployment once the deployment completes.
- Use a standard contracts tag (e.g.
tag://op-contracts/v2.0.0). This will make upgrading easier.
Bootstrapping Implementations
The smart contracts for an OP Chain are deployed using a factory that points to a set of predeployed implementations. You must deploy the factory and the implementations every time you deploy to a new L1 and whenever new smart contract versions are released. Implementations are deployed usingCREATE2, so addresses may be reused if they
already exist on the L1.
To deploy the implementations, use the following command:
bootstrap superchain command, this will output a JSON file containing the addresses of the relevant
contracts. Again, keep track of this file.
The most important address in the implementations file is the OPCM, or OP Contracts Manager. This contract is the
factory that will deploy all the OP Chains belonging to this deployment group. It is also responsible for upgrading between
different contracts versions. Please keep the following very important invariants in mind with the OPCM:
- There is a one-to-one mapping between each OPCM, and contracts version.
- Each OPCM is associated with exactly one deployment group. This means that you must deploy a new OPCM using the
bootstrap implementationscommand for each new deployment group you manage.
Deploying
After bootstrapping the contracts and implementations, you can deploy your L2 chains with theapply command. You
will need to specify a configType of standard-overrides and set the opcmAddress field in your intent to the
address of the OPCM above. Make sure you call the right OPCM. Failing to call the right OPCM might lead to
deploying incorrect contract versions, or associating your chain with the wrong deployment.
See the following config for an example:
apply completes successfully, you can use the inspect family of commands to download your chain’s L2
genesis and rollup config files.
Upgrading
You can upgrade between smart contract versions using theupgrade family of commands. As a prerequisite,
you must deploy OPCMs for each version you want to upgrade between using the bootstrap implementations command.
You will need to use the correct sub-command for the version you are upgrading from. For example, if you are
upgrading from v2.0.0 to v3.0.0, you will need to use the upgrade v3.0.0 subcommand.
Unlike the bootstrap and apply commands, the upgrade command does not interact with the chain directly. Instead,
it generates calldata that you can use with cast, Gnosis SAFE, or whatever tooling you use to manage your L1.
To run the upgrade command, use the following:
upgrade() method on the
OPCM. The exact method you use to do this will depend on your tooling. As an example, you can craft a transaction
for use with Gnosis SAFE CLI using the command below:
The Gnosis SAFE UI does not support the
--delegate flag, so the CLI is required if you’re using a Gnosis SAFE.DELEGATECALL. If your upgrade command reverts, it is likely
due to one of these conditions not being met.