Skip to content

Add op-deployer flow to OP Stack genesis creation #1302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 82 additions & 6 deletions pages/builders/chain-operators/deploy/genesis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,96 @@ import { Callout } from 'nextra/components'

# OP Stack genesis creation

<Callout type="warning">
This page is out of date and shows the legacy method for genesis file creation.
For the latest recommended method, use [op-deployer](/builders/chain-operators/tools/op-deployer).
<Callout type="info">
The recommended way to generate genesis and rollup configuration files is using `op-deployer`.
This ensures standardization and compatibility with the Superchain.
</Callout>

The `op-deployer` tool simplifies the creation of genesis and rollup configuration files (`genesis.json` and `rollup.json`).
These files are crucial for initializing the execution client (`op-geth`) and consensus client (`op-node`) for your network.

The recommended flow for creating a genesis file and rollup configuration file on the OP Stack is as follows:

1. **Deploy the L1 contracts** using [op-deployer](/builders/chain-operators/tools/op-deployer).
2. **Generate** both the L2 genesis file (`genesis.json`) and the rollup configuration file (`rollup.json`) using op-deployer’s `inspect` commands.
3. **Initialize** your off-chain components (e.g., execution client, consensus client).

## Recommended method: using op-deployer

### Prerequisites

1. You have installed the `op-deployer` binary following the instructions in [deployer docs](/builders/chain-operators/tools/op-deployer#installation).
After installation, extract the `op-deployer` into your `PATH` and `cd op-deployer`.
2. You have created and customized an intent file in a `.deployer` directory, typically by running:
```bash
./bin/op-deployer init --l1-chain-id <YOUR_L1_CHAIN_ID> --l2-chain-ids <YOUR_L2_CHAIN_ID> --workdir .deployer
```

Replace `<YOUR_L1_CHAIN_ID>` and `<YOUR_L2_CHAIN_ID>` with their respective values, see a list of [`chainIds`](https://chainid.network/).

3. You have edited that intent file to your liking (roles, addresses, etc.).

### Step 1: Deploy the L1 contracts

To deploy your chain to L1, run:
```bash
./bin/op-deployer apply --workdir .deployer \
--l1-rpc-url <RPC_URL_FOR_L1> \
--private-key <DEPLOYER_PRIVATE_KEY_HEX>
```

This command:

* Reads your intent file in `.deployer/.`
* Deploys the OP Stack contracts to the specified L1.
* Updates a local `state.json` file with the results of the deployment.

### Step 2: Generate your L2 genesis file and rollup file

After your L1 contracts have been deployed, generate the L2 genesis and rollup configuration files by inspecting the deployer’s `state.json.`
```bash
./bin/op-deployer inspect genesis --workdir .deployer <L2_CHAIN_ID> > .deployer/genesis.json
./bin/op-deployer inspect rollup --workdir .deployer <L2_CHAIN_ID> > .deployer/rollup.json
```

* genesis.json is the file you will provide to your execution client (e.g. op-geth).
* rollup.json is the file you will provide to your consensus client (e.g. op-node).

### Step 3: Initialize your off-chain components

Once you have `genesis.json` and `rollup.json`:

1. Initialize op-geth using genesis.json.
2. Configure op-node with rollup.json.
3. Set up additional off-chain infrastructure as needed (block explorer, indexers, etc.). For more on architecture, see [Architecture overview](/builders/chain-operators/architecture).

4. ### Step 3: Get data

Now that you have your `genesis.json` and `rollup.json` you can spin up a node on your network.
You can also use the following inspect subcommands to get additional data:

```bash
./bin/op-deployer inspect l1 --workdir .deployer <l2-chain-id> # outputs all L1 contract addresses for an L2 chain
./bin/op-deployer inspect deploy-config --workdir .deployer <l2-chain-id> # outputs the deploy config for an L2 chain
```

## Legacy method: using foundry script

The following guide shows you how to generate the L2 genesis file `genesis.json`. This is a JSON
file that represents the L2 genesis. You will provide this file to the
execution client (op-geth) to initialize your network. There is also the rollup configuration file, `rollup.json`, which will be
provided to the consensus client (op-node).

## Solidity script
<Callout type="warning">
The following genesis creation information is the legacy method for creating OP Stack configuration files.
This method is not recommended. It's preserved here for historical context.
</Callout>


## Solidity script (Legacy)

At the time of this writing, the preferred method for genesis generation is to use the foundry script
located in the monorepo to generate an "L2 state dump" and then pass this into the op-node genesis subcommand.
You can also use the foundry script
located in the monorepo to generate an "L2 state dump" and then pass this into the op-node genesis subcommand.
The foundry script can be found at
[packages/contracts-bedrock/scripts/L2Genesis.s.sol](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/scripts/L2Genesis.s.sol).

Expand Down