From 2800f359521decd79bb052bdf6b016820e48dd24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Mon, 28 Nov 2022 14:03:00 +0100 Subject: [PATCH 01/17] Init CI attempt --- e2e-tests/Cargo.lock | 1 + e2e-tests/docker_entrypoint.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/e2e-tests/Cargo.lock b/e2e-tests/Cargo.lock index 1bf96b1341..521f6b0b45 100644 --- a/e2e-tests/Cargo.lock +++ b/e2e-tests/Cargo.lock @@ -2267,6 +2267,7 @@ name = "pallets-support" version = "0.1.2" dependencies = [ "frame-support", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.30)", ] [[package]] diff --git a/e2e-tests/docker_entrypoint.sh b/e2e-tests/docker_entrypoint.sh index 3ab44def91..2681b57a2e 100644 --- a/e2e-tests/docker_entrypoint.sh +++ b/e2e-tests/docker_entrypoint.sh @@ -11,7 +11,9 @@ fi # If test case params are both not empty, run client with them. Otherwise, run without params. if [[ -n "${RESERVED_SEATS:-}" && -n "${NON_RESERVED_SEATS:-}" ]]; then + VALIDATOR_COUNT = $((${RESERVED_SEATS} + ${NON_RESERVED_SEATS})) ARGS+=( + --validator-count "${VALIDATOR_COUNT}" --reserved-seats "${RESERVED_SEATS}" --non-reserved-seats "${NON_RESERVED_SEATS}" ) From 10cfa191d321e90dc46284dc1be94efa582b530e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Mon, 28 Nov 2022 14:08:32 +0100 Subject: [PATCH 02/17] More --- .github/actions/run-e2e-test/action.yml | 5 +++++ .github/scripts/run_consensus.sh | 4 +--- docker/docker-compose.base.yml | 16 ++++++++++++++++ docker/docker-compose.bridged.yml | 13 +++++++++++++ docker/docker-compose.yml | 6 ++++++ 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/.github/actions/run-e2e-test/action.yml b/.github/actions/run-e2e-test/action.yml index 9a79c5cf74..e824586fc5 100644 --- a/.github/actions/run-e2e-test/action.yml +++ b/.github/actions/run-e2e-test/action.yml @@ -70,8 +70,13 @@ runs: -m "${{ inputs.min-validator-count }}" ) + NODE_COUNT="${{ inputs.node-count }}" RESERVED_SEATS="${{ inputs.reserved-seats }}" NON_RESERVED_SEATS="${{ inputs.non-reserved-seats }}" + + if [[ -n "${NODE_COUNT}" ]]; then + ARGS+=(-v "${NODE_COUNT}") + fi if [[ -n "${RANDOMIZED}" ]]; then ARGS+=(-r "${RANDOMIZED}") diff --git a/.github/scripts/run_consensus.sh b/.github/scripts/run_consensus.sh index ca40484618..b04f50f44e 100755 --- a/.github/scripts/run_consensus.sh +++ b/.github/scripts/run_consensus.sh @@ -5,13 +5,11 @@ set -euo pipefail # default node count # change when increasing the number of node containers NODE_COUNT=5 +# default minimum validator count MIN_VALIDATOR_COUNT=4 DOCKER_COMPOSE=${DOCKER_COMPOSE:-"docker/docker-compose.yml"} OVERRIDE_DOCKER_COMPOSE=${OVERRIDE_DOCKER_COMPOSE:-""} -# default minimum validator count -MIN_VALIDATOR_COUNT=4 - export NODE_IMAGE=aleph-node:latest mkdir -p docker/data/ diff --git a/docker/docker-compose.base.yml b/docker/docker-compose.base.yml index 6a159a6f19..ca33551779 100644 --- a/docker/docker-compose.base.yml +++ b/docker/docker-compose.base.yml @@ -77,3 +77,19 @@ services: # key derived from "//4" - BASE_PATH=/data/5DiDShBWa1fQx6gLzpf3SFBhMinCoyvHM1BWjPNsmXS8hkrW - NODE_KEY_PATH=/data/5DiDShBWa1fQx6gLzpf3SFBhMinCoyvHM1BWjPNsmXS8hkrW/p2p_secret + + Node5: + extends: + file: common.yml + service: AlephNonBootNode + container_name: Node5 + environment: + - RPC_PORT=9938 + - WS_PORT=9948 + - PORT=30338 + - VALIDATOR_PORT=30348 + - PUBLIC_VALIDATOR_ADDRESS=127.0.0.1:30348 + - NAME=Node5 + # key derived from "//5" + - BASE_PATH=/data/5EFb84yH9tpcFuiKUcsmdoF7xeeY3ajG1ZLQimxQoFt9HMKR + - NODE_KEY_PATH=/data/5EFb84yH9tpcFuiKUcsmdoF7xeeY3ajG1ZLQimxQoFt9HMKR/p2p_secret diff --git a/docker/docker-compose.bridged.yml b/docker/docker-compose.bridged.yml index b1303e4ca4..0f81315058 100644 --- a/docker/docker-compose.bridged.yml +++ b/docker/docker-compose.bridged.yml @@ -53,6 +53,17 @@ services: - PUBLIC_VALIDATOR_ADDRESS=Node4:30347 - BOOT_NODES=/dns4/Node0/tcp/30333/p2p/$BOOTNODE_PEER_ID + Node5: + extends: + file: docker-compose.base.yml + service: Node5 + networks: + - main + - Node5 + environment: + - PUBLIC_VALIDATOR_ADDRESS=Node4:30348 + - BOOT_NODES=/dns4/Node0/tcp/30333/p2p/$BOOTNODE_PEER_ID + networks: main: name: main-network @@ -66,3 +77,5 @@ networks: name: Node3-network Node4: name: Node4-network + Node5: + name: Node5-network diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 154031e825..e07f6dfb98 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -30,3 +30,9 @@ services: file: docker-compose.base.yml service: Node4 network_mode: host + + Node5: + extends: + file: docker-compose.base.yml + service: Node5 + network_mode: host From f66ea77ed726882fe57b02ef66d3613f89b937ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Mon, 28 Nov 2022 14:10:16 +0100 Subject: [PATCH 03/17] Finalization check --- .github/workflows/e2e-tests-main-devnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests-main-devnet.yml b/.github/workflows/e2e-tests-main-devnet.yml index 4496db3c09..2dd263504b 100644 --- a/.github/workflows/e2e-tests-main-devnet.yml +++ b/.github/workflows/e2e-tests-main-devnet.yml @@ -454,7 +454,7 @@ jobs: node-count: 6 reserved-seats: 3 non-reserved-seats: 3 - follow-up-finalization-check: false + follow-up-finalization-check: true timeout-minutes: 15 run-e2e-ban-automatic: From ca76514e29bb7cd2a29c4b7520d376f7d5d92652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Mon, 28 Nov 2022 15:12:01 +0100 Subject: [PATCH 04/17] Max node count --- .github/scripts/run_consensus.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/scripts/run_consensus.sh b/.github/scripts/run_consensus.sh index b04f50f44e..e77e09fbb5 100755 --- a/.github/scripts/run_consensus.sh +++ b/.github/scripts/run_consensus.sh @@ -5,6 +5,8 @@ set -euo pipefail # default node count # change when increasing the number of node containers NODE_COUNT=5 +# max node count that will not crash current GH machines +MAX_NODE_COUNT=6 # default minimum validator count MIN_VALIDATOR_COUNT=4 DOCKER_COMPOSE=${DOCKER_COMPOSE:-"docker/docker-compose.yml"} @@ -48,6 +50,11 @@ done export NODE_COUNT +if [[${NODE_COUNT} -gt ${MAX_NODE_COUNT}]]; then + echo "Tried to run ${NODE_COUNT}. Max node count allowed: ${MAX_NODE_COUNT}." + exit 1 +fi + function generate_authorities { local authorities_count="$1" From db687ecab7131c0f97d91e0674fc8b9ecd84f4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Mon, 28 Nov 2022 15:37:01 +0100 Subject: [PATCH 05/17] GH action fix --- .github/actions/run-e2e-test/action.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/actions/run-e2e-test/action.yml b/.github/actions/run-e2e-test/action.yml index e824586fc5..15253f80b1 100644 --- a/.github/actions/run-e2e-test/action.yml +++ b/.github/actions/run-e2e-test/action.yml @@ -70,14 +70,9 @@ runs: -m "${{ inputs.min-validator-count }}" ) - NODE_COUNT="${{ inputs.node-count }}" RESERVED_SEATS="${{ inputs.reserved-seats }}" NON_RESERVED_SEATS="${{ inputs.non-reserved-seats }}" - if [[ -n "${NODE_COUNT}" ]]; then - ARGS+=(-v "${NODE_COUNT}") - fi - if [[ -n "${RANDOMIZED}" ]]; then ARGS+=(-r "${RANDOMIZED}") fi From 05a9e81f6d54ef2d3685eb4972e778eea094d765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Mon, 28 Nov 2022 15:43:07 +0100 Subject: [PATCH 06/17] Improved error message --- .github/scripts/run_consensus.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/run_consensus.sh b/.github/scripts/run_consensus.sh index e77e09fbb5..349b19037b 100755 --- a/.github/scripts/run_consensus.sh +++ b/.github/scripts/run_consensus.sh @@ -51,7 +51,7 @@ done export NODE_COUNT if [[${NODE_COUNT} -gt ${MAX_NODE_COUNT}]]; then - echo "Tried to run ${NODE_COUNT}. Max node count allowed: ${MAX_NODE_COUNT}." + echo "Tried to run ${NODE_COUNT} nodes. Max node count allowed: ${MAX_NODE_COUNT}." exit 1 fi From 3a6342884f756441bded25aa92922f11751a8f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Mon, 28 Nov 2022 16:18:05 +0100 Subject: [PATCH 07/17] Increased node count --- .github/scripts/run_consensus.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/run_consensus.sh b/.github/scripts/run_consensus.sh index 349b19037b..e3cfdcad73 100755 --- a/.github/scripts/run_consensus.sh +++ b/.github/scripts/run_consensus.sh @@ -4,7 +4,7 @@ set -euo pipefail # default node count # change when increasing the number of node containers -NODE_COUNT=5 +NODE_COUNT=6 # max node count that will not crash current GH machines MAX_NODE_COUNT=6 # default minimum validator count From e53cd09543cebe2d63ce13c05c80ea85fa2d1588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Tue, 29 Nov 2022 09:05:31 +0100 Subject: [PATCH 08/17] Increased timeout for authorities are staking e2e test --- .github/workflows/e2e-tests-main-devnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests-main-devnet.yml b/.github/workflows/e2e-tests-main-devnet.yml index 2dd263504b..e801f750af 100644 --- a/.github/workflows/e2e-tests-main-devnet.yml +++ b/.github/workflows/e2e-tests-main-devnet.yml @@ -455,7 +455,7 @@ jobs: reserved-seats: 3 non-reserved-seats: 3 follow-up-finalization-check: true - timeout-minutes: 15 + timeout-minutes: 20 run-e2e-ban-automatic: needs: [build-test-docker, build-test-client] From 404a3d24275d388117c75876b99f144b7b15b13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Tue, 29 Nov 2022 10:52:19 +0100 Subject: [PATCH 09/17] Removed post-test finalization check --- .github/workflows/e2e-tests-main-devnet.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests-main-devnet.yml b/.github/workflows/e2e-tests-main-devnet.yml index e801f750af..4496db3c09 100644 --- a/.github/workflows/e2e-tests-main-devnet.yml +++ b/.github/workflows/e2e-tests-main-devnet.yml @@ -454,8 +454,8 @@ jobs: node-count: 6 reserved-seats: 3 non-reserved-seats: 3 - follow-up-finalization-check: true - timeout-minutes: 20 + follow-up-finalization-check: false + timeout-minutes: 15 run-e2e-ban-automatic: needs: [build-test-docker, build-test-client] From ba280afd86143022d47c90906215bdac4015fa2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Tue, 6 Dec 2022 13:58:46 +0100 Subject: [PATCH 10/17] Script fix --- .github/scripts/run_consensus.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/run_consensus.sh b/.github/scripts/run_consensus.sh index e3cfdcad73..c797700119 100755 --- a/.github/scripts/run_consensus.sh +++ b/.github/scripts/run_consensus.sh @@ -50,7 +50,7 @@ done export NODE_COUNT -if [[${NODE_COUNT} -gt ${MAX_NODE_COUNT}]]; then +if [[ ${NODE_COUNT} -gt ${MAX_NODE_COUNT} ]]; then echo "Tried to run ${NODE_COUNT} nodes. Max node count allowed: ${MAX_NODE_COUNT}." exit 1 fi From fbb2f52f5cc81c404157dd9c374a9e8f2eb73f94 Mon Sep 17 00:00:00 2001 From: Marcin Date: Tue, 10 Jan 2023 13:29:40 +0100 Subject: [PATCH 11/17] Make sure rotate keys is done for every validator separately --- e2e-tests/Cargo.lock | 2 +- e2e-tests/src/validators.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-tests/Cargo.lock b/e2e-tests/Cargo.lock index 69fa1e40ed..9ee234048f 100644 --- a/e2e-tests/Cargo.lock +++ b/e2e-tests/Cargo.lock @@ -78,7 +78,7 @@ dependencies = [ [[package]] name = "aleph_client" -version = "2.6.0" +version = "2.7.0" dependencies = [ "anyhow", "async-trait", diff --git a/e2e-tests/src/validators.rs b/e2e-tests/src/validators.rs index 850dbad40f..1cc1aacfd7 100644 --- a/e2e-tests/src/validators.rs +++ b/e2e-tests/src/validators.rs @@ -138,9 +138,9 @@ pub async fn prepare_validators( })); } - for controller in accounts.controller_raw_keys.iter() { + for (port, controller) in accounts.controller_raw_keys.iter().enumerate() { + let connection = SignedConnection::new(format!("ws://127.0.0.1:{}", 9943 + port).as_str(), KeyPair::new(controller.clone())).await; let keys = connection.author_rotate_keys().await?; - let connection = SignedConnection::new(node, KeyPair::new(controller.clone())).await; handles.push(tokio::spawn(async move { connection .set_keys(keys, TxStatus::Finalized) From 1fbf0f399bf98242443d0ca636506e2a0c752d00 Mon Sep 17 00:00:00 2001 From: Marcin Date: Tue, 10 Jan 2023 14:12:42 +0100 Subject: [PATCH 12/17] fmt --- e2e-tests/src/validators.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/e2e-tests/src/validators.rs b/e2e-tests/src/validators.rs index 1cc1aacfd7..e73e23bade 100644 --- a/e2e-tests/src/validators.rs +++ b/e2e-tests/src/validators.rs @@ -139,7 +139,11 @@ pub async fn prepare_validators( } for (port, controller) in accounts.controller_raw_keys.iter().enumerate() { - let connection = SignedConnection::new(format!("ws://127.0.0.1:{}", 9943 + port).as_str(), KeyPair::new(controller.clone())).await; + let connection = SignedConnection::new( + format!("ws://127.0.0.1:{}", 9943 + port).as_str(), + KeyPair::new(controller.clone()), + ) + .await; let keys = connection.author_rotate_keys().await?; handles.push(tokio::spawn(async move { connection From ba56d3ba016fb1a1757502486843f50b3ae1e17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Tue, 10 Jan 2023 14:43:29 +0100 Subject: [PATCH 13/17] Ip address and ports from config --- e2e-tests/src/validators.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/e2e-tests/src/validators.rs b/e2e-tests/src/validators.rs index e73e23bade..4c3d9782b6 100644 --- a/e2e-tests/src/validators.rs +++ b/e2e-tests/src/validators.rs @@ -138,9 +138,15 @@ pub async fn prepare_validators( })); } + let address_tokens = node.split(":").collect::>(); + let ip_address = address_tokens[0]; + let first_port = address_tokens[1]; + + // Assumes the same ip address and consecutive ports for nodes, e.g. ws://127.0.0.1:9943, + // ws://127.0.0.1:9944, etc. for (port, controller) in accounts.controller_raw_keys.iter().enumerate() { let connection = SignedConnection::new( - format!("ws://127.0.0.1:{}", 9943 + port).as_str(), + format!("{}:{}", ip_address, first_port + port).as_str(), KeyPair::new(controller.clone()), ) .await; From 6c8cd68ccb65c3052c3d13e1ad63201de59c72ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Wed, 11 Jan 2023 20:13:55 +0100 Subject: [PATCH 14/17] WS params parsing; default node count change --- .github/scripts/run_consensus.sh | 3 +-- .github/workflows/nightly-pipeline.yaml | 2 +- benches/payout-stakers/Cargo.lock | 2 +- e2e-tests/src/config.rs | 2 +- e2e-tests/src/validators.rs | 9 +++++---- flooder/Cargo.lock | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/scripts/run_consensus.sh b/.github/scripts/run_consensus.sh index 9cdf12703d..d1e8092645 100755 --- a/.github/scripts/run_consensus.sh +++ b/.github/scripts/run_consensus.sh @@ -3,8 +3,7 @@ set -euo pipefail # default node count -# change when increasing the number of node containers -NODE_COUNT=6 +NODE_COUNT=5 # max node count that will not crash current GH machines MAX_NODE_COUNT=6 # default minimum validator count diff --git a/.github/workflows/nightly-pipeline.yaml b/.github/workflows/nightly-pipeline.yaml index a426f97ffc..b7ecb9fcf1 100644 --- a/.github/workflows/nightly-pipeline.yaml +++ b/.github/workflows/nightly-pipeline.yaml @@ -170,7 +170,7 @@ jobs: uses: ./.github/actions/run-e2e-test with: test-case: authorities_are_staking - randomized: true + node-count: 6 timeout-minutes: 60 run-e2e-high-out-latency: diff --git a/benches/payout-stakers/Cargo.lock b/benches/payout-stakers/Cargo.lock index 9b1dad9c35..c80accd682 100644 --- a/benches/payout-stakers/Cargo.lock +++ b/benches/payout-stakers/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "aleph_client" -version = "2.6.0" +version = "2.7.0" dependencies = [ "anyhow", "async-trait", diff --git a/e2e-tests/src/config.rs b/e2e-tests/src/config.rs index 10d781bd4f..b79b27de74 100644 --- a/e2e-tests/src/config.rs +++ b/e2e-tests/src/config.rs @@ -86,7 +86,7 @@ impl Config { RootConnection::new(&self.node, sudo_keypair).await.unwrap() } - pub fn validator_names<'a>(&'a self) -> Vec { + pub fn validator_names(&self) -> Vec { (0..self.validator_count) .map(|id| format!("Node{}", id)) .collect() diff --git a/e2e-tests/src/validators.rs b/e2e-tests/src/validators.rs index 4c3d9782b6..6f246cb533 100644 --- a/e2e-tests/src/validators.rs +++ b/e2e-tests/src/validators.rs @@ -138,15 +138,16 @@ pub async fn prepare_validators( })); } - let address_tokens = node.split(":").collect::>(); - let ip_address = address_tokens[0]; - let first_port = address_tokens[1]; + let address_tokens = node.split(':').collect::>(); + let ws = address_tokens[0]; + let ip_address = address_tokens[1]; + let first_port = address_tokens[2].parse::()?; // Assumes the same ip address and consecutive ports for nodes, e.g. ws://127.0.0.1:9943, // ws://127.0.0.1:9944, etc. for (port, controller) in accounts.controller_raw_keys.iter().enumerate() { let connection = SignedConnection::new( - format!("{}:{}", ip_address, first_port + port).as_str(), + format!("{}:{}:{}", ws, ip_address, first_port + port).as_str(), KeyPair::new(controller.clone()), ) .await; diff --git a/flooder/Cargo.lock b/flooder/Cargo.lock index 7abb059b74..82abc52881 100644 --- a/flooder/Cargo.lock +++ b/flooder/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "aleph_client" -version = "2.6.0" +version = "2.7.0" dependencies = [ "anyhow", "async-trait", From 2683ce55ea1f64ac031e00dc286212c031b950fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Wed, 11 Jan 2023 20:17:28 +0100 Subject: [PATCH 15/17] Follow up finalization check --- .github/workflows/nightly-pipeline.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nightly-pipeline.yaml b/.github/workflows/nightly-pipeline.yaml index b7ecb9fcf1..5933a1c8c9 100644 --- a/.github/workflows/nightly-pipeline.yaml +++ b/.github/workflows/nightly-pipeline.yaml @@ -171,6 +171,7 @@ jobs: with: test-case: authorities_are_staking node-count: 6 + follow-up-finalization-check: true timeout-minutes: 60 run-e2e-high-out-latency: From ba8631ea27252e7712de0d6335f5055052ee2ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Wed, 11 Jan 2023 20:55:24 +0100 Subject: [PATCH 16/17] Patch version bump --- e2e-tests/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-tests/Cargo.toml b/e2e-tests/Cargo.toml index 2f78045ad2..7f027d28a5 100644 --- a/e2e-tests/Cargo.toml +++ b/e2e-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aleph-e2e-client" -version = "0.10.0" +version = "0.10.1" edition = "2021" license = "Apache 2.0" From 678ecb119d0d07c6195f93ec49b027ff7e1f3441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBelaszczyk?= Date: Thu, 12 Jan 2023 17:42:30 +0100 Subject: [PATCH 17/17] Extracted controller connections; minor fixes --- e2e-tests/Cargo.lock | 2 +- e2e-tests/src/test/electing_validators.rs | 7 ++-- e2e-tests/src/validators.rs | 40 +++++++++++++++-------- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/e2e-tests/Cargo.lock b/e2e-tests/Cargo.lock index 9ee234048f..3ff38122d4 100644 --- a/e2e-tests/Cargo.lock +++ b/e2e-tests/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "aleph-e2e-client" -version = "0.10.0" +version = "0.10.1" dependencies = [ "aleph_client", "anyhow", diff --git a/e2e-tests/src/test/electing_validators.rs b/e2e-tests/src/test/electing_validators.rs index 59bdfc65b7..d5767ad998 100644 --- a/e2e-tests/src/test/electing_validators.rs +++ b/e2e-tests/src/test/electing_validators.rs @@ -15,7 +15,7 @@ use primitives::EraIndex; use crate::{ config::setup_test, - validators::{prepare_validators, setup_accounts}, + validators::{get_controller_connections_to_nodes, prepare_validators, setup_accounts}, }; /// Verify that `pallet_staking::ErasStakers` contains all target validators. @@ -179,7 +179,10 @@ pub async fn authorities_are_staking() -> anyhow::Result<()> { let desired_validator_count = reserved_seats + non_reserved_seats; let accounts = setup_accounts(desired_validator_count); - prepare_validators(&root_connection, node, &accounts).await?; + let controller_connections = + get_controller_connections_to_nodes(node, accounts.get_controller_raw_keys().clone()) + .await?; + prepare_validators(&root_connection, node, &accounts, controller_connections).await?; info!("New validators are set up"); let reserved_validators = accounts.get_stash_accounts()[..reserved_seats as usize].to_vec(); diff --git a/e2e-tests/src/validators.rs b/e2e-tests/src/validators.rs index 6f246cb533..3a6c6dab54 100644 --- a/e2e-tests/src/validators.rs +++ b/e2e-tests/src/validators.rs @@ -108,6 +108,7 @@ pub async fn prepare_validators( connection: &S, node: &str, accounts: &Accounts, + controller_connections: Vec, ) -> anyhow::Result<()> { connection .batch_transfer( @@ -138,19 +139,7 @@ pub async fn prepare_validators( })); } - let address_tokens = node.split(':').collect::>(); - let ws = address_tokens[0]; - let ip_address = address_tokens[1]; - let first_port = address_tokens[2].parse::()?; - - // Assumes the same ip address and consecutive ports for nodes, e.g. ws://127.0.0.1:9943, - // ws://127.0.0.1:9944, etc. - for (port, controller) in accounts.controller_raw_keys.iter().enumerate() { - let connection = SignedConnection::new( - format!("{}:{}:{}", ws, ip_address, first_port + port).as_str(), - KeyPair::new(controller.clone()), - ) - .await; + for connection in controller_connections { let keys = connection.author_rotate_keys().await?; handles.push(tokio::spawn(async move { connection @@ -164,3 +153,28 @@ pub async fn prepare_validators( join_all(handles).await; Ok(()) } + +// Assumes the same ip address and consecutive ports for nodes, e.g. ws://127.0.0.1:9943, +// ws://127.0.0.1:9944, etc. +pub async fn get_controller_connections_to_nodes( + first_node_address: &str, + controller_raw_keys: Vec, +) -> anyhow::Result> { + let address_tokens = first_node_address.split(':').collect::>(); + let prefix = format!("{}:{}", address_tokens[0], address_tokens[1]); + let address_prefix = prefix.as_str(); + let first_port = address_tokens[2].parse::()?; + let controller_connections = + controller_raw_keys + .into_iter() + .enumerate() + .map(|(port_idx, controller)| async move { + SignedConnection::new( + format!("{}:{}", address_prefix, first_port + port_idx as u16).as_str(), + KeyPair::new(controller), + ) + .await + }); + let connections = join_all(controller_connections.collect::>()).await; + Ok(connections) +}