From 670c2e0b351bb84f63edbee3fb6a14d44ac2015a Mon Sep 17 00:00:00 2001 From: Sebastien Baizet Date: Fri, 14 Jun 2024 10:58:51 +0200 Subject: [PATCH 1/2] feat: add l2geth boot script --- .../charts/l2-bootnode/values.yaml | 47 +++++---- charts/scroll-stack/charts/l2-rpc/values.yaml | 58 ++++++----- .../charts/l2-sequencer/values.yaml | 66 ++++++++----- charts/scroll-stack/l2geth-boot.sh | 98 +++++++++++++++++++ .../scroll-stack/templates/l2geth-boot.yaml | 8 ++ 5 files changed, 209 insertions(+), 68 deletions(-) create mode 100755 charts/scroll-stack/l2geth-boot.sh create mode 100644 charts/scroll-stack/templates/l2geth-boot.yaml diff --git a/charts/scroll-stack/charts/l2-bootnode/values.yaml b/charts/scroll-stack/charts/l2-bootnode/values.yaml index 56e23159..dcd735c3 100644 --- a/charts/scroll-stack/charts/l2-bootnode/values.yaml +++ b/charts/scroll-stack/charts/l2-bootnode/values.yaml @@ -45,26 +45,31 @@ env: - name: L2GETH_EXTRA_PARAMS value: "" +#command: ["bash", +# "-c", +# "geth --datadir \"/l2geth/data\" init /l2geth/genesis/genesis.json && \ +# echo \"[Node.P2P] StaticNodes = $L2GETH_PEER_LIST\" > \"/l2geth/config.toml\" && \ +# geth --datadir \"/l2geth/data\" \ +# --port \"$L2GETH_P2P_PORT\" --syncmode full --networkid \"$CHAIN_ID\" --maxpeers \"$L2GETH_MAX_PEERS\" --netrestrict \"$L2GETH_NETRESTRICT\" --nat \"$L2GETH_NAT\" \ +# --bootnodes \"\" \ +# --gcmode archive \ +# --config \"/l2geth/config.toml\" \ +# --cache.noprefetch \ +# --verbosity 3 \ +# --pprof --pprof.addr \"0.0.0.0\" --pprof.port 6060 \ +# $CCC_FLAG \ +# $METRICS_FLAGS \ +# --txpool.globalqueue 4096 --txpool.globalslots 40960 --txpool.pricelimit \"$L2GETH_MIN_GAS_PRICE\" $LOCALS_FLAG \ +# --l1.endpoint \"$L2GETH_L1_ENDPOINT\" --l1.confirmations \"$L2GETH_L1_WATCHER_CONFIRMATIONS\" --l1.sync.startblock \"$L2GETH_L1_CONTRACT_DEPLOYMENT_BLOCK\" \ +# --miner.gasprice \"$L2GETH_MIN_GAS_PRICE\" --rpc.gascap 0 --gpo.ignoreprice \"$L2GETH_MIN_GAS_PRICE\" \ +# --metrics --metrics.expensive \ +# $L2GETH_EXTRA_PARAMS" +# ] + command: ["bash", "-c", - "geth --datadir \"/l2geth/data\" init /l2geth/genesis/genesis.json && \ - echo \"[Node.P2P] StaticNodes = $L2GETH_PEER_LIST\" > \"/l2geth/config.toml\" && \ - geth --datadir \"/l2geth/data\" \ - --port \"$L2GETH_P2P_PORT\" --syncmode full --networkid \"$CHAIN_ID\" --maxpeers \"$L2GETH_MAX_PEERS\" --netrestrict \"$L2GETH_NETRESTRICT\" --nat \"$L2GETH_NAT\" \ - --bootnodes \"\" \ - --gcmode archive \ - --config \"/l2geth/config.toml\" \ - --cache.noprefetch \ - --verbosity 3 \ - --pprof --pprof.addr \"0.0.0.0\" --pprof.port 6060 \ - $CCC_FLAG \ - $METRICS_FLAGS \ - --txpool.globalqueue 4096 --txpool.globalslots 40960 --txpool.pricelimit \"$L2GETH_MIN_GAS_PRICE\" $LOCALS_FLAG \ - --l1.endpoint \"$L2GETH_L1_ENDPOINT\" --l1.confirmations \"$L2GETH_L1_WATCHER_CONFIRMATIONS\" --l1.sync.startblock \"$L2GETH_L1_CONTRACT_DEPLOYMENT_BLOCK\" \ - --miner.gasprice \"$L2GETH_MIN_GAS_PRICE\" --rpc.gascap 0 --gpo.ignoreprice \"$L2GETH_MIN_GAS_PRICE\" \ - --metrics --metrics.expensive \ - $L2GETH_EXTRA_PARAMS" - ] + "/script/l2geth-boot.sh" +] initContainers: wait-for-other-pod: @@ -95,6 +100,12 @@ probes: << : *default_probes persistence: + boot: + enabled: yes + type: configMap + mountPath: /script/ + name: l2geth-boot + defaultMode: 0777 data: enabled: yes type: pvc diff --git a/charts/scroll-stack/charts/l2-rpc/values.yaml b/charts/scroll-stack/charts/l2-rpc/values.yaml index 2cbf9cb9..e7442768 100644 --- a/charts/scroll-stack/charts/l2-rpc/values.yaml +++ b/charts/scroll-stack/charts/l2-rpc/values.yaml @@ -80,30 +80,36 @@ env: - name: L2GETH_EXTRA_PARAMS value: "" -command: ["bash", +#command: ["bash", +# "-c", +# "geth --datadir \"/l2geth/data\" init /l2geth/genesis/genesis.json && \ +# echo \"[Node.P2P] StaticNodes = $L2GETH_PEER_LIST\" > \"/l2geth/config.toml\" && \ +# geth \ +# --datadir \"/l2geth/data\" \ +# --port \"$L2GETH_P2P_PORT\" --nodiscover --syncmode full --networkid \"$CHAIN_ID\" \ +# --config \"/l2geth/config.toml\" \ +# --http --http.port \"$L2GETH_RPC_HTTP_PORT\" --http.addr \"0.0.0.0\" --http.vhosts=\"*\" --http.corsdomain '*' --http.api \"eth,scroll,net,web3,debug\" \ +# --pprof --pprof.addr \"0.0.0.0\" --pprof.port 6060 \ +# --ws --ws.port \"$L2GETH_RPC_WS_PORT\" --ws.addr \"0.0.0.0\" --ws.api \"eth,scroll,net,web3,debug\" \ +# $CCC_FLAG \ +# $METRICS_FLAGS \ +# --gcmode archive \ +# --cache.noprefetch \ +# --verbosity 3 \ +# --txpool.globalqueue 4096 --txpool.globalslots 40960 --txpool.pricelimit \"$L2GETH_MIN_GAS_PRICE\" $LOCALS_FLAG \ +# --miner.gasprice \"$L2GETH_MIN_GAS_PRICE\" --rpc.gascap 0 --gpo.ignoreprice \"$L2GETH_MIN_GAS_PRICE\" \ +# --gpo.percentile 20 \ +# --gpo.blocks 100 \ +# --l1.endpoint \"$L2GETH_L1_ENDPOINT\" --l1.confirmations \"$L2GETH_L1_WATCHER_CONFIRMATIONS\" --l1.sync.startblock \"$L2GETH_L1_CONTRACT_DEPLOYMENT_BLOCK\" \ +# --rollup.verify \ +# --metrics --metrics.expensive \ +# $L2GETH_EXTRA_PARAMS" +#] + +command: [ + "bash", "-c", - "geth --datadir \"/l2geth/data\" init /l2geth/genesis/genesis.json && \ - echo \"[Node.P2P] StaticNodes = $L2GETH_PEER_LIST\" > \"/l2geth/config.toml\" && \ - geth \ - --datadir \"/l2geth/data\" \ - --port \"$L2GETH_P2P_PORT\" --nodiscover --syncmode full --networkid \"$CHAIN_ID\" \ - --config \"/l2geth/config.toml\" \ - --http --http.port \"$L2GETH_RPC_HTTP_PORT\" --http.addr \"0.0.0.0\" --http.vhosts=\"*\" --http.corsdomain '*' --http.api \"eth,scroll,net,web3,debug\" \ - --pprof --pprof.addr \"0.0.0.0\" --pprof.port 6060 \ - --ws --ws.port \"$L2GETH_RPC_WS_PORT\" --ws.addr \"0.0.0.0\" --ws.api \"eth,scroll,net,web3,debug\" \ - $CCC_FLAG \ - $METRICS_FLAGS \ - --gcmode archive \ - --cache.noprefetch \ - --verbosity 3 \ - --txpool.globalqueue 4096 --txpool.globalslots 40960 --txpool.pricelimit \"$L2GETH_MIN_GAS_PRICE\" $LOCALS_FLAG \ - --miner.gasprice \"$L2GETH_MIN_GAS_PRICE\" --rpc.gascap 0 --gpo.ignoreprice \"$L2GETH_MIN_GAS_PRICE\" \ - --gpo.percentile 20 \ - --gpo.blocks 100 \ - --l1.endpoint \"$L2GETH_L1_ENDPOINT\" --l1.confirmations \"$L2GETH_L1_WATCHER_CONFIRMATIONS\" --l1.sync.startblock \"$L2GETH_L1_CONTRACT_DEPLOYMENT_BLOCK\" \ - --rollup.verify \ - --metrics --metrics.expensive \ - $L2GETH_EXTRA_PARAMS" + "/script/l2geth-boot.sh" ] initContainers: @@ -119,6 +125,12 @@ initContainers: done persistence: + boot: + enabled: yes + type: configMap + mountPath: /script/ + name: l2geth-boot + defaultMode: 0777 data: enabled: yes type: pvc diff --git a/charts/scroll-stack/charts/l2-sequencer/values.yaml b/charts/scroll-stack/charts/l2-sequencer/values.yaml index e566bce1..a33bb335 100644 --- a/charts/scroll-stack/charts/l2-sequencer/values.yaml +++ b/charts/scroll-stack/charts/l2-sequencer/values.yaml @@ -17,7 +17,7 @@ env: - name: CHAIN_ID value: "222222" - name: L2GETH_ROLE - value: "signer" + value: "sequencer" - name: L2GETH_SIGNER_ADDRESS value: "0x756EA06BDEe36de11F22DCca45a31d8a178eF3c6" - name: L2GETH_KEYSTORE @@ -51,32 +51,38 @@ env: - name: VERBOSITY value: "3" -command: ["bash", - "-c", - "mkdir -p /l2geth/data/keystore && \ - mkdir -p /l2geth/data/geth && \ - echo ${L2GETH_PASSWORD} > /l2geth/password && \ - echo ${L2GETH_KEYSTORE} > /l2geth/data/keystore/keystore.json && \ - echo ${L2GETH_NODEKEY} > /l2geth/data/geth/nodekey && \ - geth --datadir \"/l2geth/data\" init /l2geth/genesis/genesis.json && \ - geth --datadir \"/l2geth/data\" \ - --port \"$L2GETH_P2P_PORT\" --nodiscover --syncmode full --networkid \"$CHAIN_ID\" \ - --http --http.port \"$L2GETH_RPC_HTTP_PORT\" --http.addr \"0.0.0.0\" --http.vhosts=\"*\" --http.corsdomain \'*\' --http.api \"eth,scroll,net,web3,debug\" \ - --pprof --pprof.addr \"0.0.0.0\" --pprof.port 6060 \ - --ws --ws.port \"$L2GETH_RPC_WS_PORT\" --ws.addr \"0.0.0.0\" --ws.api \"eth,scroll,net,web3,debug\" \ - --unlock \"$L2GETH_SIGNER_ADDRESS\" --password \"/l2geth/password\" --allow-insecure-unlock --mine \ - $CCC_FLAG \ - --gcmode archive \ - --cache.noprefetch \ - --verbosity ${VERBOSITY} \ - --txpool.globalqueue 4096 --txpool.globalslots 40960 --txpool.pricelimit \"$L2GETH_MIN_GAS_PRICE\" $LOCALS_FLAG \ - --miner.gasprice \"$L2GETH_MIN_GAS_PRICE\" --rpc.gascap 0 --gpo.ignoreprice \"$L2GETH_MIN_GAS_PRICE\" \ - --gpo.percentile 20 \ - --gpo.blocks 100 \ - --l1.endpoint \"$L2GETH_L1_ENDPOINT\" --l1.confirmations \"$L2GETH_L1_WATCHER_CONFIRMATIONS\" --l1.sync.startblock \"$L2GETH_L1_CONTRACT_DEPLOYMENT_BLOCK\" \ - --rollup.verify \ - --metrics --metrics.expensive \ - $L2GETH_EXTRA_PARAMS"] +#command: ["bash", +# "-c", +# "mkdir -p /l2geth/data/keystore && \ +# mkdir -p /l2geth/data/geth && \ +# echo ${L2GETH_PASSWORD} > /l2geth/password && \ +# echo ${L2GETH_KEYSTORE} > /l2geth/data/keystore/keystore.json && \ +# echo ${L2GETH_NODEKEY} > /l2geth/data/geth/nodekey && \ +# geth --datadir \"/l2geth/data\" init /l2geth/genesis/genesis.json && \ +# geth --datadir \"/l2geth/data\" \ +# --port \"$L2GETH_P2P_PORT\" --nodiscover --syncmode full --networkid \"$CHAIN_ID\" \ +# --http --http.port \"$L2GETH_RPC_HTTP_PORT\" --http.addr \"0.0.0.0\" --http.vhosts=\"*\" --http.corsdomain \'*\' --http.api \"eth,scroll,net,web3,debug\" \ +# --pprof --pprof.addr \"0.0.0.0\" --pprof.port 6060 \ +# --ws --ws.port \"$L2GETH_RPC_WS_PORT\" --ws.addr \"0.0.0.0\" --ws.api \"eth,scroll,net,web3,debug\" \ +# --unlock \"$L2GETH_SIGNER_ADDRESS\" --password \"/l2geth/password\" --allow-insecure-unlock --mine \ +# $CCC_FLAG \ +# --gcmode archive \ +# --cache.noprefetch \ +# --verbosity ${VERBOSITY} \ +# --txpool.globalqueue 4096 --txpool.globalslots 40960 --txpool.pricelimit \"$L2GETH_MIN_GAS_PRICE\" $LOCALS_FLAG \ +# --miner.gasprice \"$L2GETH_MIN_GAS_PRICE\" --rpc.gascap 0 --gpo.ignoreprice \"$L2GETH_MIN_GAS_PRICE\" \ +# --gpo.percentile 20 \ +# --gpo.blocks 100 \ +# --l1.endpoint \"$L2GETH_L1_ENDPOINT\" --l1.confirmations \"$L2GETH_L1_WATCHER_CONFIRMATIONS\" --l1.sync.startblock \"$L2GETH_L1_CONTRACT_DEPLOYMENT_BLOCK\" \ +# --rollup.verify \ +# --metrics --metrics.expensive \ +# $L2GETH_EXTRA_PARAMS"] + +command: [ + "bash", + "-c", + "/script/l2geth-boot.sh" +] initContainers: wait-for-other-pod: @@ -136,6 +142,12 @@ probes: << : *default_probes persistence: + boot: + enabled: yes + type: configMap + mountPath: /script/ + name: l2geth-boot + defaultMode: 0777 data: enabled: yes type: pvc diff --git a/charts/scroll-stack/l2geth-boot.sh b/charts/scroll-stack/l2geth-boot.sh new file mode 100755 index 00000000..6176cb8e --- /dev/null +++ b/charts/scroll-stack/l2geth-boot.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +# Check if L2GETH_ROLE is set +if [ -z "$L2GETH_ROLE" ]; then + echo "Error: L2GETH_ROLE is not set" + exit 1 +fi + +# Default values for verbosity and CCC_FLAG +VERBOSITY=${VERBOSITY:-3} +CCC_FLAG=${CCC_FLAG:-""} + +# Common command options +COMMON_OPTS=( + --datadir "/l2geth/data" + --port "$L2GETH_P2P_PORT" + --syncmode full + --networkid "$CHAIN_ID" + --gcmode archive + --cache.noprefetch + --verbosity "$VERBOSITY" + --txpool.globalqueue 4096 + --txpool.globalslots 40960 + --txpool.pricelimit "$L2GETH_MIN_GAS_PRICE" + --miner.gasprice "$L2GETH_MIN_GAS_PRICE" + --rpc.gascap 0 + --gpo.ignoreprice "$L2GETH_MIN_GAS_PRICE" + --metrics --metrics.expensive + $CCC_FLAG + $LOCALS_FLAG + $METRICS_FLAGS + --l1.endpoint "$L2GETH_L1_ENDPOINT" + --l1.confirmations "$L2GETH_L1_WATCHER_CONFIRMATIONS" + --l1.sync.startblock "$L2GETH_L1_CONTRACT_DEPLOYMENT_BLOCK" + $L2GETH_EXTRA_PARAMS +) + +# Role specific options +case "$L2GETH_ROLE" in + rpc) + ROLE_OPTS=( + --config "/l2geth/config.toml" + --nodiscover + --http --http.port "$L2GETH_RPC_HTTP_PORT" --http.addr "0.0.0.0" --http.vhosts="*" --http.corsdomain '*' --http.api "eth,scroll,net,web3,debug" + --pprof --pprof.addr "0.0.0.0" --pprof.port 6060 + --ws --ws.port "$L2GETH_RPC_WS_PORT" --ws.addr "0.0.0.0" --ws.api "eth,scroll,net,web3,debug" + --gpo.percentile 20 + --gpo.blocks 100 + --rollup.verify + ) + ;; + bootnode) + ROLE_OPTS=( + --config "/l2geth/config.toml" + --maxpeers "$L2GETH_MAX_PEERS" + --netrestrict "$L2GETH_NETRESTRICT" + --nat "$L2GETH_NAT" + --bootnodes "" + --pprof --pprof.addr "0.0.0.0" --pprof.port 6060 + ) + ;; + sequencer) + ROLE_OPTS=( + --nodiscover + --http --http.port "$L2GETH_RPC_HTTP_PORT" --http.addr "0.0.0.0" --http.vhosts="*" --http.corsdomain '*' --http.api "eth,scroll,net,web3,debug" + --pprof --pprof.addr "0.0.0.0" --pprof.port 6060 + --ws --ws.port "$L2GETH_RPC_WS_PORT" --ws.addr "0.0.0.0" --ws.api "eth,scroll,net,web3,debug" + --unlock "$L2GETH_SIGNER_ADDRESS" --password "/l2geth/password" --allow-insecure-unlock --mine + --gpo.percentile 20 + --gpo.blocks 100 + --rollup.verify + ) + ;; + *) + echo "Error: Unknown L2GETH_ROLE value '$L2GETH_ROLE'" + exit 1 + ;; +esac + +# Combine common and role specific options +echo "${COMMON_OPTS[@]}" "${ROLE_OPTS[@]}" + +if [ $L2GETH_ROLE == "bootnode" ] || [ $L2GETH_ROLE == "rpc" ] +then + echo "[Node.P2P] StaticNodes = $L2GETH_PEER_LIST" > "/l2geth/config.toml" + geth --datadir "/l2geth/data" init /l2geth/genesis/genesis.json + geth "${COMMON_OPTS[@]}" "${ROLE_OPTS[@]}" +elif [ $L2GETH_ROLE == "sequencer" ]; then + mkdir -p /l2geth/data/keystore + mkdir -p /l2geth/data/geth + echo ${L2GETH_PASSWORD} > /l2geth/password + echo ${L2GETH_KEYSTORE} > /l2geth/data/keystore/keystore.json + echo ${L2GETH_NODEKEY} > /l2geth/data/geth/nodekey + geth --datadir "/l2geth/data" init /l2geth/genesis/genesis.json + geth "${COMMON_OPTS[@]}" "${ROLE_OPTS[@]}" +else + echo "L2GETH_ROLE is not set to bootnode,rpc or sequencer. Exiting." +fi \ No newline at end of file diff --git a/charts/scroll-stack/templates/l2geth-boot.yaml b/charts/scroll-stack/templates/l2geth-boot.yaml new file mode 100644 index 00000000..7a81c25a --- /dev/null +++ b/charts/scroll-stack/templates/l2geth-boot.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + {{- include "scroll-stack.labels" $ | nindent 4 }} + name: l2geth-boot +data: +{{ (.Files.Glob "l2geth-boot.sh").AsConfig | indent 2 }} From 140a3e91491db2ca754e0155da445ab5dfb622a2 Mon Sep 17 00:00:00 2001 From: Sebastien Baizet Date: Fri, 14 Jun 2024 11:14:46 +0200 Subject: [PATCH 2/2] add comments on the script --- charts/scroll-stack/l2geth-boot.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/charts/scroll-stack/l2geth-boot.sh b/charts/scroll-stack/l2geth-boot.sh index 6176cb8e..347b1be0 100755 --- a/charts/scroll-stack/l2geth-boot.sh +++ b/charts/scroll-stack/l2geth-boot.sh @@ -77,13 +77,12 @@ case "$L2GETH_ROLE" in ;; esac -# Combine common and role specific options -echo "${COMMON_OPTS[@]}" "${ROLE_OPTS[@]}" - if [ $L2GETH_ROLE == "bootnode" ] || [ $L2GETH_ROLE == "rpc" ] then echo "[Node.P2P] StaticNodes = $L2GETH_PEER_LIST" > "/l2geth/config.toml" geth --datadir "/l2geth/data" init /l2geth/genesis/genesis.json + echo "Launching l2geth with this command: " + echo "geth \"${COMMON_OPTS[@]}\" \"${ROLE_OPTS[@]}\"" geth "${COMMON_OPTS[@]}" "${ROLE_OPTS[@]}" elif [ $L2GETH_ROLE == "sequencer" ]; then mkdir -p /l2geth/data/keystore @@ -92,6 +91,8 @@ elif [ $L2GETH_ROLE == "sequencer" ]; then echo ${L2GETH_KEYSTORE} > /l2geth/data/keystore/keystore.json echo ${L2GETH_NODEKEY} > /l2geth/data/geth/nodekey geth --datadir "/l2geth/data" init /l2geth/genesis/genesis.json + echo "Launching l2geth with this command: " + echo "geth \"${COMMON_OPTS[@]}\" \"${ROLE_OPTS[@]}\"" geth "${COMMON_OPTS[@]}" "${ROLE_OPTS[@]}" else echo "L2GETH_ROLE is not set to bootnode,rpc or sequencer. Exiting."