Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat l2geth boot script #55

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions charts/scroll-stack/charts/l2-bootnode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,31 @@ env:
- name: L2GETH_EXTRA_PARAMS
value: ""

#command: ["bash",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we fully remove these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes of course, once we are sure everything work.
I keep it to easily compare.

# "-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:
Expand Down Expand Up @@ -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
Expand Down
58 changes: 35 additions & 23 deletions charts/scroll-stack/charts/l2-rpc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -119,6 +125,12 @@ initContainers:
done

persistence:
boot:
enabled: yes
type: configMap
mountPath: /script/
name: l2geth-boot
defaultMode: 0777
data:
enabled: yes
type: pvc
Expand Down
66 changes: 39 additions & 27 deletions charts/scroll-stack/charts/l2-sequencer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
99 changes: 99 additions & 0 deletions charts/scroll-stack/l2geth-boot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/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

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
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
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."
fi
8 changes: 8 additions & 0 deletions charts/scroll-stack/templates/l2geth-boot.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading