fixturenet-optimism-stack/stack/fixturenet-optimism/l2-only.md

141 lines
4.3 KiB
Markdown
Raw Normal View History

Port over optimism stack and update to use latest releases (#1) Part of [Update Optimism stack to use Bedrock release](https://www.notion.so/Update-Optimism-stack-to-use-Bedrock-release-e44a490247724a6095a9fbc19fba3bcd) Requires [Add an option to allow unprotected txs in geth](https://git.vdb.to/cerc-io/fixturenet-eth-stacks/pulls/8) - Port over existing `fixturenet-optimism` stack components from SO - Use external [fixturenet-eth](https://git.vdb.to/cerc-io/fixturenet-eth-stacks/src/branch/main/stack-orchestrator/stacks/fixturenet-eth) stack for L1 - Use latest Optimism releases ([optimism@v1.7.4](https://github.com/ethereum-optimism/optimism/releases/tag/v1.7.4) and [op-geth@v1.101311.0](https://github.com/ethereum-optimism/op-geth/releases/tag/v1.101311.0)) - Update Optimism L1 contracts deployment script - Update L2 genesis generation - Remove override on L1 script to allow unprotected txs and unlock an account - `fixturenet-eth` stack itself now has an option to allow unprotected txs; the raw tx bytes for create2 proxy contract deployment from Optimism docs is not `EIP155` compatible - Use pk of funded account for txs instead of unlocking it - Add updated instructions - Use upstream [foundry](https://github.com/foundry-rs/foundry/pkgs/container/foundry/209507574?tag=nightly-267e14fab654d9ce955dce64c0eb09f01c8538ee) as base image for `cerc/optimism-contracts` container - Support for arm64/Apple Silicon to be handled in a follow-on PR Reviewed-on: https://git.vdb.to/cerc-io/fixturenet-optimism-stack/pulls/1 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-05-07 04:18:02 +00:00
# fixturenet-optimism (L2-only)
Instructions to setup and deploy L2 fixturenet using [Optimism](https://stack.optimism.io)
Prerequisite: An L1 Ethereum RPC endpoint (with unprotected txs enabled)
## Setup
Clone the stack repo:
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-optimism-stack
```
Clone required repositories:
```bash
laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism setup-repositories
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove concerned repositories and re-run the command
```
Build the container images:
```bash
laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism build-containers
```
This should create the required docker images in the local image registry:
* `cerc/optimism-contracts`
* `cerc/optimism-l2geth`
* `cerc/optimism-op-node`
* `cerc/optimism-op-batcher`
* `cerc/optimism-op-proposer`
## Create a deployment
First, create a spec file for the deployment, which will map the stack's ports and volumes to the host:
```bash
laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism deploy init --map-ports-to-host any-fixed-random --output fixturenet-optimism-spec.yml
```
### Ports and Data volumes
The default port and volume mappings to host can be customized by editing the "spec" file generated by `laconic-so deploy init`
---
Once you've made any needed changes to the spec file, create a deployment from it:
```bash
laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism deploy create --spec-file fixturenet-optimism-spec.yml --deployment-dir fixturenet-optimism-deployment
```
## Set chain env variables
Inside the deployment directory, open the file `config.env` and add the following variables to point the stack at your L1 rpc and provide account credentials ([defaults](../../config/fixturenet-optimism/l1-params.env)):
```bash
# External L1 endpoint
CERC_L1_CHAIN_ID=
CERC_L1_RPC=
CERC_L1_HOST=
CERC_L1_PORT=
# External L1 Beacon node endpoint
CERC_L1_BEACON=
Port over optimism stack and update to use latest releases (#1) Part of [Update Optimism stack to use Bedrock release](https://www.notion.so/Update-Optimism-stack-to-use-Bedrock-release-e44a490247724a6095a9fbc19fba3bcd) Requires [Add an option to allow unprotected txs in geth](https://git.vdb.to/cerc-io/fixturenet-eth-stacks/pulls/8) - Port over existing `fixturenet-optimism` stack components from SO - Use external [fixturenet-eth](https://git.vdb.to/cerc-io/fixturenet-eth-stacks/src/branch/main/stack-orchestrator/stacks/fixturenet-eth) stack for L1 - Use latest Optimism releases ([optimism@v1.7.4](https://github.com/ethereum-optimism/optimism/releases/tag/v1.7.4) and [op-geth@v1.101311.0](https://github.com/ethereum-optimism/op-geth/releases/tag/v1.101311.0)) - Update Optimism L1 contracts deployment script - Update L2 genesis generation - Remove override on L1 script to allow unprotected txs and unlock an account - `fixturenet-eth` stack itself now has an option to allow unprotected txs; the raw tx bytes for create2 proxy contract deployment from Optimism docs is not `EIP155` compatible - Use pk of funded account for txs instead of unlocking it - Add updated instructions - Use upstream [foundry](https://github.com/foundry-rs/foundry/pkgs/container/foundry/209507574?tag=nightly-267e14fab654d9ce955dce64c0eb09f01c8538ee) as base image for `cerc/optimism-contracts` container - Support for arm64/Apple Silicon to be handled in a follow-on PR Reviewed-on: https://git.vdb.to/cerc-io/fixturenet-optimism-stack/pulls/1 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-05-07 04:18:02 +00:00
# URL to get CSV with credentials for accounts on L1
# that are used to send balance to Optimism Proxy contract
# (enables them to do transactions on L2)
CERC_L1_ACCOUNTS_CSV_URL=
# OR
# Specify the required account credentials for the Admin account
# Other generated accounts will be funded from this account, so it should contain ~20 Eth
CERC_L1_ADDRESS=
CERC_L1_PRIV_KEY=
# Optional
# Funding amounts for proposer and batcher accounts on L1
# (Accounts funded using the Admin account)
CERC_PROPOSER_AMOUNT=
CERC_BATCHER_AMOUNT=
Port over optimism stack and update to use latest releases (#1) Part of [Update Optimism stack to use Bedrock release](https://www.notion.so/Update-Optimism-stack-to-use-Bedrock-release-e44a490247724a6095a9fbc19fba3bcd) Requires [Add an option to allow unprotected txs in geth](https://git.vdb.to/cerc-io/fixturenet-eth-stacks/pulls/8) - Port over existing `fixturenet-optimism` stack components from SO - Use external [fixturenet-eth](https://git.vdb.to/cerc-io/fixturenet-eth-stacks/src/branch/main/stack-orchestrator/stacks/fixturenet-eth) stack for L1 - Use latest Optimism releases ([optimism@v1.7.4](https://github.com/ethereum-optimism/optimism/releases/tag/v1.7.4) and [op-geth@v1.101311.0](https://github.com/ethereum-optimism/op-geth/releases/tag/v1.101311.0)) - Update Optimism L1 contracts deployment script - Update L2 genesis generation - Remove override on L1 script to allow unprotected txs and unlock an account - `fixturenet-eth` stack itself now has an option to allow unprotected txs; the raw tx bytes for create2 proxy contract deployment from Optimism docs is not `EIP155` compatible - Use pk of funded account for txs instead of unlocking it - Add updated instructions - Use upstream [foundry](https://github.com/foundry-rs/foundry/pkgs/container/foundry/209507574?tag=nightly-267e14fab654d9ce955dce64c0eb09f01c8538ee) as base image for `cerc/optimism-contracts` container - Support for arm64/Apple Silicon to be handled in a follow-on PR Reviewed-on: https://git.vdb.to/cerc-io/fixturenet-optimism-stack/pulls/1 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-05-07 04:18:02 +00:00
```
* NOTE: If L1 is running on the host machine, use `host.docker.internal` as the hostname to access the host port, or use the `ip a` command to find the IP address of the `docker0` interface (this will usually be something like `172.17.0.1` or `172.18.0.1`)
## Start the stack
Start the deployment:
```bash
laconic-so deployment --dir fixturenet-optimism-deployment start
```
1. The stack will check for a response from the L1 endpoint specified in your env file
2. The `fixturenet-optimism-contracts` service will configure and deploy the Optimism contracts to L1, exiting when complete. This may take several minutes; you can follow the progress by following the container's logs (see below)
3. The `op-node` and `op-geth` services will initialize themselves (if not already initialized) and start
4. The remaining services, `op-batcher` and `op-proposer` will start
### Logs
To list and monitor the running containers:
```bash
laconic-so --stack fixturenet-optimism deploy ps
# With status
docker ps
# Check logs for a container
docker logs -f <CONTAINER_ID>
```
## Example
Try out the [example](./README.md#example-bridge-some-eth-from-l1-to-l2) to bridge ETH from L1 to L2
Note: Use external L1 endpoint as `L1_RPC` and add flag `--add-host="host.docker.internal:host-gateway"` to `docker run` commands if necessary
## Clean up
To stop all L2 services running in the background, while preserving chain data:
```bash
laconic-so deployment --dir fixturenet-optimism-deployment stop
```
To stop all L2 services and also delete chain data:
```bash
laconic-so deployment --dir fixturenet-optimism-deployment stop --delete-volumes
```
## Troubleshooting
See [Troubleshooting](./README.md#troubleshooting)