From 8d6d13ecf89c5cb29c347ff7346e0b3ef5dc9b1b Mon Sep 17 00:00:00 2001 From: nabarun Date: Thu, 30 Mar 2023 18:51:44 +0530 Subject: [PATCH] Add fixturenet-optimism op-node and op-geth --- .../docker-compose-fixturenet-optimism.yml | 50 ++++++++++++++++- .../fixturenet-optimism/generate-l2-config.sh | 14 +++++ .../config/fixturenet-optimism/run-op-geth.sh | 54 +++++++++++++++++++ .../config/fixturenet-optimism/run-op-node.sh | 20 +++++++ 4 files changed, 137 insertions(+), 1 deletion(-) create mode 100755 app/data/config/fixturenet-optimism/generate-l2-config.sh create mode 100755 app/data/config/fixturenet-optimism/run-op-geth.sh create mode 100755 app/data/config/fixturenet-optimism/run-op-node.sh diff --git a/app/data/compose/docker-compose-fixturenet-optimism.yml b/app/data/compose/docker-compose-fixturenet-optimism.yml index 73ba7313..198ac533 100644 --- a/app/data/compose/docker-compose-fixturenet-optimism.yml +++ b/app/data/compose/docker-compose-fixturenet-optimism.yml @@ -1,7 +1,6 @@ version: '3.7' services: - fixturenet-optimism-contracts: hostname: fixturenet-optimism-contracts depends_on: @@ -22,7 +21,56 @@ services: # TODO: Add healthcheck # healthcheck: + op-node-l2-config-gen: + environment: + # TODO: Integrate + 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 + # TODO: Integrate + - ../test/contracts-bedrock:/app/packages/contracts-bedrock + - op_node_data:/app/op-node + command: ["sh", "generate-l2-config.sh"] + + op-geth: + image: cerc/optimism-l2geth:local + depends_on: + op-node-l2-config-gen: + condition: service_started + volumes: + - ../config/fixturenet-optimism/run-op-geth.sh:/run-op-geth.sh + - op_node_data:/op-node + # TODO: Integrate + - ../test/l2-accounts:/l2-accounts + entrypoint: "sh" + command: "/run-op-geth.sh" + ports: + - "8545" + healthcheck: + test: ["CMD", "nc", "-v", "http://localhost:8545"] + interval: 30s + timeout: 10s + retries: 10 + start_period: 30s + + op-node: + environment: + # TODO: Integrate + L1_RPC: "http://fixturenet-eth-geth-1:8545" + depends_on: + op-geth: + 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 + # TODO: Integrate + - ../test/l2-accounts:/l2-accounts + command: ["sh", "run-op-node.sh"] + volumes: + op_node_data: l2-accounts: # TODO: Required? # fixturenet-geth-accounts: diff --git a/app/data/config/fixturenet-optimism/generate-l2-config.sh b/app/data/config/fixturenet-optimism/generate-l2-config.sh new file mode 100755 index 00000000..489654e9 --- /dev/null +++ b/app/data/config/fixturenet-optimism/generate-l2-config.sh @@ -0,0 +1,14 @@ +#!/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 \ + --l1-rpc $L1_RPC + +openssl rand -hex 32 > jwt.txt + +cat genesis.json +cat jwt.txt diff --git a/app/data/config/fixturenet-optimism/run-op-geth.sh b/app/data/config/fixturenet-optimism/run-op-geth.sh new file mode 100755 index 00000000..a6de011d --- /dev/null +++ b/app/data/config/fixturenet-optimism/run-op-geth.sh @@ -0,0 +1,54 @@ +#!/bin/sh +set -e + +mkdir datadir + +echo "pwd" > datadir/password + +# Get SEQUENCER KEY from keys.json +SEQUENCER_KEY=`jq '.Sequencer.privateKey' /l2-accounts/keys.json` +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" ] +do + echo "Config files not created. Checking after 5 seconds." + sleep 5 +done + +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` +echo "SEQUENCER_ADDRESS: ${SEQUENCER_ADDRESS}" +cp /op-node/jwt.txt ./ +geth \ + --datadir ./datadir \ + --http \ + --http.corsdomain="*" \ + --http.vhosts="*" \ + --http.addr=0.0.0.0 \ + --http.api=web3,debug,eth,txpool,net,engine \ + --ws \ + --ws.addr=0.0.0.0 \ + --ws.port=8546 \ + --ws.origins="*" \ + --ws.api=debug,eth,txpool,net,engine \ + --syncmode=full \ + --gcmode=full \ + --nodiscover \ + --maxpeers=0 \ + --networkid=42069 \ + --authrpc.vhosts="*" \ + --authrpc.addr=0.0.0.0 \ + --authrpc.port=8551 \ + --authrpc.jwtsecret=./jwt.txt \ + --rollup.disabletxpoolgossip=true \ + --password=./datadir/password \ + --allow-insecure-unlock \ + --mine \ + --miner.etherbase=$SEQUENCER_ADDRESS \ + --unlock=$SEQUENCER_ADDRESS diff --git a/app/data/config/fixturenet-optimism/run-op-node.sh b/app/data/config/fixturenet-optimism/run-op-node.sh new file mode 100755 index 00000000..097b0983 --- /dev/null +++ b/app/data/config/fixturenet-optimism/run-op-node.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +# Get SEQUENCER KEY from keys.json +SEQUENCER_KEY=`jq '.Sequencer.privateKey' /l2-accounts/keys.json` + +op-node \ + --l2=http://op-geth:8551 \ + --l2.jwt-secret=./jwt.txt \ + --sequencer.enabled \ + --sequencer.l1-confs=3 \ + --verifier.l1-confs=3 \ + --rollup.config=./rollup.json \ + --rpc.addr=0.0.0.0 \ + --rpc.port=8547 \ + --p2p.disable \ + --rpc.enable-admin \ + --p2p.sequencer.key=$SEQUENCER_KEY \ + --l1=$L1_RPC \ + --l1.rpckind=any