Skip to content

Commit

Permalink
Gracefully shutdown optimism batcher and op-geth containers (#345)
Browse files Browse the repository at this point in the history
* Gracefully shutdown optimism batcher and op-geth containers

* Remove unnecessary env export

Former-commit-id: c6e6122
  • Loading branch information
prathamesh0 authored Apr 19, 2023
1 parent 3f79c2b commit 4caae1d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
15 changes: 14 additions & 1 deletion app/data/config/fixturenet-optimism/run-op-batcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}"
# Get BACTHER_KEY from keys.json
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 \
--l2-eth-rpc=http://op-geth:8545 \
--rollup-rpc=http://op-node:8547 \
Expand All @@ -23,4 +32,8 @@ op-batcher \
--max-channel-duration=1 \
--target-l1-tx-size-bytes=2048 \
--l1-eth-rpc=$CERC_L1_RPC \
--private-key=$BATCHER_KEY
--private-key=$BATCHER_KEY \
&

batcher_pid=$!
wait $batcher_pid
15 changes: 14 additions & 1 deletion app/data/config/fixturenet-optimism/run-op-geth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ fi
SEQUENCER_ADDRESS=$(jq -r '.Sequencer.address' /l2-accounts/keys.json | tr -d '"')
echo "SEQUENCER_ADDRESS: ${SEQUENCER_ADDRESS}"

cleanup() {
echo "Signal received, cleaning up..."
kill ${geth_pid}

wait
echo "Done"
}
trap 'cleanup' INT TERM

# Run op-geth
geth \
--datadir ./datadir \
Expand Down Expand Up @@ -74,4 +83,8 @@ geth \
--allow-insecure-unlock \
--mine \
--miner.etherbase=$SEQUENCER_ADDRESS \
--unlock=$SEQUENCER_ADDRESS
--unlock=$SEQUENCER_ADDRESS \
&

geth_pid=$!
wait $geth_pid
3 changes: 3 additions & 0 deletions app/data/stacks/fixturenet-optimism/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

WARNING: This will reset the L2 chain; consequently, all the data on it will be lost

* Stop and remove the concerned containers:

```bash
Expand Down

0 comments on commit 4caae1d

Please sign in to comment.