|
| 1 | +--- |
| 2 | +title: Running a Local Network Environment |
| 3 | +lang: en-US |
| 4 | +description: This tutorial walks you through spinning up an OP Stack devnet chain. |
| 5 | +--- |
| 6 | + |
| 7 | +import {Callout, Steps} from 'nextra/components' |
| 8 | +import {WipCallout} from '@/components/WipCallout' |
| 9 | + |
| 10 | +# Running a Local Development Environment |
| 11 | + |
| 12 | +<Callout type="info"> |
| 13 | + This guide is currently under active development. If you run into any issues, please open an issue on |
| 14 | + [Github](https://github.com/ethereum-optimism/optimism). |
| 15 | +</Callout> |
| 16 | + |
| 17 | +This tutorial is **designed for developers** who want to learn about the OP Stack by spinning up a local OP Stack devnet. |
| 18 | +You'll perform the full deployment process, and **you'll end up with your very own OP Stack devnet**. |
| 19 | + |
| 20 | +It's useful to understand what each of these components does before |
| 21 | +you start deploying your chain. To learn about the different components please |
| 22 | +read the [deployment overview page](/builders/chain-operators/deploy/overview). |
| 23 | + |
| 24 | +You can use this devnet to experiment and perform tests, or you can choose to modify the chain to adapt it to your own needs. |
| 25 | +**The OP Stack is free and open source software licensed entirely under the MIT license**. You don't need permission from |
| 26 | +anyone to modify or deploy the stack in any configuration you want. |
| 27 | + |
| 28 | +<Callout type="warning"> |
| 29 | + Modifications to the OP Stack may prevent a chain from being able to benefit from aspects of the [Optimism |
| 30 | + Superchain](/stack/explainer). Make sure to check out the [Superchain Explainer](/stack/explainer) to learn more. |
| 31 | +</Callout> |
| 32 | + |
| 33 | +## Installing Dependencies |
| 34 | + |
| 35 | +| Dependency | Version | Version Check Command | |
| 36 | +| ------------------------------------------------- | -------- | --------------------- | |
| 37 | +| [docker](https://docs.docker.com/engine/install/) | `^27` | `docker --version` | |
| 38 | +| [kurtosis](https://docs.kurtosis.com/install/) | `^1.3.0` | `kurtosis version` | |
| 39 | + |
| 40 | +### Notes on Specific Dependencies |
| 41 | + |
| 42 | +#### `docker` |
| 43 | + |
| 44 | +We recommend using the latest version of Docker on Linux, or [OrbStack](https://orbstack.dev/) (a drop-in replacement |
| 45 | +for Docker Desktop) on OSX. |
| 46 | + |
| 47 | +#### `kurtosis` |
| 48 | + |
| 49 | +Kurtosis is a tool for packaging and deploying containerized services. It's used in this tutorial to automatically deploy |
| 50 | +your devnet in an isolated environment. |
| 51 | + |
| 52 | +## Configure your network |
| 53 | + |
| 54 | +Now that you've installed all the necessary dependencies, you can start configuring your network. The Kurtosis package |
| 55 | +accepts a YAML file which configures how many network participants there are, what kind of software they're running, and |
| 56 | +the network's topology. An example YAML file is below: |
| 57 | + |
| 58 | +```yaml |
| 59 | +optimism_package: |
| 60 | + chains: # you can define multiple L2s, which will be deployed against the same L1 as a single Superchain |
| 61 | + - participants: # each participant is a node in the network. here we've defined two, one running op-geth and one running op-reth |
| 62 | + - el_type: op-geth # this node will be the sequencer since it's first in the list |
| 63 | + - el_type: op-reth |
| 64 | + network_params: |
| 65 | + name: rollup-1 # can be anything as long as it is unique |
| 66 | + network_id: 12345 # can be anything as long as it is unique |
| 67 | +``` |
| 68 | +
|
| 69 | +Save the above configuration to a file. For the rest of this tutorial, we'll assume you've saved it to `network-config.yaml`. |
| 70 | + |
| 71 | +## Start your network |
| 72 | + |
| 73 | +Now that you've configured your network, you can start it up using the Kurtosis CLI. Run the command below: |
| 74 | + |
| 75 | +```bash |
| 76 | +kurtosis run github.com/ethpandaops/optimism-package --args-file ./network-config.yaml |
| 77 | +``` |
| 78 | + |
| 79 | +This command will start up your network and deploy the OP Stack based on the configuration you created. The command will |
| 80 | +produce a lot of output and will take about five minutes to complete. Once it's done, you'll see a message that looks like |
| 81 | +the one below: |
| 82 | + |
| 83 | +``` |
| 84 | +INFO[2024-09-23T00:31:29-06:00] =================================================== |
| 85 | +INFO[2024-09-23T00:31:29-06:00] || Created enclave: blue-marsh || |
| 86 | +INFO[2024-09-23T00:31:29-06:00] =================================================== |
| 87 | +Name: blue-marsh |
| 88 | +UUID: 91af529557cb |
| 89 | +Status: RUNNING |
| 90 | +Creation Time: Mon, 23 Sep 2024 00:29:58 MDT |
| 91 | +Flags: |
| 92 | +
|
| 93 | +========================================= Files Artifacts ========================================= |
| 94 | +UUID Name |
| 95 | +a5824b041b28 1-lighthouse-geth-0-63-0 |
| 96 | +f7c0e13e9871 el_cl_genesis_data |
| 97 | +bfa022049aea final-genesis-timestamp |
| 98 | +0b5c53e3940f genesis-el-cl-env-file |
| 99 | +46a78cc34966 genesis_validators_root |
| 100 | +038ad1a753ed jwt_file |
| 101 | +4fbc4bde03c2 keymanager_file |
| 102 | +c36887606978 op-deployer-configs |
| 103 | +d638c3222e56 op-deployer-fund-script |
| 104 | +b02f20c287ac op_jwt_filerollup-1 |
| 105 | +655d57862785 prysm-password |
| 106 | +28203054f5ec validator-ranges |
| 107 | +
|
| 108 | +========================================== User Services ========================================== |
| 109 | +UUID Name Ports Status |
| 110 | +29643e475cb7 cl-1-lighthouse-geth http: 4000/tcp -> http://127.0.0.1:33639 RUNNING |
| 111 | + metrics: 5054/tcp -> http://127.0.0.1:33640 |
| 112 | + tcp-discovery: 9000/tcp -> 127.0.0.1:33641 |
| 113 | + udp-discovery: 9000/udp -> 127.0.0.1:32920 |
| 114 | +e7dfdc2588ae el-1-geth-lighthouse engine-rpc: 8551/tcp -> 127.0.0.1:33636 RUNNING |
| 115 | + metrics: 9001/tcp -> http://127.0.0.1:33637 |
| 116 | + rpc: 8545/tcp -> 127.0.0.1:33634 |
| 117 | + tcp-discovery: 30303/tcp -> 127.0.0.1:33638 |
| 118 | + udp-discovery: 30303/udp -> 127.0.0.1:32919 |
| 119 | + ws: 8546/tcp -> 127.0.0.1:33635 |
| 120 | +5ff43094ccc3 op-batcher-rollup-1 http: 8548/tcp -> http://127.0.0.1:33650 RUNNING |
| 121 | +aa30d376acc9 op-cl-1-op-node-op-geth-rollup-1 http: 8547/tcp -> http://127.0.0.1:33648 RUNNING |
| 122 | + tcp-discovery: 9003/tcp -> 127.0.0.1:33649 |
| 123 | + udp-discovery: 9003/udp -> 127.0.0.1:32922 |
| 124 | +af4abdbbe939 op-el-1-op-geth-op-node-rollup-1 engine-rpc: 8551/tcp -> 127.0.0.1:33645 RUNNING |
| 125 | + metrics: 9001/tcp -> 127.0.0.1:33646 |
| 126 | + rpc: 8545/tcp -> http://127.0.0.1:33643 |
| 127 | + tcp-discovery: 30303/tcp -> 127.0.0.1:33647 |
| 128 | + udp-discovery: 30303/udp -> 127.0.0.1:32921 |
| 129 | + ws: 8546/tcp -> 127.0.0.1:33644 |
| 130 | +578ee2b5bfe7 validator-key-generation-cl-validator-keystore <none> RUNNING |
| 131 | +aa69f73e96c1 vc-1-geth-lighthouse metrics: 8080/tcp -> http://127.0.0.1:33642 RUNNING |
| 132 | +``` |
| 133 | + |
| 134 | +Also take note of the last log line above this message, which contains the address of the standard bridge. You'll |
| 135 | +need this address to deposit funds on your L2. |
| 136 | + |
| 137 | +This might look complicated, but it's just a list of the services that were started up by Kurtosis. For each service, you |
| 138 | +can see: |
| 139 | + |
| 140 | +* The enclave name, which identifies the services you just deployed within Kurtosis. The enclave is an isolated environment |
| 141 | + that runs your devnet. |
| 142 | +* The service's name, which you can use with the Kurtosis CLI to view its logs and interact with it. |
| 143 | +* The service's ports and addresses, which you can use to connect to the service. |
| 144 | + |
| 145 | +At this point your chain is up and running. Let's move on to the next section to learn how to interact with it. |
| 146 | + |
| 147 | +## Interact with your network |
| 148 | + |
| 149 | +You now have a fully functioning OP Stack Rollup. You can connect your wallet to this chain the same way you'd connect |
| 150 | +your wallet to any other EVM chain. You can find your node's RPC URL by running `kurtosis enclave inspect <enclave name>`. |
| 151 | +Your enclave name is outputted at the end of the `kurtosis run` command above. The RPC url is the `rpc` port name in any |
| 152 | +of the execution client services identified by `op-el`. |
| 153 | + |
| 154 | +### Depositing funds onto your network |
| 155 | + |
| 156 | +Your network was configured to pre-fund development addresses using the `test test test test test test test test test test test junk` |
| 157 | +mnemonic. To get ETH onto your L2, you import one of the private keys from that mnemonic into your favorite wallet or use |
| 158 | +a CLI tool like `cast`. For the purposes of this tutorial, we'll use `cast` and assume you want to use the first address |
| 159 | +generated by that mnemonic. |
| 160 | + |
| 161 | +To move ETH onto your L2, run the following command. Make sure to replace the values in angle brackets with real values: |
| 162 | + |
| 163 | +```bash |
| 164 | +cast send --mnemonic 'test test test test test test test test test test test junk' --mnemonic-path "m/44'/60'/0'/0/0" \ |
| 165 | + --to "<standard bridge address>" --amount "<amount in ETH>eth" --rpc-url "http://127.0.0.1:<rpc port of el-1-geth-lighthouse service>" |
| 166 | +``` |
| 167 | + |
| 168 | +Wait \~30 seconds, then check your balance on L2 by running the following command: |
| 169 | + |
| 170 | +```bash |
| 171 | +export ETH_RPC_URL="http://127.0.0.1:<rpc port of el-1-geth-lighthouse service>" |
| 172 | +export ADDRESS="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" |
| 173 | +cast balance "$ADDRESS" |
| 174 | +``` |
| 175 | + |
| 176 | +Your balance should match the amount you sent. |
| 177 | + |
| 178 | +## See Your Rollup in Action |
| 179 | + |
| 180 | +You can interact with your Rollup the same way you'd interact with any other EVM chain. |
| 181 | +Send some transactions, deploy some contracts, and see what happens! |
| 182 | + |
| 183 | +## Next Steps |
| 184 | + |
| 185 | +* You can [modify the blockchain in various ways](../hacks/overview). |
| 186 | +* Check out the [protocol specs](https://specs.optimism.io/) for more detail about the rollup protocol. |
| 187 | +* If you run into any problems, please visit the [Chain Operators Troubleshooting Guide](../management/troubleshooting) |
| 188 | + or [file an issue](https://github.com/ethereum-optimism/optimism/issues) for help. |
0 commit comments