Skip to content

Commit

Permalink
chain activation: avoid misfiring (#601)
Browse files Browse the repository at this point in the history
* chain activation: avoid misfiring

when activate job gets a successful RPC response for the first time, it
should not repeat the query; instead, just parse the output again and
check whether the level is zero.

This way, if the second rpc query fails, it will just restart the job
instead of passing silently, resulting in a non-activated chain stuck at
level 0, as happened on Mondaynet today.

* fix helm tests
  • Loading branch information
nicolasochem committed Sep 12, 2023
1 parent 2653782 commit 2bde953
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
17 changes: 9 additions & 8 deletions charts/tezos/scripts/chain-initiator.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
set -e
CLIENT="/usr/local/bin/octez-client --endpoint http://tezos-node-rpc:8732"

until $CLIENT rpc get /chains/main/blocks/head/header | grep '"level":'; do
OUTPUT=""
until OUTPUT=$($CLIENT rpc get /chains/main/blocks/head/header) && echo "$OUTPUT" | grep '"level":'; do
sleep 2
done

set -o pipefail
if ! $CLIENT rpc get /chains/main/blocks/head/header | grep '"level": 0,'; then
if ! echo "$OUTPUT" | grep '"level": 0,'; then
echo "Chain already activated, considering activation successful and exiting"
exit 0
fi
Expand Down Expand Up @@ -88,9 +89,9 @@ else
echo "No 'fromfile#' detected in '$PARAMETERS_FILE', no changes made."
fi
echo Activating chain:
$CLIENT -d /var/tezos/client --block \
genesis activate protocol \
{{ .Values.activation.protocol_hash }} \
with fitness 1 and key \
$( cat /etc/tezos/activation_account_name ) \
and parameters $PARAMETERS_FILE 2>&1 | head -200
$CLIENT -d /var/tezos/client --block \
genesis activate protocol \
{{ .Values.activation.protocol_hash }} \
with fitness 1 and key \
$( cat /etc/tezos/activation_account_name ) \
and parameters /etc/tezos/parameters.json 2>&1 | head -200
17 changes: 9 additions & 8 deletions test/charts/private-chain.expect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1622,24 +1622,25 @@ spec:
- |
CLIENT="/usr/local/bin/octez-client --endpoint http://tezos-node-rpc:8732"
until $CLIENT rpc get /chains/main/blocks/head/header | grep '"level":'; do
OUTPUT=""
until OUTPUT=$($CLIENT rpc get /chains/main/blocks/head/header) && echo "$OUTPUT" | grep '"level":'; do
sleep 2
done
set -x
set -o pipefail
if ! $CLIENT rpc get /chains/main/blocks/head/header | grep '"level": 0,'; then
if ! echo "$OUTPUT" | grep '"level": 0,'; then
echo "Chain already activated, considering activation successful and exiting"
exit 0
fi
echo Activating chain:
$CLIENT -d /var/tezos/client --block \
genesis activate protocol \
PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY \
with fitness 1 and key \
$( cat /etc/tezos/activation_account_name ) \
and parameters /etc/tezos/parameters.json 2>&1 | head -200
$CLIENT -d /var/tezos/client --block \
genesis activate protocol \
PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY \
with fitness 1 and key \
$( cat /etc/tezos/activation_account_name ) \
and parameters /etc/tezos/parameters.json 2>&1 | head -200
envFrom:
env:
Expand Down

0 comments on commit 2bde953

Please sign in to comment.