diff --git a/pages/builders/chain-operators/deploy/smart-contracts.mdx b/pages/builders/chain-operators/deploy/smart-contracts.mdx index 2a26e2f10..8a65356cf 100644 --- a/pages/builders/chain-operators/deploy/smart-contracts.mdx +++ b/pages/builders/chain-operators/deploy/smart-contracts.mdx @@ -4,13 +4,12 @@ lang: en-US description: Learn how to deploy the OP Stack L1 smart contracts. --- -import { Callout } from 'nextra/components' +import { Callout, Steps } from 'nextra/components' # OP Stack smart contract deployment - -This page is out of date and shows the legacy method for smart contract deployment. -For the latest recommended method, use [op-deployer](/builders/chain-operators/tools/op-deployer). + + Standard OP Stack chains must use the latest governance approved and audited versions of the smart contract code. The following guide shows you how to deploy the OP Stack L1 smart contracts. @@ -19,29 +18,28 @@ official contract releases**. You can visit the see the [smart contract overview for the official release versions. Changes to the smart contracts are generally not considered backwards compatible. - - Standard OP Stack chains should use the latest governance approved and audited versions of the smart contract code. + +The following deployment information outlines the legacy method for deploying the OP Stack L1 contracts. +This method is not recommended and is provided here only for historical context. -## Deployment configuration +## Deployment Configuration + +To deploy OP Stack contracts, you need to create a deployment configuration JSON file. +The file should be placed in the following monorepo subdirectory: [packages/contracts-bedrock/deploy-config](https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts-bedrock/deploy-config). -Deploying your OP Stack contracts requires creating a deployment configuration -JSON file. You will create a new deployment configuration file in the following -monorepo subdirectory: [packages/contracts-bedrock/deploy-config](https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts-bedrock/deploy-config) -For the full set of deployment configuration options and their meanings, you -can see the [rollup deployment configuration page](/builders/chain-operators/configuration/rollup). +For a detailed explanation of the configuration options and their meanings, refer to the [rollup deployment configuration page](/builders/chain-operators/configuration/rollup). -## Deployment script +## Deployment script (Legacy Method) -The smart contracts are deployed using [foundry](https://github.com/foundry-rs) -and you can find the script's source code in the monorepo at +The legacy method for deploying smart contracts uses [foundry](https://github.com/foundry-rs) and the deployment script located in the monorepo at [packages/contracts-bedrock/scripts/deploy/Deploy.s.sol](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol). ### State diff -Before deploying the contracts, you can verify the state diff by using the `runWithStateDiff()` function signature in the deployment script, which produces -the outputs inside [`snapshots/state-diff/`](https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts-bedrock/snapshots/state-diff). -Run the deployment with state diffs by executing: +You can verify the state diff before deploying the contracts by using the `runWithStateDiff()` function in the deployment script. +This produces outputs in [`snapshots/state-diff/`](https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts-bedrock/snapshots/state-diff). +Run the deployment with state diffs using the following command: ```bash forge script -vvv scripts/deploy/Deploy.s.sol:Deploy --sig 'runWithStateDiff()' --rpc-url $ETH_RPC_URL --broadcast --private-key $PRIVATE_KEY @@ -82,6 +80,52 @@ All functions for deploying a single contract are public, meaning that the `--sig` argument to forge script can be used to target the deployment of a single contract. + +## Using `op-deployer` + +The recommended way to deploy the L1 smart contracts is with the `op-deployer` tool. +Follow these steps: + + +{

Set Up Your Environment

} + +* Install `op-deployer`: + The recommended way to install `op-deployer` is to download the latest release from the monorepo's + [release page](https://github.com/ethereum-optimism/optimism/releases). To install a release, download the binary + for your platform then extract it somewhere on your `PATH`. +* Access to the L1 blockchain (e.g., Sepolia or Mainnet) via an RPC URL. +* A private key with sufficient funds to cover deployment costs. + + +### Create an intent file + +* Define the configuration of your chain in an intent file. +* This file specifies the deployment parameters for both L1. +Follow the instructions provided in the [configure your chain](/builders/chain-operators/tools/op-deployer#init-configure-your-chain) section to generate the intent file. + +### Run the `apply` command + +The next step is to deploy the L1 smart contracts, by running the following command: + +```bash +./bin/op-deployer apply --workdir .deployer --l1-rpc-url --private-key +``` +* Replace `` with your L1 RPC URL. +* Replace `` with the private key of the account used for deployment. + +### Verify the deployment +Once the deployment is complete, you can verify the deployed contract addresses and configuration: + +* Check the deployment output for contract addresses and transaction details. +* Verify the deployed contracts on the block explorer using the specified `ETHERSCAN_API_KEY` in the configuration file. + +
+ + +If you need deterministic deployment (e.g., for deploying contracts at the same address across multiple chains), +use the `CREATE2` method. + + ## Best practices Production users should deploy their L1 contracts from a contracts release. diff --git a/pages/builders/chain-operators/tools/op-deployer.mdx b/pages/builders/chain-operators/tools/op-deployer.mdx index c611d27a6..0bd607436 100644 --- a/pages/builders/chain-operators/tools/op-deployer.mdx +++ b/pages/builders/chain-operators/tools/op-deployer.mdx @@ -15,7 +15,14 @@ import {Callout, Steps} from 'nextra/components' The recommended way to install `op-deployer` is to download the latest release from the monorepo's [release page](https://github.com/ethereum-optimism/optimism/releases). To install a release, download the binary -for your platform then extract it somewhere on your `PATH`. The rest of this tutorial will assume that you have +for your platform then extract it somewhere on your `PATH`. + +Run the following command: + ```bash + cd op-deployer && just build + ``` + +The rest of this tutorial will assume that you have installed `op-deployer` using this method. ## Deployment usage @@ -31,6 +38,7 @@ To get started with `op-deployer`, create an intent file that defines your desir ``` ./bin/op-deployer init --l1-chain-id 11155111 --l2-chain-ids --workdir .deployer ``` +Replace `` with the correct value. This command will create a directory called `.deployer` in your current working directory containing the intent file and an empty `state.json` file. `state.json` is populated with the results of your deployment, and never needs to be edited directly. @@ -97,8 +105,9 @@ You can also do chain by chain configurations in the `chains` table. Now that you've created your intent file, you can apply it to your chain to deploy the L1 smart contracts: ``` -op-deployer apply --workdir .deployer --l1-rpc-url --private-key +./bin/op-deployer apply --workdir .deployer --l1-rpc-url --private-key ``` +* Replace `` with your `L1_RPC_URL` and `` with your private key This command will deploy the OP Stack to L1. It will deploy all L2s specified in the intent file. Superchain configuration will be set to the Superchain-wide defaults - i.e., your chain will be opted into the [Superchain pause](https://specs.optimism.io/protocol/superchain-config.html#pausability) @@ -114,8 +123,8 @@ address as other chains on the Superchain. Inspect the `state.json` file by navigating to your working directory. With the contracts deployed, generate the genesis and rollup configuration files by running the following commands: ``` -op-deployer inspect genesis --workdir .deployer > .deployer/genesis.json -op-deployer inspect rollup --workdir .deployer > .deployer/rollup.json +./bin/op-deployer inspect genesis --workdir .deployer > .deployer/genesis.json +./bin/op-deployer inspect rollup --workdir .deployer > .deployer/rollup.json ``` 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: diff --git a/pages/builders/chain-operators/tutorials/create-l2-rollup.mdx b/pages/builders/chain-operators/tutorials/create-l2-rollup.mdx index 0090367f1..bc842239f 100644 --- a/pages/builders/chain-operators/tutorials/create-l2-rollup.mdx +++ b/pages/builders/chain-operators/tutorials/create-l2-rollup.mdx @@ -10,8 +10,6 @@ import { WipCallout } from '@/components/WipCallout' # Creating your own L2 rollup testnet - - Please **be prepared to set aside approximately one hour** to get everything running properly and **make sure to read through the guide carefully**. You don't want to miss any important steps that might cause issues down the line. @@ -419,71 +417,79 @@ cast codesize 0x4e59b44847b379578588920cA78FbF26c0B4956C --rpc-url $L1_RPC_URL Once you've configured your network, it's time to deploy the L1 contracts necessary for the functionality of the chain. +### Using `op-deployer` + +The recommended way to deploy the L1 smart contracts is with the `op-deployer` tool. +Follow these steps: + +{

Set Up Your Environment

} + +* Install `op-deployer`: + The recommended way to install `op-deployer` is to download the latest release from the monorepo's + [release page](https://github.com/ethereum-optimism/optimism/releases). To install a release, download the binary + for your platform then extract it somewhere on your `PATH`. +* Access to the L1 blockchain (e.g., Sepolia or Mainnet) via an RPC URL. +* A private key with sufficient funds to cover deployment costs. -{

Deploy the L1 contracts

} +### Create an intent file + +* Define the configuration of your chain in an intent file. +* This file specifies the deployment parameters for deploying the L1 smart contract. +Follow the instructions provided in the [configure your chain](/builders/chain-operators/tools/op-deployer#init-configure-your-chain) section to generate the intent file. + +### Run the `apply` command + +The next step is to deploy the L1 smart contracts, by running the following command: ```bash -forge script scripts/Deploy.s.sol:Deploy --private-key $GS_ADMIN_PRIVATE_KEY --broadcast --rpc-url $L1_RPC_URL --slow +./bin/op-deployer apply --workdir .deployer --l1-rpc-url --private-key ``` +* Replace `` with your L1 RPC URL. +* Replace `` with the private key of the account used for deployment. - -If you see a nondescript error that includes `EvmError: Revert` and `Script failed` then you likely need to change the `IMPL_SALT` environment variable. -This variable determines the addresses of various smart contracts that are deployed via [CREATE2](https://eips.ethereum.org/EIPS/eip-1014). -If the same `IMPL_SALT` is used to deploy the same contracts twice, the second deployment will fail. -**You can generate a new `IMPL_SALT` by running `direnv allow` anywhere in the Optimism Monorepo.** - +### Verify the deployment +Once the deployment is complete, you can verify the deployed contract addresses and configuration: + +* Check the deployment output for contract addresses and transaction details. +* Verify the deployed contracts on the block explorer using the specified `ETHERSCAN_API_KEY` in the configuration file.
## Generate the L2 config files -Now that you've set up the L1 smart contracts you can automatically generate several configuration files that are used within the Consensus Client and the Execution Client. +Now that you've set up the L1 smart contracts you can automatically generate several configuration files that are used within the consensus client and the execution client. -You need to generate three important files: +You need to generate two important files: 1. `genesis.json` includes the genesis state of the chain for the Execution Client. 2. `rollup.json` includes configuration information for the Consensus Client. -3. `jwt.txt` is a [JSON Web Token](https://jwt.io/introduction) that allows the Consensus Client and the Execution Client to communicate securely (the same mechanism is used in Ethereum clients). -{

Navigate to the op-node package

} - -```bash -cd ~/optimism/op-node -``` +{

Install op-deployer

} -{

Create genesis files

} - -Now you'll generate the `genesis.json` and `rollup.json` files within the `op-node` folder: - -```bash -go run cmd/main.go genesis l2 \ - --deploy-config ../packages/contracts-bedrock/deploy-config/getting-started.json \ - --l1-deployments ../packages/contracts-bedrock/deployments/getting-started/.deploy \ - --outfile.l2 genesis.json \ - --outfile.rollup rollup.json \ - --l1-rpc $L1_RPC_URL -``` + Ensure you have the `op-deployer` tool installed. + For installation instructions, see the [op-deployer installation section](/builders/chain-operators/tools/op-deployer#installation). -{

Create an authentication key

} +{

Generate configuration files

} -Next you'll create a [JSON Web Token](https://jwt.io/introduction) that will be used to authenticate the Consensus Client and the Execution Client. -This token is used to ensure that only the Consensus Client and the Execution Client can communicate with each other. -You can generate a JWT with the following command: +With the contracts deployed, generate the genesis and rollup configuration files by running the following commands: ```bash -openssl rand -hex 32 > jwt.txt +op-deployer inspect genesis --workdir .deployer > .deployer/genesis.json +op-deployer inspect rollup --workdir .deployer > .deployer/rollup.json ``` +Replace `` with the L2 chain ID. -{

Copy genesis files into the op-geth directory

} +{

Get data

} -Finally, you'll need to copy the `genesis.json` file and `jwt.txt` file into `op-geth` so you can use it to initialize and run `op-geth`: +Now that you have your `genesis.json` and `rollup.json` +you can use the following inspect subcommands to get additional data: ```bash -cp genesis.json ~/op-geth -cp jwt.txt ~/op-geth +op-deployer inspect l1 --workdir .deployer # outputs all L1 contract addresses for an L2 chain +op-deployer inspect deploy-config --workdir .deployer # outputs the deploy config for an L2 chain ```
diff --git a/words.txt b/words.txt index d17d59bbc..2319a4d23 100644 --- a/words.txt +++ b/words.txt @@ -94,6 +94,7 @@ DISABLETXPOOLGOSSIP disabletxpoolgossip Discv discv +disincentivize DIVU Drand dripcheck @@ -122,7 +123,6 @@ Farcaster Faultproof FDLIMIT fdlimit -featureset Flashblocks Flashbots forkable @@ -281,7 +281,6 @@ pprof Precommitments precommitments preconfigured -Preconfigured predeploy Predeployed predeployed @@ -377,7 +376,6 @@ Superchain superchain Superchain's Superchainerc -superchainerc Superchains Superscan Supersim @@ -410,7 +408,6 @@ unmetered Unprotect unsubmitted UPNP -usafe VERKLE verkle VHOSTS