From 5bf01a587e4d7bf5fe730964172696225a9afc33 Mon Sep 17 00:00:00 2001 From: nabarun Date: Thu, 30 Mar 2023 20:53:33 +0530 Subject: [PATCH] Fixes for running op-geth container --- .../docker-compose-fixturenet-optimism.yml | 18 +++++++++--------- .../fixturenet-optimism/generate-l2-config.sh | 15 ++++++--------- .../config/fixturenet-optimism/run-op-geth.sh | 10 +++++++--- .../cerc-optimism-op-node/Dockerfile | 2 ++ 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/data/compose/docker-compose-fixturenet-optimism.yml b/app/data/compose/docker-compose-fixturenet-optimism.yml index 198ac533..5d382c75 100644 --- a/app/data/compose/docker-compose-fixturenet-optimism.yml +++ b/app/data/compose/docker-compose-fixturenet-optimism.yml @@ -27,11 +27,11 @@ services: L1_RPC: "http://fixturenet-eth-geth-1:8545" image: cerc/optimism-op-node:local volumes: - - ../config/fixturenet-optimism/generate-l2-config.sh:/app/op-node/generate-l2-config.sh + - ../config/fixturenet-optimism/generate-l2-config.sh:/app/generate-l2-config.sh # TODO: Integrate - - ../test/contracts-bedrock:/app/packages/contracts-bedrock - - op_node_data:/app/op-node - command: ["sh", "generate-l2-config.sh"] + - ../test/contracts-bedrock:/contracts-bedrock + - op_node_data:/app + command: ["sh", "/app/generate-l2-config.sh"] op-geth: image: cerc/optimism-l2geth:local @@ -48,11 +48,11 @@ services: ports: - "8545" healthcheck: - test: ["CMD", "nc", "-v", "http://localhost:8545"] + test: ["CMD", "nc", "-vz", "localhost:8545"] interval: 30s timeout: 10s retries: 10 - start_period: 30s + start_period: 10s op-node: environment: @@ -63,11 +63,11 @@ services: condition: service_healthy image: cerc/optimism-op-node:local volumes: - - ../config/fixturenet-optimism/run-op-node.sh:/app/op-node/run-op-node.sh - - op_node_data:/app/op-node + - ../config/fixturenet-optimism/run-op-node.sh:/app/run-op-node.sh + - op_node_data:/app # TODO: Integrate - ../test/l2-accounts:/l2-accounts - command: ["sh", "run-op-node.sh"] + command: ["sh", "/app/run-op-node.sh"] volumes: op_node_data: diff --git a/app/data/config/fixturenet-optimism/generate-l2-config.sh b/app/data/config/fixturenet-optimism/generate-l2-config.sh index 489654e9..25ed2378 100755 --- a/app/data/config/fixturenet-optimism/generate-l2-config.sh +++ b/app/data/config/fixturenet-optimism/generate-l2-config.sh @@ -1,14 +1,11 @@ #!/bin/sh set -e -go run cmd/main.go genesis l2 \ - --deploy-config ../packages/contracts-bedrock/deploy-config/getting-started.json \ - --deployment-dir ../packages/contracts-bedrock/deployments/getting-started/ \ - --outfile.l2 genesis.json \ - --outfile.rollup rollup.json \ +op-node genesis l2 \ + --deploy-config /contracts-bedrock/deploy-config/getting-started.json \ + --deployment-dir /contracts-bedrock/deployments/getting-started/ \ + --outfile.l2 /app/genesis.json \ + --outfile.rollup /app/rollup.json \ --l1-rpc $L1_RPC -openssl rand -hex 32 > jwt.txt - -cat genesis.json -cat jwt.txt +openssl rand -hex 32 > /app/jwt.txt diff --git a/app/data/config/fixturenet-optimism/run-op-geth.sh b/app/data/config/fixturenet-optimism/run-op-geth.sh index a6de011d..88b3126b 100755 --- a/app/data/config/fixturenet-optimism/run-op-geth.sh +++ b/app/data/config/fixturenet-optimism/run-op-geth.sh @@ -5,13 +5,17 @@ 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 '.Sequencer.privateKey' /l2-accounts/keys.json` +SEQUENCER_KEY=$(jq -r '.Sequencer.privateKey' /l2-accounts/keys.json | tr -d '"') echo $SEQUENCER_KEY > datadir/block-signer-key geth account import --datadir=datadir --password=datadir/password datadir/block-signer-key -while [ ! -f "/op-node/jwt.tx" ] +while [ ! -f "/op-node/jwt.txt" ] do echo "Config files not created. Checking after 5 seconds." sleep 5 @@ -22,7 +26,7 @@ echo "Config files created by op-node, proceeding with script..." cp /op-node/genesis.json ./ geth init --datadir=datadir genesis.json -SEQUENCER_ADDRESS=`jq '.Sequencer.address' /l2-accounts/keys.json` +SEQUENCER_ADDRESS=$(jq -r '.Sequencer.address' /l2-accounts/keys.json | tr -d '"') echo "SEQUENCER_ADDRESS: ${SEQUENCER_ADDRESS}" cp /op-node/jwt.txt ./ geth \ diff --git a/app/data/container-build/cerc-optimism-op-node/Dockerfile b/app/data/container-build/cerc-optimism-op-node/Dockerfile index 2ef39960..ee878471 100644 --- a/app/data/container-build/cerc-optimism-op-node/Dockerfile +++ b/app/data/container-build/cerc-optimism-op-node/Dockerfile @@ -23,6 +23,8 @@ RUN make op-node VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH FROM alpine:3.15 +RUN apk add --no-cache openssl + COPY --from=builder /app/op-node/bin/op-node /usr/local/bin CMD ["op-node"]