Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
12 changes: 6 additions & 6 deletions .github/scripts/check_finalization.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

RPC_HOST=127.0.0.1
RPC_PORT=9933
RPC_HOST=${RPC_HOST:-127.0.0.1}
RPC_PORT=${RPC_PORT:-9933}
LAST_FINALIZED=""
VALIDATOR=damian
VALIDATOR=${VALIDATOR:-damian}

while [[ "$LAST_FINALIZED" =~ "0x0" ]] || [[ -z "$LAST_FINALIZED" ]]; do
block_hash=$(docker run --network container:$VALIDATOR appropriate/curl:latest \
block_hash=$(docker run --rm --network container:$VALIDATOR appropriate/curl:latest \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getFinalizedHead"}' http://$RPC_HOST:$RPC_PORT | jq '.result')
ret_val=$?
Expand All @@ -15,7 +15,7 @@ while [[ "$LAST_FINALIZED" =~ "0x0" ]] || [[ -z "$LAST_FINALIZED" ]]; do
continue
fi

finalized_block=$(docker run --network container:$VALIDATOR appropriate/curl:latest \
finalized_block=$(docker run --rm --network container:$VALIDATOR appropriate/curl:latest \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock", "params": ['$block_hash']}' http://$RPC_HOST:$RPC_PORT | jq '.result.block.header.number')

Expand All @@ -25,9 +25,9 @@ while [[ "$LAST_FINALIZED" =~ "0x0" ]] || [[ -z "$LAST_FINALIZED" ]]; do
continue
else
LAST_FINALIZED=$finalized_block
echo "Last finalized block number: $LAST_FINALIZED"
fi

done

echo "Last finalized block number: $LAST_FINALIZED"
exit $?
10 changes: 6 additions & 4 deletions .github/scripts/run_consensus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -euo pipefail
# change when increasing the number of node containers
NODE_COUNT=5
MIN_VALIDATOR_COUNT=4
DOCKER_COMPOSE=${DOCKER_COMPOSE:-"docker/docker-compose.yml"}
OVERRIDE_DOCKER_COMPOSE=${OVERRIDE_DOCKER_COMPOSE:-""}

# default minimum validator count
Expand Down Expand Up @@ -83,19 +84,20 @@ function generate_bootnode_peer_id {

function run_containers {
local authorities_count="$1"
local override_file="$2"
local docker_compose_file="$2"
local override_file="$3"

echo "Running ${authorities_count} containers..."
if [[ -z ${override_file} ]]; then
docker-compose -f docker/docker-compose.yml up -d
docker-compose -f "${docker_compose_file}" up -d
else
docker-compose -f docker/docker-compose.yml -f "${override_file}" up -d
docker-compose -f "${docker_compose_file}" -f "${override_file}" up -d
fi
}

authorities=$(generate_authorities ${NODE_COUNT})
generate_chainspec "${authorities[@]}" "${MIN_VALIDATOR_COUNT}"
generate_bootnode_peer_id ${authorities[0]}
run_containers ${NODE_COUNT} "${OVERRIDE_DOCKER_COMPOSE}"
run_containers ${NODE_COUNT} "${DOCKER_COMPOSE}" "${OVERRIDE_DOCKER_COMPOSE}"

exit $?
159 changes: 159 additions & 0 deletions .github/workflows/e2e-tests-main-devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,36 @@ jobs:
retention-days: 7


build-cliain-image:
name: Build docker image for cliain
runs-on: ubuntu-20.04
steps:
- name: GIT | Checkout source code
uses: actions/checkout@v2

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1

- name: Cargo | Build release binary
run: |
cd ./bin/cliain && cargo build --release

- name: Build docker image
run: |
cd ./bin/cliain
chmod +x target/release/cliain
docker build --tag cliain:latest -f ./Dockerfile .
docker save -o cliain.tar cliain:latest

- name: Upload test docker image
uses: actions/upload-artifact@v2
with:
name: cliain-docker
path: ./bin/cliain/cliain.tar
if-no-files-found: error
retention-days: 7


check-determinism:
needs: [build-new-node]
name: Verify runtime build determinism
Expand Down Expand Up @@ -279,6 +309,7 @@ jobs:
test-case: fee_calculation
timeout-minutes: 2


run-e2e-validators-rotate:
needs: [build-test-docker, build-test-client]
name: Run validators rotation test
Expand Down Expand Up @@ -485,6 +516,130 @@ jobs:
follow-up-finalization-check: true
timeout-minutes: 15

run-e2e-version-upgrade-catchup-one-node-late:
needs: [build-test-docker, build-cliain-image]
name: Run a test where one of the nodes learns of version-upgrade during catchup
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Download artifact with docker image for aleph-node
uses: actions/download-artifact@v2
with:
name: aleph-test-docker

- name: Load node docker image
shell: bash
run: docker load -i aleph-node.tar

- name: Download artifact with docker image for cliain
uses: actions/download-artifact@v2
with:
name: cliain-docker

- name: Load cliain docker image
shell: bash
run: docker load -i cliain.tar

- name: Call catchup_test.sh
run: |
chmod +x ./scripts/catchup_version_upgrade_test.sh
UPGRADE_ROUND=31 NODES="Node1" PORTS="9934" EXT_STATUS="finalized" DOCKER_COMPOSE=docker/docker-compose.bridged.yml ./scripts/catchup_version_upgrade_test.sh

run-e2e-version-upgrade-catchup-two-nodes-late:
needs: [build-test-docker, build-cliain-image]
name: Run a test where two nodes learn of version-upgrade during catchup
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Download artifact with docker image for aleph-node
uses: actions/download-artifact@v2
with:
name: aleph-test-docker

- name: Load node docker image
shell: bash
run: docker load -i aleph-node.tar

- name: Download artifact with docker image for cliain
uses: actions/download-artifact@v2
with:
name: cliain-docker

- name: Load cliain docker image
shell: bash
run: docker load -i cliain.tar

- name: Call catchup_test.sh
run: |
chmod +x ./scripts/catchup_version_upgrade_test.sh
UPGRADE_ROUND=31 NODES="Node1:Node2" PORTS="9934:9935" EXT_STATUS="in-block" DOCKER_COMPOSE=docker/docker-compose.bridged.yml ./scripts/catchup_version_upgrade_test.sh

run-e2e-version-upgrade-early-catchup-one-node-late:
needs: [build-test-docker, build-cliain-image]
name: Run a test where one of the nodes learns of version-upgrade before catchup
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Download artifact with docker image for aleph-node
uses: actions/download-artifact@v2
with:
name: aleph-test-docker

- name: Load node docker image
shell: bash
run: docker load -i aleph-node.tar

- name: Download artifact with docker image for cliain
uses: actions/download-artifact@v2
with:
name: cliain-docker

- name: Load cliain docker image
shell: bash
run: docker load -i cliain.tar

- name: Call catchup_test.sh
run: |
chmod +x ./scripts/catchup_version_upgrade_test.sh
UPGRADE_BEFORE_DISABLE=true UPGRADE_ROUND=31 NODES="Node1" PORTS="9934" EXT_STATUS="finalized" DOCKER_COMPOSE=docker/docker-compose.bridged.yml ./scripts/catchup_version_upgrade_test.sh

run-e2e-version-upgrade-early-catchup-two-nodes-late:
needs: [build-test-docker, build-cliain-image]
name: Run a test where two nodes learn of version-upgrade before catchup
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Download artifact with docker image for aleph-node
uses: actions/download-artifact@v2
with:
name: aleph-test-docker

- name: Load node docker image
shell: bash
run: docker load -i aleph-node.tar

- name: Download artifact with docker image for cliain
uses: actions/download-artifact@v2
with:
name: cliain-docker

- name: Load cliain docker image
shell: bash
run: docker load -i cliain.tar

- name: Call catchup_test.sh
run: |
chmod +x ./scripts/catchup_version_upgrade_test.sh
UPGRADE_BEFORE_DISABLE=true UPGRADE_ROUND=31 NODES="Node1:Node2" PORTS="9934:9935" EXT_STATUS="finalized" DOCKER_COMPOSE=docker/docker-compose.bridged.yml ./scripts/catchup_version_upgrade_test.sh

check-e2e-test-suite-completion:
needs: [
run-e2e-finalization-test,
Expand All @@ -510,6 +665,10 @@ jobs:
run-e2e-ban-manual,
run-e2e-version-upgrade,
run-e2e-failing-version-upgrade,
run-e2e-version-upgrade-catchup-one-node-late,
run-e2e-version-upgrade-catchup-two-nodes-late,
run-e2e-version-upgrade-early-catchup-one-node-late,
run-e2e-version-upgrade-early-catchup-two-nodes-late,
]
name: Check e2e test suite completion
runs-on: ubuntu-20.04
Expand Down
3 changes: 2 additions & 1 deletion aleph-client/src/version_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub fn schedule_upgrade(
connection: &RootConnection,
version: Version,
session: SessionIndex,
state: XtStatus,
) -> Result<(), ApiClientError> {
let connection = connection.as_connection();
let upgrade_call = compose_call!(
Expand All @@ -30,7 +31,7 @@ pub fn schedule_upgrade(
&connection,
xt,
Some("schedule finality version change"),
XtStatus::Finalized,
state,
)
.map(|_| ())
}
35 changes: 32 additions & 3 deletions bin/cliain/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::{
path::{Path, PathBuf},
};

use aleph_client::BlockNumber;
use clap::{Args, Subcommand};
use primitives::{Balance, CommitteeSeats};
use aleph_client::{BlockNumber, XtStatus};
use clap::{clap_derive::ValueEnum, Args, Subcommand};
use primitives::{Balance, CommitteeSeats, SessionIndex};
use serde::{Deserialize, Serialize};
use sp_core::H256;
use substrate_api_client::AccountId;
Expand Down Expand Up @@ -111,6 +111,8 @@ pub struct ChangeValidatorArgs {
pub committee_size: Option<CommitteeSeats>,
}

pub type Version = u32;

impl std::str::FromStr for ChangeValidatorArgs {
type Err = serde_json::Error;

Expand All @@ -124,6 +126,21 @@ impl std::str::FromStr for ChangeValidatorArgs {
}
}

#[derive(Debug, Clone, ValueEnum)]
pub enum ExtrinsicState {
InBlock,
Finalized,
}

impl From<ExtrinsicState> for XtStatus {
fn from(state: ExtrinsicState) -> Self {
match state {
ExtrinsicState::InBlock => XtStatus::InBlock,
ExtrinsicState::Finalized => XtStatus::Finalized,
}
}
}

#[derive(Debug, Clone, Subcommand)]
pub enum Command {
/// Staking call to bond stash with controller
Expand Down Expand Up @@ -336,4 +353,16 @@ pub enum Command {
/// Code can only be removed by its original uploader (its owner) and only if it is not used by any contract.
/// API signature: https://polkadot.js.org/docs/substrate/extrinsics/#removecodecode_hash-h256
ContractRemoveCode(ContractRemoveCode),

/// Schedules a version upgrade of the network.
VersionUpgradeSchedule {
#[clap(long)]
version: Version,

#[clap(long)]
session: SessionIndex,

#[clap(long, value_enum, default_value_t=ExtrinsicState::Finalized)]
expected_state: ExtrinsicState,
},
}
2 changes: 2 additions & 0 deletions bin/cliain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod staking;
mod transfer;
mod treasury;
mod validators;
mod version_upgrade;
mod vesting;

use aleph_client::{
Expand All @@ -27,6 +28,7 @@ pub use treasury::{
approve as treasury_approve, propose as treasury_propose, reject as treasury_reject,
};
pub use validators::change_validators;
pub use version_upgrade::schedule_upgrade;
pub use vesting::{vest, vest_other, vested_transfer};

pub struct ConnectionConfig {
Expand Down
14 changes: 11 additions & 3 deletions bin/cliain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use clap::Parser;
use cliain::{
bond, call, change_validators, finalize, force_new_era, instantiate, instantiate_with_code,
next_session_keys, nominate, owner_info, prepare_keys, prompt_password_hidden, remove_code,
rotate_keys, set_emergency_finalizer, set_keys, set_staking_limits, transfer, treasury_approve,
treasury_propose, treasury_reject, update_runtime, upload_code, validate, vest, vest_other,
vested_transfer, Command, ConnectionConfig,
rotate_keys, schedule_upgrade, set_emergency_finalizer, set_keys, set_staking_limits, transfer,
treasury_approve, treasury_propose, treasury_reject, update_runtime, upload_code, validate,
vest, vest_other, vested_transfer, Command, ConnectionConfig,
};
use log::{error, info};
use sp_core::Pair;
Expand Down Expand Up @@ -182,6 +182,14 @@ fn main() {
Ok(result) => println!("{:?}", result),
Err(why) => error!("Contract remove code failed {:?}", why),
},
Command::VersionUpgradeSchedule {
version,
session: session_for_upgrade,
expected_state,
} => match schedule_upgrade(cfg.into(), version, session_for_upgrade, expected_state) {
Ok(_) => {}
Err(why) => error!("Unable to schedule an upgrade {:?}", why),
},
}
}

Expand Down
20 changes: 20 additions & 0 deletions bin/cliain/src/version_upgrade.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use aleph_client::RootConnection;
use anyhow::Error;
use primitives::SessionIndex;

use crate::commands::{ExtrinsicState, Version};

pub fn schedule_upgrade(
connection: RootConnection,
version: Version,
session_for_upgrade: SessionIndex,
expected_state: ExtrinsicState,
) -> anyhow::Result<()> {
aleph_client::schedule_upgrade(
&connection,
version,
session_for_upgrade,
expected_state.into(),
)
.map_err(Error::new)
}
Loading