Archived
update fixturenet-optimism
This commit is contained in:
@@ -12,6 +12,7 @@ Clone required repositories:
|
||||
laconic-so --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 the repositories mentioned below and re-run the command
|
||||
# The repositories are located in $HOME/cerc by default
|
||||
```
|
||||
|
||||
Build the container images:
|
||||
@@ -39,20 +40,53 @@ This should create the required docker images in the local image registry:
|
||||
* `cerc/optimism-op-batcher`
|
||||
* `cerc/optimism-op-proposer`
|
||||
|
||||
## Deploy
|
||||
|
||||
Deploy the stack:
|
||||
## 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 fixturenet-optimism deploy up
|
||||
laconic-so --stack fixturenet-optimism deploy init --map-ports-to-host any-fixed-random --output fixturenet-optimism-spec.yml
|
||||
```
|
||||
|
||||
The `fixturenet-optimism-contracts` service takes a while 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
|
||||
It may restart a few times after running into errors.
|
||||
### Ports
|
||||
It is usually necessary to expose certain container ports on one or more the host's addresses to allow incoming connections.
|
||||
Any ports defined in the Docker compose file are exposed by default with random port assignments, bound to "any" interface (IP address 0.0.0.0), but the port mappings can be customized by editing the "spec" file generated by `laconic-so deploy init`.
|
||||
|
||||
In addition, a stack-wide port mapping "recipe" can be applied at the time the
|
||||
`laconic-so deploy init` command is run, by supplying the desired recipe with the `--map-ports-to-host` option. The following recipes are supported:
|
||||
| Recipe | Host Port Mapping |
|
||||
|--------|-------------------|
|
||||
| any-variable-random | Bind to 0.0.0.0 using a random port assigned at start time (default) |
|
||||
| localhost-same | Bind to 127.0.0.1 using the same port number as exposed by the containers |
|
||||
| any-same | Bind to 0.0.0.0 using the same port number as exposed by the containers |
|
||||
| localhost-fixed-random | Bind to 127.0.0.1 using a random port number selected at the time the command is run (not checked for already in use)|
|
||||
| any-fixed-random | Bind to 0.0.0.0 using a random port number selected at the time the command is run (not checked for already in use) |
|
||||
|
||||
For example, you may wish to use `any-fixed-random` to generate the initial mappings and then edit the spec file to set the `fixturenet-eth-geth-1` RPC to port 8545 and the `op-geth` RPC to port 9545 on the host.
|
||||
|
||||
Or, you may wish to use `any-same` for the initial mappings -- in which case you'll have to edit the spec to file to ensure the various geth instances aren't all trying to publish to host ports 8545/8546 at once.
|
||||
|
||||
### Data volumes
|
||||
Container data volumes are bind-mounted to specified paths in the host filesystem.
|
||||
The default setup (generated by `laconic-so deploy init`) places the volumes in the `./data` subdirectory of the deployment directory. The default mappings 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 fixturenet-optimism deploy create --spec-file fixturenet-optimism-spec.yml --deployment-dir fixturenet-optimism-deployment
|
||||
```
|
||||
|
||||
## Start the stack
|
||||
Start the deployment:
|
||||
```bash
|
||||
laconic-so deployment --dir fixturenet-optimism-deployment start
|
||||
```
|
||||
1. The `fixturenet-eth` L1 chain will start up first and begin producing blocks.
|
||||
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
|
||||
@@ -65,22 +99,69 @@ docker ps
|
||||
docker logs -f <CONTAINER_ID>
|
||||
```
|
||||
|
||||
## Clean up
|
||||
## Example: bridge some ETH from L1 to L2
|
||||
|
||||
Stop all services running in the background:
|
||||
Send some ETH from the desired account to the `L1StandardBridgeProxy` contract on L1 to test bridging to L2.
|
||||
|
||||
We can use the testing account `0xe6CE22afe802CAf5fF7d3845cec8c736ecc8d61F` which is pre-funded and unlocked, and the `cerc/foundry:local` container to make use of the `cast` cli.
|
||||
|
||||
1. Note the docker network the stack is running on:
|
||||
```bash
|
||||
laconic-so --stack fixturenet-optimism deploy down 30
|
||||
docker network ls
|
||||
# The network name will be something like laconic-[some_hash]_default
|
||||
```
|
||||
2. Set some variables:
|
||||
```bash
|
||||
L1_RPC=http://fixturenet-eth-geth-1:8545
|
||||
L2_RPC=http://op-geth:8545
|
||||
NETWORK=<the network name found above>
|
||||
DEPLOYMENT_CONTEXT=<L1 chain-id; 1212 by default>
|
||||
ACCOUNT=0xe6CE22afe802CAf5fF7d3845cec8c736ecc8d61F
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
If you need to check the L1 chain-id, you can use:
|
||||
```bash
|
||||
docker run --rm --network $NETWORK cerc/foundry:local "cast chain-id --rpc-url $L1_RPC"
|
||||
```
|
||||
|
||||
3. Check the account starting balance on L2 (it should be 0):
|
||||
```bash
|
||||
docker run --rm --network $NETWORK cerc/foundry:local "cast balance $ACCOUNT --rpc-url $L2_RPC"
|
||||
# 0
|
||||
```
|
||||
|
||||
4. Read the bridge contract address from the L1 deployment records in the `op-node` container:
|
||||
```bash
|
||||
# get the container id for op-node
|
||||
NODE_CONTAINER=$(docker ps --filter "name=op-node" -q)
|
||||
BRIDGE=$(docker exec $NODE_CONTAINER cat /l1-deployment/$DEPLOYMENT_CONTEXT/L1StandardBridgeProxy.json | jq -r .address)
|
||||
```
|
||||
|
||||
5. Use cast to send some ETH to the bridge contract:
|
||||
```bash
|
||||
docker run --rm --network $NETWORK cerc/foundry:local "cast send --from $ACCOUNT --value 1ether $BRIDGE --rpc-url $L1_RPC"
|
||||
```
|
||||
|
||||
6. Allow a couple minutes for the bridge to complete
|
||||
|
||||
7. Check the L2 balance again (it should show the bridged funds):
|
||||
```bash
|
||||
docker run --rm --network $NETWORK cerc/foundry:local "cast balance $ACCOUNT --rpc-url $L2_RPC"
|
||||
# 1000000000000000000
|
||||
```
|
||||
|
||||
## Clean up
|
||||
|
||||
To stop all services running in the background, while preserving chain data:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter "name=.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data"
|
||||
laconic-so deployment --dir fixturenet-optimism-deployment stop
|
||||
```
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter "name=.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
|
||||
To stop all services and also delete chain data:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir fixturenet-optimism-deployment stop --delete-volumes
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# Copyright © 2023 Vulcanize
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
from app.deploy.deploy_types import DeployCommandContext, LaconicStackSetupCommand, DeploymentContext
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
def create(context: DeploymentContext, extra_args):
|
||||
# Slightly modify the base fixturenet-eth compose file to replace the startup script for fixturenet-eth-geth-1
|
||||
# We need to start geth with the flag to allow non eip-155 compliant transactions in order to publish the
|
||||
# deterministic-deployment-proxy contract, which itself is a prereq for Optimism contract deployment
|
||||
fixturenet_eth_compose_file = context.deployment_dir.joinpath('compose', 'docker-compose-fixturenet-eth.yml')
|
||||
|
||||
with open(fixturenet_eth_compose_file, 'r') as yaml_file:
|
||||
yaml=YAML()
|
||||
yaml_data = yaml.load(yaml_file)
|
||||
|
||||
new_script = '../config/fixturenet-optimism/run-geth.sh:/opt/testnet/run.sh'
|
||||
|
||||
if new_script not in yaml_data['services']['fixturenet-eth-geth-1']['volumes']:
|
||||
yaml_data['services']['fixturenet-eth-geth-1']['volumes'].append(new_script)
|
||||
|
||||
with open(fixturenet_eth_compose_file, 'w') as yaml_file:
|
||||
yaml=YAML()
|
||||
yaml.dump(yaml_data, yaml_file)
|
||||
|
||||
return None
|
||||
@@ -1,4 +1,4 @@
|
||||
# fixturenet-optimism
|
||||
# fixturenet-optimism (L2-only)
|
||||
|
||||
Instructions to setup and deploy L2 fixturenet using [Optimism](https://stack.optimism.io)
|
||||
|
||||
@@ -28,9 +28,43 @@ This should create the required docker images in the local image registry:
|
||||
* `cerc/optimism-op-batcher`
|
||||
* `cerc/optimism-op-proposer`
|
||||
|
||||
## Deploy
|
||||
## Create a deployment
|
||||
|
||||
Create and update an env file to be used in the next step ([defaults](../../config/fixturenet-optimism/l1-params.env)):
|
||||
First, create a spec file for the deployment, which will map the stack's ports and volumes to the host:
|
||||
```bash
|
||||
laconic-so --stack fixturenet-optimism deploy init --map-ports-to-host any-fixed-random --output fixturenet-optimism-spec.yml
|
||||
```
|
||||
### Ports
|
||||
It is usually necessary to expose certain container ports on one or more the host's addresses to allow incoming connections.
|
||||
Any ports defined in the Docker compose file are exposed by default with random port assignments, bound to "any" interface (IP address 0.0.0.0), but the port mappings can be customized by editing the "spec" file generated by `laconic-so deploy init`.
|
||||
|
||||
In addition, a stack-wide port mapping "recipe" can be applied at the time the
|
||||
`laconic-so deploy init` command is run, by supplying the desired recipe with the `--map-ports-to-host` option. The following recipes are supported:
|
||||
| Recipe | Host Port Mapping |
|
||||
|--------|-------------------|
|
||||
| any-variable-random | Bind to 0.0.0.0 using a random port assigned at start time (default) |
|
||||
| localhost-same | Bind to 127.0.0.1 using the same port number as exposed by the containers |
|
||||
| any-same | Bind to 0.0.0.0 using the same port number as exposed by the containers |
|
||||
| localhost-fixed-random | Bind to 127.0.0.1 using a random port number selected at the time the command is run (not checked for already in use)|
|
||||
| any-fixed-random | Bind to 0.0.0.0 using a random port number selected at the time the command is run (not checked for already in use) |
|
||||
|
||||
For example, you may wish to use `any-fixed-random` to generate the initial mappings and then edit the spec file to set the `op-geth` RPC to an easy to remember port like 8545 or 9545 on the host.
|
||||
|
||||
### Data volumes
|
||||
Container data volumes are bind-mounted to specified paths in the host filesystem.
|
||||
The default setup (generated by `laconic-so deploy init`) places the volumes in the `./data` subdirectory of the deployment directory. The default mappings 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 fixturenet-optimism deploy create --spec-file fixturenet-optimism-spec.yml --deployment-dir fixturenet-optimism-deployment
|
||||
```
|
||||
|
||||
Finally, open the `stack.yml` file inside your deployment directory and, under the `pods:` section, remove (or comment out) the entry for `fixturenet-eth`. This will prevent the deployment from trying to spin up a new L1 chain when starting the stack.
|
||||
|
||||
## 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
|
||||
@@ -45,30 +79,29 @@ Create and update an env file to be used in the next step ([defaults](../../conf
|
||||
CERC_L1_ACCOUNTS_CSV_URL=
|
||||
|
||||
# OR
|
||||
# Specify the required account credentials
|
||||
# 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=
|
||||
CERC_L1_ADDRESS_2=
|
||||
CERC_L1_PRIV_KEY_2=
|
||||
```
|
||||
|
||||
* NOTE: If L1 is running on the host machine, use `host.docker.internal` as the hostname to access the host port
|
||||
|
||||
Deploy the stack:
|
||||
* 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 --stack fixturenet-optimism deploy --include fixturenet-optimism --env-file <PATH_TO_ENV_FILE> up
|
||||
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
|
||||
|
||||
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:
|
||||
### Logs
|
||||
To list and monitor the running containers:
|
||||
|
||||
```bash
|
||||
laconic-so --stack fixturenet-optimism deploy --include fixturenet-optimism ps
|
||||
laconic-so --stack fixturenet-optimism deploy ps
|
||||
|
||||
# With status
|
||||
docker ps
|
||||
@@ -79,20 +112,16 @@ docker logs -f <CONTAINER_ID>
|
||||
|
||||
## Clean up
|
||||
|
||||
Stop all services running in the background:
|
||||
To stop all L2 services running in the background, while preserving chain data:
|
||||
|
||||
```bash
|
||||
laconic-so --stack fixturenet-optimism deploy --include fixturenet-optimism down 30
|
||||
laconic-so deployment --dir fixturenet-optimism-deployment stop
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
To stop all L2 services and also delete chain data:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter "name=.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data"
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter "name=.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
|
||||
laconic-so deployment --dir fixturenet-optimism-deployment stop --delete-volumes
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@@ -5,8 +5,8 @@ repos:
|
||||
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||
- git.vdb.to/cerc-io/lighthouse
|
||||
- github.com/dboreham/foundry
|
||||
- github.com/ethereum-optimism/optimism@v1.0.4
|
||||
- github.com/ethereum-optimism/op-geth@v1.101105.2
|
||||
- github.com/ethereum-optimism/optimism@op-node/v1.3.0
|
||||
- github.com/ethereum-optimism/op-geth@v1.101304.0
|
||||
containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
|
||||
Reference in New Issue
Block a user