-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
op-conductor fixes + bootstrap script (#322)
* op-conductor robustness + bootstrap/startup script improvement op-conductor robustness fixes in localnet modified "setup-raft.bash" script to allow configuration of op-conductor raft setup from environment * stop sequencers as well
- Loading branch information
1 parent
d6778c2
commit 3cc4168
Showing
5 changed files
with
143 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,5 @@ RUN forge build | |
WORKDIR /git/optimism | ||
|
||
RUN make devnet-allocs | ||
|
||
RUN apt-get install -y netcat-openbsd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,47 @@ | ||
#! /bin/bash | ||
|
||
set -ev | ||
set -evx | ||
|
||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_pause","params":[],"id":4}' http://op-conductor:8547 | ||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_pause","params":[],"id":4}' http://op-conductor-2:8547 | ||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_pause","params":[],"id":4}' http://op-conductor-3:8547 | ||
curl -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"admin_stopSequencer\",\"params\":[],\"id\":3}" http://op-node:8547 | ||
IFS=',' read -ra conductor_rpcs <<< "$OPCONDUCTOR_RPCS" | ||
IFS=',' read -ra conductor_rafts <<< "$OPCONDUCTOR_RAFT_VOTERS" | ||
IFS=',' read -ra opnode_rpcs <<< "$OPNODE_RPCS" | ||
opnode_rpc= | ||
|
||
# find the leader | ||
for i in "${!conductor_rpcs[@]}"; do | ||
is_leader=$(curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_leader","params":[],"id":4}' "${conductor_rpcs[$i]}" | jq '.result') | ||
if [ "$is_leader" = 'true' ]; then | ||
opnode_rpc=${opnode_rpcs[$i]} | ||
fi | ||
done | ||
|
||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"optimism_syncStatus","params":[],"id":1}' http://op-node:8547 | ||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_addServerAsVoter","params":["op-conductor-2", "op-conductor-2:50051"],"id":4}' http://op-conductor:8547 | ||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_addServerAsVoter","params":["op-conductor-3", "op-conductor-3:50052"],"id":4}' http://op-conductor:8547 | ||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_resume","params":[],"id":4}' http://op-conductor:8547 | ||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_resume","params":[],"id":4}' http://op-conductor-2:8547 | ||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_resume","params":[],"id":4}' http://op-conductor-3:8547 | ||
|
||
unsafe_head=$(curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"optimism_syncStatus","params":[],"id":2}' http://op-node:8547 | jq '.result.unsafe_l2.hash' ) | ||
if [ "$opnode_rpc" = '' ]; then | ||
echo "could not find leader, aborting" | ||
exit 1 | ||
fi | ||
|
||
# pause each conductor so we can modify state | ||
for rpc in "${conductor_rpcs[@]}"; do | ||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_pause","params":[],"id":4}' $rpc | ||
done | ||
|
||
for rpc in "${opnode_rpcs[@]}"; do | ||
curl -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"admin_stopSequencer\",\"params\":[],\"id\":3}" $rpc | ||
done | ||
|
||
|
||
# for each raft port in op-conductor, add as a voter. this may error when adding self as a voter with the leader, but that's ok, the others should succeed | ||
for raft in "${conductor_rafts[@]}"; do | ||
curl -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"conductor_addServerAsVoter\",\"params\":[\"$raft\", \"$raft\"],\"id\":4}" ${conductor_rpcs[0]} | ||
done | ||
|
||
# resume the conductors | ||
for rpc in "${conductor_rpcs[@]}"; do | ||
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_resume","params":[],"id":4}' $rpc | ||
done | ||
|
||
# restart the sequencer using the unsafe head from the leader's sync status | ||
unsafe_head=$(curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"optimism_syncStatus","params":[],"id":2}' $opnode_rpc | jq '.result.unsafe_l2.hash' ) | ||
echo "unsafe_head=$unsafe_head" | ||
curl -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"admin_startSequencer\",\"params\":[$unsafe_head],\"id\":3}" http://op-node:8547 | ||
curl -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"admin_startSequencer\",\"params\":[$unsafe_head],\"id\":3}" $opnode_rpc |