Gracefully shutdown optimism batcher and op-geth containers

This commit is contained in:
Prathamesh Musale 2023-04-18 16:56:08 +05:30
parent 3130af1615
commit 76ccdf3eec
4 changed files with 32 additions and 2 deletions

View File

@ -13,6 +13,7 @@ CERC_L1_ADDRESS_2="${CERC_L1_ADDRESS_2:-${DEFAULT_CERC_L1_ADDRESS_2}}"
CERC_L1_PRIV_KEY_2="${CERC_L1_PRIV_KEY_2:-${DEFAULT_CERC_L1_PRIV_KEY_2}}" CERC_L1_PRIV_KEY_2="${CERC_L1_PRIV_KEY_2:-${DEFAULT_CERC_L1_PRIV_KEY_2}}"
echo "Using L1 RPC endpoint ${CERC_L1_RPC}" echo "Using L1 RPC endpoint ${CERC_L1_RPC}"
export L1_RPC=${CERC_L1_RPC}
IMPORT_1="import './verify-contract-deployment'" IMPORT_1="import './verify-contract-deployment'"
IMPORT_2="import './rekey-json'" IMPORT_2="import './rekey-json'"

View File

@ -9,6 +9,15 @@ CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}"
# Get BACTHER_KEY from keys.json # Get BACTHER_KEY from keys.json
BATCHER_KEY=$(jq -r '.Batcher.privateKey' /l2-accounts/keys.json | tr -d '"') BATCHER_KEY=$(jq -r '.Batcher.privateKey' /l2-accounts/keys.json | tr -d '"')
cleanup() {
echo "Signal received, cleaning up..."
kill ${batcher_pid}
wait
echo "Done"
}
trap 'cleanup' INT TERM
op-batcher \ op-batcher \
--l2-eth-rpc=http://op-geth:8545 \ --l2-eth-rpc=http://op-geth:8545 \
--rollup-rpc=http://op-node:8547 \ --rollup-rpc=http://op-node:8547 \
@ -23,4 +32,8 @@ op-batcher \
--max-channel-duration=1 \ --max-channel-duration=1 \
--target-l1-tx-size-bytes=2048 \ --target-l1-tx-size-bytes=2048 \
--l1-eth-rpc=$CERC_L1_RPC \ --l1-eth-rpc=$CERC_L1_RPC \
--private-key=$BATCHER_KEY --private-key=$BATCHER_KEY \
&
batcher_pid=$!
wait $batcher_pid

View File

@ -47,6 +47,15 @@ fi
SEQUENCER_ADDRESS=$(jq -r '.Sequencer.address' /l2-accounts/keys.json | tr -d '"') SEQUENCER_ADDRESS=$(jq -r '.Sequencer.address' /l2-accounts/keys.json | tr -d '"')
echo "SEQUENCER_ADDRESS: ${SEQUENCER_ADDRESS}" echo "SEQUENCER_ADDRESS: ${SEQUENCER_ADDRESS}"
cleanup() {
echo "Signal received, cleaning up..."
kill ${geth_pid}
wait
echo "Done"
}
trap 'cleanup' INT TERM
# Run op-geth # Run op-geth
geth \ geth \
--datadir ./datadir \ --datadir ./datadir \
@ -74,4 +83,8 @@ geth \
--allow-insecure-unlock \ --allow-insecure-unlock \
--mine \ --mine \
--miner.etherbase=$SEQUENCER_ADDRESS \ --miner.etherbase=$SEQUENCER_ADDRESS \
--unlock=$SEQUENCER_ADDRESS --unlock=$SEQUENCER_ADDRESS \
&
geth_pid=$!
wait $geth_pid

View File

@ -91,6 +91,9 @@ docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts
``` ```
* This means that the data directory that `op-geth` is using is corrupted and needs to be reinitialized; the containers `op-geth`, `op-node` and `op-batcher` need to be started afresh: * This means that the data directory that `op-geth` is using is corrupted and needs to be reinitialized; the containers `op-geth`, `op-node` and `op-batcher` need to be started afresh:
WARNING: This will reset the L2 chain; consequently, all the data on it will be lost
* Stop and remove the concerned containers: * Stop and remove the concerned containers:
```bash ```bash