Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9106149
support in cliain for version_upgrade
fixxxedpoint Nov 4, 2022
a13cc8f
support of our docker-compose to run using bridged docker's network
fixxxedpoint Nov 4, 2022
dc072d9
catchup_version_upgrade_test.sh
fixxxedpoint Nov 4, 2022
83e02be
added the catchup version upgrade test to github pipelines
fixxxedpoint Nov 4, 2022
143ec1b
review changes
fixxxedpoint Nov 6, 2022
8ca57d7
chmod +x catchup_version_upgrade_test.sh
fixxxedpoint Nov 7, 2022
02fd76b
review changes: using `matrix` for catch-up version upgrade test
fixxxedpoint Nov 7, 2022
87defd7
review changes: bumped version of aleph-client; added schedule_versio…
fixxxedpoint Nov 7, 2022
65a41f6
review changes: comment about key derivation in docker-compose `//1` …
fixxxedpoint Nov 7, 2022
4e05972
fix: e2e...yml: wrong `uses`
fixxxedpoint Nov 7, 2022
148439c
bumped e2e-tests/Cargo.lock
fixxxedpoint Nov 7, 2022
d3d65ed
fix: version_upgrade after api refactor
fixxxedpoint Nov 7, 2022
35563c7
review changes: added cache cleanup to build-cliain-image job
fixxxedpoint Nov 7, 2022
22dce1e
fix: typo in e2e...yml s/NODE2/Node2
fixxxedpoint Nov 7, 2022
781c881
fix for e2e...yml: fixed matrix-include for catch-up version upgrade …
fixxxedpoint Nov 7, 2022
999ef6f
Merge branch 'main' into message_compatibility-catchup
fixxxedpoint Nov 8, 2022
992926a
review changes: renamed local variable in catchup_version_upgrade.sh
fixxxedpoint Nov 8, 2022
dd9e3ed
Merge branch 'main' into message_compatibility-catchup
fixxxedpoint Nov 8, 2022
0b27557
more review changes for catchup_version_upgrade_test.sh
fixxxedpoint Nov 8, 2022
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
Prev Previous commit
Next Next commit
review changes
  • Loading branch information
fixxxedpoint committed Nov 6, 2022
commit 143ec1bb4a0f1f0e63fc5e2a92a9760417983328
51 changes: 24 additions & 27 deletions scripts/catchup_version_upgrade_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
set -euo pipefail

INIT_BLOCK=${INIT_BLOCK:-3}
UPGRADE_ROUND=${UPGRADE_ROUND:-31}
UPGRADE_BLOCK=${UPGRADE_BLOCK:-31}
UPGRADE_VERSION=${UPGRADE_VERSION:-1}
NODES=${NODES:-"Node1:Node2"}
PORTS=${PORTS:-9934:9935}
UPGRADE_BEFORE_DISABLE=${UPGRADE_BEFORE_DISABLE:-false}
SEED=${SEED:-"//0"}
ALL_NODES=${ALL_NODES:-"Node0:Node1:Node2:Node3:Node4"}
ALL_NODES_PORTS=${ALL_NODES_PORTS:-"9933:9934:9935:9936:9937"}
WAIT_ROUNDS=${WAIT_ROUNDS:-30}
WAIT_BLOCKS=${WAIT_BLOCKS:-30}
EXT_STATUS=${EXT_STATUS:-"in-block"}

function log() {
Expand All @@ -37,7 +37,7 @@ function wait_for_finalized_block() {
local node=$2
local port=$3

while [[ $(get_best_finalized $node $port ) -le $init_block ]]; do
while [[ $(get_best_finalized $node $port) -le $init_block ]]; do
sleep 3
done
}
Expand All @@ -50,15 +50,15 @@ function get_best_finalized {
printf "%d" $best_finalized
}

function set_upgrade_round {
local round=$1
function set_upgrade_session {
local session=$1
local version=$2
local validator=$3
local port=$4
local seed=$5
local status=$6

docker run --rm --network container:$validator cliain:latest --node 127.0.0.1:$port --seed $seed version-upgrade-schedule --version $version --session $round --expected-state $status
docker run --rm --network container:$validator cliain:latest --node 127.0.0.1:$port --seed $seed version-upgrade-schedule --version $version --session $session --expected-state $status
}

function check_if_disconnected() {
Expand All @@ -84,10 +84,10 @@ function check_if_disconnected() {
sleep 20

new_finalized=$(get_best_finalized $node $port)
log "newest finalized at node $node after waiting is $new_finalized"
log "newest finalized block at node $node after waiting is $new_finalized"

if [[ $(($new_finalized - $last_finalized)) -ge 1 ]]; then
log ""somehow a disconnected node $node was able to finalize new blocks""
log "somehow a disconnected node $node was able to finalize new blocks"
exit -1
fi
done
Expand All @@ -110,29 +110,26 @@ function disconnect_nodes {
done
}

function wait_for_round {
local round=$1
function wait_for_block {
local block=$1
local validator=$2
local rpc_port=$3

local last_block=""
while [[ -z "$last_block" ]]; do
last_block=$(docker run --rm --network container:$validator appropriate/curl:latest \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlockHash", "params": '$round'}' http://127.0.0.1:$rpc_port | jq '.result')
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlockHash", "params": '$block'}' http://127.0.0.1:$rpc_port | jq '.result')
done
}

function get_last_block {
local validator=$1
local rpc_port=$2

local last_block_hash=$(docker run --rm --network container:$validator appropriate/curl:latest \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlockHash"}' http://127.0.0.1:$rpc_port | jq '.result')
local last_block_number=$(docker run --rm --network container:$validator appropriate/curl:latest \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock", "params": ['$last_block_hash']}' http://127.0.0.1:$rpc_port | jq '.result.block.header.number')
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock"}' http://127.0.0.1:$rpc_port | jq '.result.block.header.number')
printf "%d" $last_block_number
}

Expand Down Expand Up @@ -165,16 +162,16 @@ into_array "$ALL_NODES_PORTS"
ALL_NODES_PORTS=(${result[@]})

log "initializing nodes..."
OVERRIDE_DOCKER_COMPOSE=./docker/docker-compose.bridged.yml ./.github/scripts/run_consensus.sh 1>&2
DOCKER_COMPOSE=./docker/docker-compose.bridged.yml ./.github/scripts/run_consensus.sh 1>&2
log "awaiting finalization of $INIT_BLOCK blocks..."
initialize $INIT_BLOCK "Node0" 9933
log "nodes initialized"

last_block=$(get_last_block "Node0" 9933)
round_for_upgrade=$(($UPGRADE_ROUND + $last_block))
block_for_upgrade=$(($UPGRADE_BLOCK + $last_block))
if [[ $UPGRADE_BEFORE_DISABLE = true ]]; then
log "setting upgrade at $round_for_upgrade round for version $UPGRADE_VERSION before disconnecting"
set_upgrade_round $round_for_upgrade $UPGRADE_VERSION "Node0" 9943 $SEED $EXT_STATUS
log "setting upgrade at $block_for_upgrade block for version $UPGRADE_VERSION before disconnecting"
set_upgrade_session $block_for_upgrade $UPGRADE_VERSION "Node0" 9943 $SEED $EXT_STATUS
fi

log "disconnecting nodes..."
Expand All @@ -184,16 +181,16 @@ check_if_disconnected NODES PORTS
log "nodes disconnected"

last_block=$(get_last_block "Node0" 9933)
round_for_upgrade=$(($UPGRADE_ROUND + $last_block))
block_for_upgrade=$(($UPGRADE_BLOCK + $last_block))
if [[ $UPGRADE_BEFORE_DISABLE = false ]]; then
log "setting upgrade at $round_for_upgrade for version $UPGRADE_VERSION"
set_upgrade_round $round_for_upgrade $UPGRADE_VERSION "Node0" 9943 ${SEED} $EXT_STATUS
log "setting upgrade at $block_for_upgrade block for version $UPGRADE_VERSION"
set_upgrade_session $block_for_upgrade $UPGRADE_VERSION "Node0" 9943 ${SEED} $EXT_STATUS
fi

last_block=$(get_last_block "Node0" 9933)
awaited_round=$(($WAIT_ROUNDS+$round_for_upgrade))
log "awaiting round $awaited_round"
wait_for_round $awaited_round "Node0" 9933
awaited_block=$(($WAIT_BLOCKS+$block_for_upgrade))
log "awaiting block $awaited_block"
wait_for_block $awaited_block "Node0" 9933
log "awaiting finished"

log "connecting nodes..."
Expand All @@ -202,7 +199,7 @@ log "nodes connected"

last_block=$(get_last_block "Node0" 9933)
log "checking finalization..."
check_finalization $(($awaited_round+1)) ALL_NODES ALL_NODES_PORTS
check_finalization $(($awaited_block+1)) ALL_NODES ALL_NODES_PORTS
log "finalization checked"

exit $?