2023-04-05 04:55:50 +00:00
# fixturenet-optimism
Instructions to setup and deploy L2 fixturenet using [Optimism ](https://stack.optimism.io )
## Setup
Prerequisite: An L1 Ethereum RPC endpoint
Clone required repositories:
```bash
laconic-so --stack fixturenet-optimism setup-repositories --exclude cerc-io/go-ethereum
2023-04-11 10:51:03 +00:00
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
2023-04-05 04:55:50 +00:00
```
Checkout to the required versions and branches in repos:
```bash
# Optimism
cd ~/cerc/optimism
git checkout @eth -optimism/sdk@0.0.0-20230329025055
```
Build the container images:
```bash
laconic-so --stack fixturenet-optimism build-containers --include cerc/foundry,cerc/optimism-contracts,cerc/optimism-op-node,cerc/optimism-l2geth,cerc/optimism-op-batcher
```
This should create the required docker images in the local image registry:
* `cerc/foundry`
* `cerc/optimism-contracts`
* `cerc/optimism-l2geth`
* `cerc/optimism-op-batcher`
* `cerc/optimism-op-node`
## Deploy
2023-04-11 10:51:03 +00:00
Create and update an env file to be used in the next step ([defaults](../../config/fixturenet-optimism/l1-params.env)):
```bash
# External L1 endpoint
CERC_L1_CHAIN_ID=
CERC_L1_RPC=
CERC_L1_HOST=
CERC_L1_PORT=
2023-04-20 09:42:59 +00:00
# URL to get CSV with credentials for accounts on L1
# that are used to send balance to Optimism Proxy contract
2023-04-11 10:51:03 +00:00
# (enables them to do transactions on L2)
2023-04-20 09:42:59 +00:00
CERC_L1_ACCOUNTS_CSV_URL=
# OR
# Specify the required account credentials
2023-04-11 10:51:03 +00:00
CERC_L1_ADDRESS=
CERC_L1_PRIV_KEY=
CERC_L1_ADDRESS_2=
CERC_L1_PRIV_KEY_2=
```
2023-04-05 04:55:50 +00:00
2023-04-11 10:51:03 +00:00
* NOTE: If L1 is running on the host machine, use `host.docker.internal` as the hostname to access the host port
2023-04-05 04:55:50 +00:00
Deploy the stack:
```bash
2023-04-11 10:51:03 +00:00
laconic-so --stack fixturenet-optimism deploy --include fixturenet-optimism --env-file < PATH_TO_ENV_FILE > up
2023-04-05 04:55:50 +00:00
```
The `fixturenet-optimism-contracts` service may take a while (`~15 mins`) to complete running as it:
1. waits for the 'Merge' to happen on L1
2. waits for a finalized block to exist on L1 (so that it can be taken as a starting block for roll ups)
3. deploys the L1 contracts
To list down and monitor the running containers:
```bash
2023-04-05 11:56:38 +00:00
laconic-so --stack fixturenet-optimism deploy --include fixturenet-optimism ps
2023-04-05 04:55:50 +00:00
# With status
docker ps
# Check logs for a container
docker logs -f < CONTAINER_ID >
```
## Clean up
Stop all services running in the background:
```bash
2023-04-11 10:51:03 +00:00
laconic-so --stack fixturenet-optimism deploy --include fixturenet-optimism down
2023-04-05 04:55:50 +00:00
```
Clear volumes created by this stack:
```bash
# List all relevant volumes
2023-04-20 09:42:59 +00:00
docker volume ls -q --filter "name=.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data"
2023-04-05 04:55:50 +00:00
# Remove all the listed volumes
2023-04-20 09:42:59 +00:00
docker volume rm $(docker volume ls -q --filter "name=.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
2023-04-05 04:55:50 +00:00
```
## Troubleshooting
2023-04-11 10:51:03 +00:00
See [Troubleshooting ](./README.md#troubleshooting )