Compare commits

...

10 Commits

Author SHA1 Message Date
c1b72e9054 Add op-node --log.level 2024-09-04 23:37:58 +08:00
f6cc95cd34 Enable granite 2024-09-04 23:37:58 +08:00
c7ca93417c Configure rpc kind from env 2024-09-04 23:37:58 +08:00
4b01f3de72 Update readme 2024-09-04 23:37:58 +08:00
b545868a97 Config L1, L2 block time, set poll intervals 2024-09-04 23:37:58 +08:00
d66b2b0d71 Fix docs 2024-09-04 23:37:58 +08:00
bf594011fb Script clean up 2024-09-04 23:37:58 +08:00
e7baf0bf08 Exec services in containers
allows forwarding of signals
2024-09-04 23:37:53 +08:00
133e9d5da2 op-geth needs state.scheme=hash for archive 2024-09-04 23:35:53 +08:00
14e4a725d6 Fix L2 alloc state dump
runWithStateDump instead of runWithAllUpgrades
2024-09-04 23:35:51 +08:00
9 changed files with 72 additions and 51 deletions

View File

@ -1,5 +1,3 @@
version: '3.7'
services:
# Generates and funds the accounts required when setting up the L2 chain (outputs to volume l2_accounts)
# Creates / updates the configuration for L1 contracts deployment
@ -10,13 +8,16 @@ services:
hostname: fixturenet-optimism-contracts
env_file:
- ../config/fixturenet-optimism/l1-params.env
- ../config/fixturenet-optimism/l2-params.env
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_L1_CHAIN_ID: ${CERC_L1_CHAIN_ID}
CERC_L1_RPC: ${CERC_L1_RPC}
CERC_L1_ACCOUNTS_CSV_URL: ${CERC_L1_ACCOUNTS_CSV_URL}
CERC_L1_ADDRESS: ${CERC_L1_ADDRESS}
CERC_L1_PRIV_KEY: ${CERC_L1_PRIV_KEY}
- CERC_SCRIPT_DEBUG
- CERC_L1_CHAIN_ID
- CERC_L1_RPC
- CERC_L1_ACCOUNTS_CSV_URL
- CERC_L1_ADDRESS
- CERC_L1_PRIV_KEY
- CERC_L1_BLOCK_TIME
- CERC_L2_BLOCK_TIME
volumes:
- ../config/network/wait-for-it.sh:/wait-for-it.sh
- ../config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh:/deploy-contracts.sh
@ -88,8 +89,10 @@ services:
env_file:
- ../config/fixturenet-optimism/l1-params.env
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_L1_RPC: ${CERC_L1_RPC}
- CERC_SCRIPT_DEBUG
- CERC_L1_RPC
- CERC_L1_RPC_KIND
- CERC_L1_BLOCK_TIME
volumes:
- ../config/fixturenet-optimism/run-op-node.sh:/run-op-node.sh
- l1_deployment:/l1-deployment:ro
@ -149,9 +152,10 @@ services:
env_file:
- ../config/fixturenet-optimism/l1-params.env
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_L1_RPC: ${CERC_L1_RPC}
CERC_L1_CHAIN_ID: ${CERC_L1_CHAIN_ID}
- CERC_SCRIPT_DEBUG
- CERC_L1_RPC
- CERC_L1_CHAIN_ID
- CERC_L1_BLOCK_TIME
volumes:
- ../config/network/wait-for-it.sh:/wait-for-it.sh
- ../config/fixturenet-optimism/run-op-proposer.sh:/run-op-proposer.sh

View File

@ -6,6 +6,12 @@ DEFAULT_CERC_L1_RPC="http://fixturenet-eth-geth-1:8545"
DEFAULT_CERC_L1_HOST="fixturenet-eth-geth-1"
DEFAULT_CERC_L1_PORT=8545
# Default block time matches L1 fixturenet config.
DEFAULT_CERC_L1_BLOCK_TIME=3
# This can optionally be set to a preset for common node providers like Infura, Alchemy, etc.
# Or, set to "any" to try all available methods.
DEFAULT_CERC_L1_RPC_KIND=standard
# 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)

View File

@ -0,0 +1,2 @@
# Default L2 block time. Must be <= L1 block time.
DEFAULT_CERC_L2_BLOCK_TIME=1

View File

@ -124,8 +124,9 @@ GS_SEQUENCER_ADDRESS=$SEQ \
L1_RPC_URL=$CERC_L1_RPC \
L1_CHAIN_ID=$CERC_L1_CHAIN_ID \
L2_CHAIN_ID=42069 \
L1_BLOCK_TIME=12 \
L2_BLOCK_TIME=2 \
L1_BLOCK_TIME=${CERC_L1_BLOCK_TIME:-$DEFAULT_CERC_L1_BLOCK_TIME} \
L2_BLOCK_TIME=${CERC_L2_BLOCK_TIME:-$DEFAULT_CERC_L2_BLOCK_TIME} \
GRANITE_TIME_OFFSET=None \
$config_build_script
echo "Writing deployment config."
@ -164,19 +165,17 @@ echo "Generating L2 genesis allocs..."
L2_CHAIN_ID=$(jq ".l2ChainID" $deploy_config_file)
DEPLOY_CONFIG_PATH=$deploy_config_file \
CONTRACT_ADDRESSES_PATH=deployments/$DEPLOYMENT_CONTEXT-deploy.json \
forge script --chain-id $L2_CHAIN_ID scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithAllUpgrades()' --private-key $ADMIN_KEY
STATE_DUMP_PATH=allocs-l2.json \
forge script --chain-id $L2_CHAIN_ID scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithStateDump()' --private-key $ADMIN_KEY
OPTIMISM_ROOT=/opt/optimism
cp $OPTIMISM_ROOT/contracts-bedrock/state-dump-$L2_CHAIN_ID.json allocs-l2.json
echo "Done."
echo "*************************************"
# Copy files needed by other containers to the appropriate shared volumes
echo "Copying deployment artifacts volume l1_deployment and deploy-config to volume l2_config"
cp $OPTIMISM_ROOT/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT-deploy.json /l1-deployment
cp $OPTIMISM_ROOT/packages/contracts-bedrock/deploy-config/$DEPLOYMENT_CONTEXT.json /l2-config
cp /opt/optimism/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT-deploy.json /l1-deployment
cp /opt/optimism/packages/contracts-bedrock/deploy-config/$DEPLOYMENT_CONTEXT.json /l2-config
cp allocs-l2.json /l2-config
openssl rand -hex 32 > /l2-config/l2-jwt.txt
echo "Deployment successful. Exiting"
echo "Deployment successful, exiting."

View File

@ -11,7 +11,7 @@ L2_RPC="http://op-geth:8545"
ROLLUP_RPC="http://op-node:8547"
BATCHER_KEY=$(cat /l2-accounts/accounts.json | jq -r .BatcherKey)
op-batcher \
exec op-batcher \
--l2-eth-rpc=$L2_RPC \
--rollup-rpc=$ROLLUP_RPC \
--poll-interval=1s \

View File

@ -26,13 +26,13 @@ fi
# Initialize geth from our generated L2 genesis file (if not already initialized)
data_dir="/datadir"
if [ ! -d "$datadir/geth" ]; then
geth init --datadir=$data_dir $l2_genesis_file
geth init --datadir=$data_dir --state.scheme=hash $l2_genesis_file
fi
# Start op-geth
jwt_file="/l2-config/l2-jwt.txt"
geth \
exec geth \
--datadir=$data_dir \
--http \
--http.corsdomain="*" \
@ -45,6 +45,7 @@ geth \
--ws.origins="*" \
--ws.api=debug,eth,txpool,net,engine \
--syncmode=full \
--state.scheme=hash \
--gcmode=archive \
--nodiscover \
--maxpeers=0 \

View File

@ -4,34 +4,36 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
CERC_L1_CHAIN_ID="${CERC_L1_CHAIN_ID:-${DEFAULT_CERC_L1_CHAIN_ID}}"
CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}"
DEPLOYMENT_CONTEXT="$CERC_L1_CHAIN_ID"
CERC_L1_RPC_KIND="${CERC_L1_RPC_KIND:-${DEFAULT_CERC_L1_RPC_KIND}}"
CERC_L1_BLOCK_TIME="${CERC_L1_BLOCK_TIME:-$DEFAULT_CERC_L1_BLOCK_TIME}"
deploy_config_file="/l2-config/$DEPLOYMENT_CONTEXT.json"
l1_deployment_file="/l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json"
l2_allocs_file="/l2-config/allocs-l2.json"
genesis_outfile="/l2-config/genesis.json"
rollup_outfile="/l2-config/rollup.json"
log_level=INFO
if [ -n "$CERC_LOG_LEVEL" ]; then
log_level="$CERC_LOG_LEVEL"
fi
# Start op-node
SEQ_KEY=$(cat /l2-accounts/accounts.json | jq -r .SeqKey)
rollup_config=/l2-config/rollup.json
seq_key=$(cat /l2-accounts/accounts.json | jq -r .SeqKey)
jwt_file=/l2-config/l2-jwt.txt
L2_AUTH="http://op-geth:8551"
RPC_KIND=any # this can optionally be set to a preset for common node providers like Infura, Alchemy, etc.
l2_auth="http://op-geth:8551"
op-node \
--l2=$L2_AUTH \
exec op-node \
--l2=$l2_auth \
--l2.jwt-secret=$jwt_file \
--sequencer.enabled \
--sequencer.l1-confs=5 \
--verifier.l1-confs=4 \
--rollup.config=$rollup_outfile \
--rollup.config=$rollup_config \
--rpc.addr=0.0.0.0 \
--rpc.port=8547 \
--p2p.disable \
--rpc.enable-admin \
--p2p.sequencer.key="${SEQ_KEY#0x}" \
--l1=$CERC_L1_RPC \
--l1.rpckind=$RPC_KIND \
--l1.beacon=http://fixturenet-eth-lighthouse-1:8001
--l1.rpckind=$CERC_L1_RPC_KIND \
--l1.beacon=http://fixturenet-eth-lighthouse-1:8001 \
--l1.http-poll-interval="${CERC_L1_BLOCK_TIME}s" \
--l1.epoch-poll-interval="$((CERC_L1_BLOCK_TIME * 32))s" \
--log.level="$log_level"

View File

@ -6,6 +6,7 @@ fi
CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}"
CERC_L1_CHAIN_ID="${CERC_L1_CHAIN_ID:-${DEFAULT_CERC_L1_CHAIN_ID}}"
CERC_L1_BLOCK_TIME="${CERC_L1_BLOCK_TIME:-${DEFAULT_CERC_L1_BLOCK_TIME}}"
DEPLOYMENT_CONTEXT="$CERC_L1_CHAIN_ID"
# Start op-proposer
@ -13,8 +14,8 @@ ROLLUP_RPC="http://op-node:8547"
PROPOSER_KEY=$(cat /l2-accounts/accounts.json | jq -r .ProposerKey)
L2OO_ADDR=$(cat /l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json | jq -r .L2OutputOracleProxy)
op-proposer \
--poll-interval=12s \
exec op-proposer \
--poll-interval="${CERC_L1_BLOCK_TIME}s" \
--rpc.port=8560 \
--rollup-rpc=$ROLLUP_RPC \
--l2oo-address="${L2OO_ADDR#0x}" \

View File

@ -68,7 +68,7 @@ laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism de
### Ports
It is usually necessary to expose certain container ports on one or more the host's addresses to allow incoming connections.
It is usually necessary to expose certain container ports on one or more of 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
@ -145,7 +145,7 @@ docker logs -f <CONTAINER_ID>
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.
We can use the testing account `0xe6CE22afe802CAf5fF7d3845cec8c736ecc8d61F` which is pre-funded and unlocked, and the `cerc/optimism-contracts:local` container to make use of the `cast` cli.
1. Note the docker network the stack is running on:
@ -164,16 +164,22 @@ We can use the testing account `0xe6CE22afe802CAf5fF7d3845cec8c736ecc8d61F` whic
ACCOUNT=0xe6CE22afe802CAf5fF7d3845cec8c736ecc8d61F
```
You can create an alias for running `cast` on the network:
```bash
alias op-cast="docker run --rm --network $NETWORK --entrypoint cast cerc/optimism-contracts:local"
```
If you need to check the L1 chain-id, you can use:
```bash
docker run --rm --network $NETWORK cerc/optimism-contracts:local "cast chain-id --rpc-url $L1_RPC"
op-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/optimism-contracts:local "cast balance $ACCOUNT --rpc-url $L2_RPC"
op-cast balance $ACCOUNT --rpc-url $L2_RPC
# 0
```
@ -182,8 +188,8 @@ We can use the testing account `0xe6CE22afe802CAf5fF7d3845cec8c736ecc8d61F` whic
```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/.deploy | jq -r .L1StandardBridgeProxy)
# get the bridge contract address
BRIDGE=$(docker exec $NODE_CONTAINER cat /l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json | jq -r .L1StandardBridgeProxy)
# get the funded account's pk
ACCOUNT_PK=$(docker exec $NODE_CONTAINER jq -r '.AdminKey' /l2-accounts/accounts.json)
```
@ -191,15 +197,15 @@ We can use the testing account `0xe6CE22afe802CAf5fF7d3845cec8c736ecc8d61F` whic
5. Use cast to send some ETH to the bridge contract:
```bash
docker run --rm --network $NETWORK cerc/optimism-contracts:local "cast send --from $ACCOUNT --value 1ether $BRIDGE --rpc-url $L1_RPC --private-key $ACCOUNT_PK"
op-cast send --from $ACCOUNT --value 1ether $BRIDGE --rpc-url $L1_RPC --private-key $ACCOUNT_PK
```
6. Allow a couple minutes for the bridge to complete
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/optimism-contracts:local "cast balance $ACCOUNT --rpc-url $L2_RPC"
op-cast balance $ACCOUNT --rpc-url $L2_RPC
# 1000000000000000000
```