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](cerc-io/fixturenet-eth-stacks#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: cerc-io/fixturenet-optimism-stack#1 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
4.1 KiB
fixturenet-optimism (L2-only)
Instructions to setup and deploy L2 fixturenet using Optimism
Prerequisite: An L1 Ethereum RPC endpoint (with unprotected txs enabled)
Setup
Clone the stack repo:
laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-optimism-stack
Clone required repositories:
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:
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:
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:
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):
# External L1 endpoint
CERC_L1_CHAIN_ID=
CERC_L1_RPC=
CERC_L1_HOST=
CERC_L1_PORT=
# 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=
- NOTE: If L1 is running on the host machine, use
host.docker.internal
as the hostname to access the host port, or use theip a
command to find the IP address of thedocker0
interface (this will usually be something like172.17.0.1
or172.18.0.1
)
Start the stack
Start the deployment:
laconic-so deployment --dir fixturenet-optimism-deployment start
- The stack will check for a response from the L1 endpoint specified in your env file
- 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) - The
op-node
andop-geth
services will initialize themselves (if not already initialized) and start - The remaining services,
op-batcher
andop-proposer
will start
Logs
To list and monitor the running containers:
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 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:
laconic-so deployment --dir fixturenet-optimism-deployment stop
To stop all L2 services and also delete chain data:
laconic-so deployment --dir fixturenet-optimism-deployment stop --delete-volumes
Troubleshooting
See Troubleshooting