Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add three-node devnet-local configuration #940

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ target
.cargo-remote.toml
.entropy
chains

# We specifically want to include the `create-test-keyshares` crate as part of our builds.
scripts
!scripts/create-test-keyshares/

service
shell.nix

Expand Down
38 changes: 38 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,41 @@ services:
- "/dns4/alice-chain-node/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"
- "--tss-server-endpoint"
- "http://bob-tss-server:3002"

# "Charlie's TSS server."
charlie-tss-server:
extends:
file: docker-compose-common.yaml
service: tss-server
ports:
- "127.0.0.1:3003:3003/tcp"
HCastano marked this conversation as resolved.
Show resolved Hide resolved
command:
- "--charlie"
- "--threshold-url"
- "0.0.0.0:3003"
- "--chain-endpoint"
- "ws://charlie-chain-node:9944"
- "--no-sync"

# "Charlie's chain node."
charlie-chain-node:
extends:
file: docker-compose-common.yaml
service: chain-node
ports:
- "127.0.0.1:9946:9944/tcp"
command:
- "--chain"
- "devnet-local"
- "--charlie" # Shortcut for `--name Charlie --validator`
- "--base-path"
- ".entropy/charlie"
- "--rpc-port"
- "9944"
- "--rpc-cors"
- "all"
- "--unsafe-rpc-external" # Intentional, for TSS's access.
- "--bootnodes"
- "/dns4/alice-chain-node/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"
- "--tss-server-endpoint"
- "http://charlie-tss-server:3003"
29 changes: 18 additions & 11 deletions node/cli/src/chain_spec/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use sp_consensus_babe::AuthorityId as BabeId;
use sp_core::sr25519;
use sp_runtime::{BoundedVec, Perbill};

pub fn devnet_two_node_initial_tss_servers(
pub fn devnet_three_node_initial_tss_servers(
) -> Vec<(sp_runtime::AccountId32, TssX25519PublicKey, String)> {
let alice = (
crate::chain_spec::tss_account_id::ALICE.clone(),
Expand All @@ -60,7 +60,7 @@ pub fn devnet_two_node_initial_tss_servers(
vec![alice, bob, charlie]
}

pub fn devnet_local_docker_two_node_initial_tss_servers(
pub fn devnet_local_docker_three_node_initial_tss_servers(
) -> Vec<(sp_runtime::AccountId32, TssX25519PublicKey, String)> {
let alice = (
crate::chain_spec::tss_account_id::ALICE.clone(),
Expand All @@ -74,7 +74,13 @@ pub fn devnet_local_docker_two_node_initial_tss_servers(
"bob-tss-server:3002".to_string(),
);

vec![alice, bob]
let charlie = (
crate::chain_spec::tss_account_id::CHARLIE.clone(),
crate::chain_spec::tss_x25519_public_key::CHARLIE,
"charlie-tss-server:3003".to_string(),
);

vec![alice, bob, charlie]
}

pub fn devnet_local_docker_four_node_initial_tss_servers(
Expand Down Expand Up @@ -108,8 +114,8 @@ pub fn devnet_local_docker_four_node_initial_tss_servers(

/// The configuration used for development.
///
/// Since Entropy requires at least two signing groups to work properly we spin up this network with
/// two validators, Alice and Bob.
/// Since Entropy requires at two-of-three threshold setup, we spin up three validators: Alice, Bob,
/// and Charlie.
pub fn development_config() -> ChainSpec {
ChainSpec::builder(wasm_binary_unwrap(), Default::default())
.with_name("Development")
Expand All @@ -124,17 +130,17 @@ pub fn development_config() -> ChainSpec {
],
vec![],
get_account_id_from_seed::<sr25519::Public>("Alice"),
devnet_two_node_initial_tss_servers(),
devnet_three_node_initial_tss_servers(),
))
.build()
}

/// The configuration used for a local development network spun up with the `docker-compose` setup
/// provided in this repository.
///
/// Since Entropy requires at least two signing groups to work properly we spin up this network with
/// two validators, Alice and Bob.
pub fn devnet_local_two_node_config() -> crate::chain_spec::ChainSpec {
/// Since Entropy requires at two-of-three threshold setup, we spin up three validators: Alice, Bob,
/// and Charlie.
pub fn devnet_local_three_node_config() -> crate::chain_spec::ChainSpec {
ChainSpec::builder(wasm_binary_unwrap(), Default::default())
.with_name("Devnet Local")
.with_id("devnet_local")
Expand All @@ -144,17 +150,18 @@ pub fn devnet_local_two_node_config() -> crate::chain_spec::ChainSpec {
vec![
crate::chain_spec::authority_keys_from_seed("Alice"),
crate::chain_spec::authority_keys_from_seed("Bob"),
crate::chain_spec::authority_keys_from_seed("Charlie"),
],
vec![],
get_account_id_from_seed::<sr25519::Public>("Alice"),
devnet_local_docker_two_node_initial_tss_servers(),
devnet_local_docker_three_node_initial_tss_servers(),
))
.build()
}

/// The configuration used for a local four-node development network spun up using `docker-compose`.
///
/// Note that this repository does not provide an example of that, but the provided two-node
/// Note that this repository does not provide an example of that, but the provided three-node
/// `docker-compose` setup can be used as a reference.
pub fn devnet_local_four_node_config() -> crate::chain_spec::ChainSpec {
ChainSpec::builder(wasm_binary_unwrap(), Default::default())
Expand Down
6 changes: 3 additions & 3 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ impl SubstrateCli for Cli {

// | --chain | Description |
// |----------------- |----------- |
// | dev | Two nodes, Two threshold servers, Alice and Bob, Development Configuration |
// | devnet-local | Two nodes, Two threshold servers, Alice and Bob, Development Configuration, Docker Compatible |
// | dev | Three nodes, Three threshold servers, Alice Bob and Charlie, Development Configuration |
// | devnet-local | Three nodes, Three threshold servers, Alice Bob and Charlie, Development Configuration, Docker Compatible |
// | devnet-local-four-nodes | Four Nodes, Four threshold servers, Alice, Bob, Dave, Eve, Testnet Configuration, Docker Compatible |
// | integration-tests | Two nodes, Four threshold servers, Alice and Bob, Development Configuration |
// | testnet-local | Two Nodes, Two threshold servers, Alice and Bob, Testnet Configuration, Docker Compatible |
// | testnet | Four nodes, Two threshold servers, Own Seed, Testnet Configuration |
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
"" | "dev" => Box::new(chain_spec::dev::development_config()),
"devnet-local" => Box::new(chain_spec::dev::devnet_local_two_node_config()),
"devnet-local" => Box::new(chain_spec::dev::devnet_local_three_node_config()),
"devnet-local-four-nodes" => Box::new(chain_spec::dev::devnet_local_four_node_config()),
"integration-tests" => {
Box::new(chain_spec::integration_tests::integration_tests_config())
Expand Down