Skip to content

Commit

Permalink
Merge branch 'main' into updated_BUILD.md
Browse files Browse the repository at this point in the history
  • Loading branch information
fixxxedpoint authored Jan 13, 2023
2 parents 4b5fec9 + 5e35cda commit dbddae4
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/actions/run-e2e-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ runs:
RESERVED_SEATS="${{ inputs.reserved-seats }}"
NON_RESERVED_SEATS="${{ inputs.non-reserved-seats }}"
if [[ -n "${RANDOMIZED}" ]]; then
ARGS+=(-r "${RANDOMIZED}")
fi
Expand Down
9 changes: 8 additions & 1 deletion .github/scripts/run_consensus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
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"}
OVERRIDE_DOCKER_COMPOSE=${OVERRIDE_DOCKER_COMPOSE:-""}
Expand Down Expand Up @@ -51,6 +53,11 @@ done

export NODE_COUNT

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

function generate_authorities {
local authorities_count="$1"

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nightly-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ jobs:
uses: ./.github/actions/run-e2e-test
with:
test-case: authorities_are_staking
randomized: true
node-count: 6
follow-up-finalization-check: true
timeout-minutes: 60

run-e2e-high-out-latency:
Expand Down
2 changes: 1 addition & 1 deletion benches/payout-stakers/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions docker/docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions docker/docker-compose.bridged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -66,3 +77,5 @@ networks:
name: Node3-network
Node4:
name: Node4-network
Node5:
name: Node5-network
6 changes: 6 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions e2e-tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph-e2e-client"
version = "0.10.0"
version = "0.10.1"
edition = "2021"
license = "Apache 2.0"

Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Config {
RootConnection::new(&self.node, sudo_keypair).await.unwrap()
}

pub fn validator_names<'a>(&'a self) -> Vec<String> {
pub fn validator_names(&self) -> Vec<String> {
(0..self.validator_count)
.map(|id| format!("Node{}", id))
.collect()
Expand Down
7 changes: 5 additions & 2 deletions e2e-tests/src/test/electing_validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
29 changes: 27 additions & 2 deletions e2e-tests/src/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub async fn prepare_validators<S: SignedConnectionApi + AuthorRpc>(
connection: &S,
node: &str,
accounts: &Accounts,
controller_connections: Vec<SignedConnection>,
) -> anyhow::Result<()> {
connection
.batch_transfer(
Expand Down Expand Up @@ -138,9 +139,8 @@ pub async fn prepare_validators<S: SignedConnectionApi + AuthorRpc>(
}));
}

for controller in accounts.controller_raw_keys.iter() {
for connection in controller_connections {
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)
Expand All @@ -153,3 +153,28 @@ pub async fn prepare_validators<S: SignedConnectionApi + AuthorRpc>(
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<RawKeyPair>,
) -> anyhow::Result<Vec<SignedConnection>> {
let address_tokens = first_node_address.split(':').collect::<Vec<_>>();
let prefix = format!("{}:{}", address_tokens[0], address_tokens[1]);
let address_prefix = prefix.as_str();
let first_port = address_tokens[2].parse::<u16>()?;
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::<Vec<_>>()).await;
Ok(connections)
}
2 changes: 1 addition & 1 deletion flooder/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dbddae4

Please sign in to comment.