fixturenet-optimism-stack/config/fixturenet-optimism/generate-l2-config.sh

44 lines
1.3 KiB
Bash

#!/bin/bash
set -e
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"
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"
jwt_file="/l2-config/l2-jwt.txt"
# Create a JWT secret at shared path if not found
if [ ! -f "$jwt_file" ]; then
openssl rand -hex 32 > $jwt_file
echo "Generated JWT secret at $jwt_file"
fi
# Check if genesis.json and rollup.json already exist
if [ -f "$genesis_outfile" ] && [ -f "$rollup_outfile" ]; then
echo "Skipping generation, files already exist: $genesis_outfile, $rollup_outfile"
exit 0
fi
# If files don't exist, proceed with generation
echo "Generating l2 config files..."
op-node genesis l2 \
--deploy-config "$deploy_config_file" \
--l1-deployments "$l1_deployment_file" \
--l2-allocs "$l2_allocs_file" \
--outfile.l2 "$genesis_outfile" \
--outfile.rollup "$rollup_outfile" \
--l1-rpc "$CERC_L1_RPC"
echo "Generated the l2 config files successfully"
echo "Exiting"