From 0dd8aed134f126060591546ea9f1a29b44ff291a Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sun, 6 Aug 2023 13:42:16 -0400 Subject: [PATCH] Expand cluster-sm/local testnet to 4 validators for BFT where f=1 --- orchestration/README.md | 5 +++-- orchestration/docker-compose.yml | 2 ++ substrate/node/src/chain_spec.rs | 2 +- tests/coordinator/src/lib.rs | 2 +- tests/coordinator/src/tests/mod.rs | 6 +++--- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/orchestration/README.md b/orchestration/README.md index a9ef1a03..59a3bd1d 100644 --- a/orchestration/README.md +++ b/orchestration/README.md @@ -22,8 +22,9 @@ All commands are assumed to be ran from `/deploy`, not the root folder. * `processor` - Serai processor for one external network. * `serai` - Serai node -* `cluster-sm` - "Alice", "Bob", and "Charlie" Serai nodes, all as validators -* `cluster-lg` - `cluster-sm` with non-validators "Dave", "Eve", and "Ferdie" +* `cluster-sm` - "Alice", "Bob", "Charlie", and "Dave" Serai nodes, all as + validators (enough to achieve BFT with one faulty node) +* `cluster-lg` - `cluster-sm` with non-validators "Eve" and "Ferdie" You can supply one or more profiles to the docker compose command to orchestrate the desired components. diff --git a/orchestration/docker-compose.yml b/orchestration/docker-compose.yml index e25bcde7..ce3fb0d1 100644 --- a/orchestration/docker-compose.yml +++ b/orchestration/docker-compose.yml @@ -168,10 +168,12 @@ services: hostname: serai-dave profiles: - dave + - cluster-sm - cluster-lg environment: CHAIN: local NAME: dave + VALIDATOR: true serai-eve: <<: *serai_defaults diff --git a/substrate/node/src/chain_spec.rs b/substrate/node/src/chain_spec.rs index c467aeb6..3fbdee67 100644 --- a/substrate/node/src/chain_spec.rs +++ b/substrate/node/src/chain_spec.rs @@ -124,7 +124,7 @@ pub fn testnet_config() -> Result { || { testnet_genesis( wasm_binary, - &["Alice", "Bob", "Charlie"], + &["Alice", "Bob", "Charlie", "Dave"], vec![ account_from_name("Alice"), account_from_name("Bob"), diff --git a/tests/coordinator/src/lib.rs b/tests/coordinator/src/lib.rs index 49d0ff26..f6ec1cb3 100644 --- a/tests/coordinator/src/lib.rs +++ b/tests/coordinator/src/lib.rs @@ -36,7 +36,7 @@ pub fn coordinator_instance( ("DB_PATH".to_string(), "./coordinator-db".to_string()), ("SERAI_KEY".to_string(), { use serai_client::primitives::insecure_pair_from_name; - hex::encode(insecure_pair_from_name(name).as_ref().secret.to_bytes()[.. 32].as_ref()) + hex::encode(&insecure_pair_from_name(name).as_ref().secret.to_bytes()[.. 32]) }), ] .into(), diff --git a/tests/coordinator/src/tests/mod.rs b/tests/coordinator/src/tests/mod.rs index 57e3d7e9..25fa9a52 100644 --- a/tests/coordinator/src/tests/mod.rs +++ b/tests/coordinator/src/tests/mod.rs @@ -13,7 +13,7 @@ use dockertest::DockerTest; use crate::*; -pub(crate) const COORDINATORS: usize = 3; +pub(crate) const COORDINATORS: usize = 4; // pub(crate) const THRESHOLD: usize = ((COORDINATORS * 2) / 3) + 1; fn new_test() -> (Vec<(Handles, ::F)>, DockerTest) { @@ -27,7 +27,7 @@ fn new_test() -> (Vec<(Handles, ::F)>, DockerTest) { 3 => "Dave", 4 => "Eve", 5 => "Ferdie", - _ => panic!("needed a 6th name for a serai node"), + _ => panic!("needed a 7th name for a serai node"), }); coordinators.push((handles, coord_key)); for composition in compositions { @@ -63,7 +63,7 @@ async fn stack_test() { }, params: ThresholdParams::new( 3, - 3, + 4, Participant::new(u16::try_from(i).unwrap() + 1).unwrap() ) .unwrap()