Check for existing L2 geth data directory
This commit is contained in:
parent
6ac8d7f3f7
commit
2a2e52751a
@ -41,7 +41,7 @@ services:
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
# Initializes and runs the L2 execution client
|
||||
# Initializes and runs the L2 execution client (outputs to volume l2_geth_data)
|
||||
op-geth:
|
||||
image: cerc/optimism-l2geth:local
|
||||
depends_on:
|
||||
@ -51,6 +51,7 @@ services:
|
||||
- ../config/fixturenet-optimism/run-op-geth.sh:/run-op-geth.sh
|
||||
- l2_config:/op-node:ro
|
||||
- l2_accounts:/l2-accounts:ro
|
||||
- l2_geth_data:/datadir
|
||||
entrypoint: "sh"
|
||||
command: "/run-op-geth.sh"
|
||||
ports:
|
||||
@ -112,3 +113,4 @@ volumes:
|
||||
l1_deployment:
|
||||
l2_accounts:
|
||||
l2_config:
|
||||
l2_geth_data:
|
||||
|
||||
@ -4,6 +4,12 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# Skip if /app/jwt.txt exists
|
||||
if [ -f /app/jwt.txt ]; then
|
||||
echo "Found existing config, exiting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
op-node genesis l2 \
|
||||
--deploy-config /contracts-bedrock/deploy-config/getting-started.json \
|
||||
--deployment-dir /contracts-bedrock/deployments/getting-started/ \
|
||||
|
||||
@ -4,34 +4,39 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
mkdir datadir
|
||||
|
||||
echo "pwd" > datadir/password
|
||||
|
||||
# TODO: Add in container build or use other tool
|
||||
echo "Installing jq"
|
||||
apk update && apk add jq
|
||||
|
||||
# Get SEQUENCER KEY from keys.json
|
||||
SEQUENCER_KEY=$(jq -r '.Sequencer.privateKey' /l2-accounts/keys.json | tr -d '"')
|
||||
echo $SEQUENCER_KEY > datadir/block-signer-key
|
||||
# Initialize op-geth if datadir/geth not found
|
||||
if [ -f /op-node/jwt.txt ] && [ -d datadir/geth ]; then
|
||||
echo "Found existing datadir, skipping initialization"
|
||||
else
|
||||
echo "Initializing op-geth"
|
||||
|
||||
geth account import --datadir=datadir --password=datadir/password datadir/block-signer-key
|
||||
mkdir datadir
|
||||
echo "pwd" > datadir/password
|
||||
|
||||
while [ ! -f "/op-node/jwt.txt" ]
|
||||
do
|
||||
echo "Config files not created. Checking after 5 seconds."
|
||||
sleep 5
|
||||
done
|
||||
# Get SEQUENCER KEY from keys.json
|
||||
SEQUENCER_KEY=$(jq -r '.Sequencer.privateKey' /l2-accounts/keys.json | tr -d '"')
|
||||
echo $SEQUENCER_KEY > datadir/block-signer-key
|
||||
|
||||
echo "Config files created by op-node, proceeding with script..."
|
||||
geth account import --datadir=datadir --password=datadir/password datadir/block-signer-key
|
||||
|
||||
cp /op-node/genesis.json ./
|
||||
geth init --datadir=datadir genesis.json
|
||||
while [ ! -f "/op-node/jwt.txt" ]
|
||||
do
|
||||
echo "Config files not created. Checking after 5 seconds."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
echo "Config files created by op-node, proceeding with the initialization..."
|
||||
|
||||
geth init --datadir=datadir /op-node/genesis.json
|
||||
echo "Node Initialized"
|
||||
fi
|
||||
|
||||
SEQUENCER_ADDRESS=$(jq -r '.Sequencer.address' /l2-accounts/keys.json | tr -d '"')
|
||||
echo "SEQUENCER_ADDRESS: ${SEQUENCER_ADDRESS}"
|
||||
cp /op-node/jwt.txt ./
|
||||
|
||||
# Run op-geth
|
||||
geth \
|
||||
@ -54,7 +59,7 @@ geth \
|
||||
--authrpc.vhosts="*" \
|
||||
--authrpc.addr=0.0.0.0 \
|
||||
--authrpc.port=8551 \
|
||||
--authrpc.jwtsecret=./jwt.txt \
|
||||
--authrpc.jwtsecret=/op-node/jwt.txt \
|
||||
--rollup.disabletxpoolgossip=true \
|
||||
--password=./datadir/password \
|
||||
--allow-insecure-unlock \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user