Skip to content

Commit

Permalink
Merge branch 'master' into peg/use-published-tdx-quote-configfs-tsm
Browse files Browse the repository at this point in the history
  • Loading branch information
HCastano committed Oct 2, 2024
2 parents 6a8fb6e + cbafc15 commit ad61c14
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 94 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ At the moment this project **does not** adhere to
data structures related to a candidates state (namely `ThresholdToStash` and `ThresholdServer`) an
attestation from the Attestation pallet must have been received. Success of the `validate()`
extrinsic **does not** mean the caller is a candidate or validator.
- In [#1086](https://github.com/entropyxyz/entropy-core/pull/1086) `Eve` was removed as a validator
from the `devnet-local` chainspec and replaced with `Charlie`.

### Added
- Jumpstart network ([#918](https://github.com/entropyxyz/entropy-core/pull/918))
Expand All @@ -58,6 +60,7 @@ At the moment this project **does not** adhere to
- No unbonding when signer or next signer ([#1031](https://github.com/entropyxyz/entropy-core/pull/1031))
- Add relay tx endpoint ([#1050](https://github.com/entropyxyz/entropy-core/pull/1050))
- Trigger attestation check during validate ([#1063](https://github.com/entropyxyz/entropy-core/pull/1063))
- Add fourth node to `devnet-local` configuration ([#1086](https://github.com/entropyxyz/entropy-core/pull/1086))

### Removed
- Remove `prune_registration` extrinsic ([#1022](https://github.com/entropyxyz/entropy-core/pull/1022))
Expand Down
8 changes: 5 additions & 3 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ use base64::prelude::{Engine, BASE64_STANDARD};
use entropy_protocol::RecoverableSignature;
use entropy_shared::HashingAlgorithm;
use futures::stream::StreamExt;
use sp_core::{sr25519, Pair};
use sp_core::{
sr25519::{self, Signature},
Pair,
};
use subxt::{
backend::legacy::LegacyRpcMethods,
ext::sp_core::sr25519::Signature,
utils::{AccountId32 as SubxtAccountId32, H256},
Config, OnlineClient,
};
Expand Down Expand Up @@ -327,7 +329,7 @@ pub async fn put_register_request_on_chain(
let registered_event = registered_events
.find::<entropy::registry::events::AccountRegistered>()
.flatten()
.find_map(|event| (event.0 == signature_request_keypair.public().into()).then_some(event))
.find_map(|event| (event.0 == signature_request_keypair.public().0.into()).then_some(event))
.ok_or(ClientError::NotRegistered);

registered_event
Expand Down
62 changes: 36 additions & 26 deletions crates/threshold-signature-server/src/user/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,8 +1304,6 @@ async fn test_device_key_proxy() {
verify_signature(test_user_res, message_hash, &verifying_key, &all_signers_info).await;
}

/// FIXME (#909): Ignored due to block number changing message causing signing selection to be the incorrect nodes
#[ignore]
#[tokio::test]
#[serial]
async fn test_faucet() {
Expand Down Expand Up @@ -1334,13 +1332,46 @@ async fn test_faucet() {
let alice = AccountKeyring::Alice;

let (_validator_ips, _validator_ids) =
spawn_testing_validators(ChainSpecType::Development).await;
let relayer_ip_and_key = ("localhost:3001".to_string(), X25519_PUBLIC_KEYS[0]);
spawn_testing_validators(ChainSpecType::Integration).await;
let substrate_context = &test_node_process_testing_state(true).await[0];
let entropy_api = get_api(&substrate_context.ws_url).await.unwrap();
let rpc = get_rpc(&substrate_context.ws_url).await.unwrap();

let verifying_key = EVE_VERIFYING_KEY;
let non_signer = jump_start_network(&entropy_api, &rpc).await.unwrap();
let (relayer_ip_and_key, _) =
validator_name_to_relayer_info(non_signer, &entropy_api, &rpc).await;

let program_hash = test_client::store_program(
&entropy_api,
&rpc,
&two.pair(),
FAUCET_PROGRAM.to_owned(),
vec![],
vec![],
vec![],
0u8,
)
.await
.unwrap();

let amount_to_send = 200000001;
let genesis_hash = &entropy_api.genesis_hash();

let faucet_user_config = UserConfig {
max_transfer_amount: amount_to_send,
genesis_hash: hex::encode(genesis_hash.encode()),
};

let (verifying_key, _registered_info) = test_client::register(
&entropy_api,
&rpc,
one.clone().into(), // This is our program modification account
subxtAccountId32(two.public().0), // This is our signature request account
BoundedVec(vec![ProgramInstance { program_pointer: program_hash, program_config: vec![] }]),
)
.await
.unwrap();

let verfiying_key_account_hash = blake2_256(&verifying_key);
let verfiying_key_account = subxtAccountId32(verfiying_key_account_hash);

Expand All @@ -1364,27 +1395,6 @@ async fn test_faucet() {
.await
.unwrap();

let program_hash = test_client::store_program(
&entropy_api,
&rpc,
&two.pair(),
FAUCET_PROGRAM.to_owned(),
vec![],
vec![],
vec![],
0u8,
)
.await
.unwrap();

let amount_to_send = 200000001;
let genesis_hash = &entropy_api.genesis_hash();

let faucet_user_config = UserConfig {
max_transfer_amount: amount_to_send,
genesis_hash: hex::encode(genesis_hash.encode()),
};

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

# "Dave's TSS server."
dave-tss-server:
extends:
file: docker-compose-common.yaml
service: tss-server
ports:
- "127.0.0.1:3004:3004/tcp"
command:
- "--dave"
- "--threshold-url"
- "0.0.0.0:3004"
- "--chain-endpoint"
- "ws://dave-chain-node:9944"
- "--no-sync"

# "Dave's chain node."
dave-chain-node:
extends:
file: docker-compose-common.yaml
service: chain-node
ports:
- "127.0.0.1:9947:9944/tcp"
command:
- "--chain"
- "devnet-local"
- "--dave" # Shortcut for `--name Dave --validator`
- "--base-path"
- ".entropy/dave"
- "--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://dave-tss-server:3004"
79 changes: 19 additions & 60 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, ByteArray};
use sp_runtime::{BoundedVec, Perbill};

pub fn devnet_three_node_initial_tss_servers(
pub fn devnet_four_node_initial_tss_servers(
) -> Vec<(sp_runtime::AccountId32, TssX25519PublicKey, String, BoundedVecEncodedVerifyingKey)> {
let alice = (
crate::chain_spec::tss_account_id::ALICE.clone(),
Expand All @@ -60,10 +60,17 @@ pub fn devnet_three_node_initial_tss_servers(
provisioning_certification_key::CHARLIE.clone(),
);

vec![alice, bob, charlie]
let dave = (
crate::chain_spec::tss_account_id::DAVE.clone(),
crate::chain_spec::tss_x25519_public_key::DAVE,
"127.0.0.1:3004".to_string(),
provisioning_certification_key::DAVE.clone(),
);

vec![alice, bob, charlie, dave]
}

pub fn devnet_local_docker_three_node_initial_tss_servers(
pub fn devnet_local_docker_four_node_initial_tss_servers(
) -> Vec<(sp_runtime::AccountId32, TssX25519PublicKey, String, BoundedVecEncodedVerifyingKey)> {
let alice = (
crate::chain_spec::tss_account_id::ALICE.clone(),
Expand All @@ -86,46 +93,20 @@ pub fn devnet_local_docker_three_node_initial_tss_servers(
provisioning_certification_key::CHARLIE.clone(),
);

vec![alice, bob, charlie]
}

pub fn devnet_local_docker_four_node_initial_tss_servers(
) -> Vec<(sp_runtime::AccountId32, TssX25519PublicKey, String, BoundedVecEncodedVerifyingKey)> {
let alice = (
crate::chain_spec::tss_account_id::ALICE.clone(),
crate::chain_spec::tss_x25519_public_key::ALICE,
"alice-tss-server:3001".to_string(),
provisioning_certification_key::ALICE.clone(),
);

let bob = (
crate::chain_spec::tss_account_id::BOB.clone(),
crate::chain_spec::tss_x25519_public_key::BOB,
"bob-tss-server:3002".to_string(),
provisioning_certification_key::BOB.clone(),
);

let dave = (
crate::chain_spec::tss_account_id::DAVE.clone(),
crate::chain_spec::tss_x25519_public_key::DAVE,
"dave-tss-server:3003".to_string(),
"dave-tss-server:3004".to_string(),
provisioning_certification_key::DAVE.clone(),
);

let eve = (
crate::chain_spec::tss_account_id::EVE.clone(),
crate::chain_spec::tss_x25519_public_key::EVE_TSS,
"eve-tss-server:3004".to_string(),
provisioning_certification_key::EVE.clone(),
);

vec![alice, bob, dave, eve]
vec![alice, bob, charlie, dave]
}

/// The configuration used for development.
///
/// Since Entropy requires at two-of-three threshold setup, we spin up three validators: Alice, Bob,
/// and Charlie.
/// Since Entropy requires at two-of-three threshold setup, and requires an additional relayer node,
/// we spin up four validators: Alice, Bob, Charlie and Dave.
pub fn development_config() -> ChainSpec {
ChainSpec::builder(wasm_binary_unwrap(), Default::default())
.with_name("Development")
Expand All @@ -137,20 +118,21 @@ pub fn development_config() -> ChainSpec {
crate::chain_spec::authority_keys_from_seed("Alice"),
crate::chain_spec::authority_keys_from_seed("Bob"),
crate::chain_spec::authority_keys_from_seed("Charlie"),
crate::chain_spec::authority_keys_from_seed("Dave"),
],
vec![],
get_account_id_from_seed::<sr25519::Public>("Alice"),
devnet_three_node_initial_tss_servers(),
devnet_four_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 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 {
/// Since Entropy requires at two-of-three threshold setup, and requires an additional relayer node,
/// we spin up four validators: Alice, Bob, Charlie and Dave.
pub fn devnet_local_four_node_config() -> crate::chain_spec::ChainSpec {
ChainSpec::builder(wasm_binary_unwrap(), Default::default())
.with_name("Devnet Local")
.with_id("devnet_local")
Expand All @@ -161,35 +143,12 @@ pub fn devnet_local_three_node_config() -> crate::chain_spec::ChainSpec {
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_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 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())
.with_name("Devnet Local Large")
.with_id("devnet_local_four_nodes")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(development_genesis_config(
vec![
crate::chain_spec::authority_keys_from_seed("Alice"),
crate::chain_spec::authority_keys_from_seed("Bob"),
crate::chain_spec::authority_keys_from_seed("Dave"),
crate::chain_spec::authority_keys_from_seed("Eve"),
],
vec![],
get_account_id_from_seed::<sr25519::Public>("Alice"),
devnet_local_docker_four_node_initial_tss_servers(),
))
.with_properties(crate::chain_spec::entropy_properties())
.build()
}

Expand Down
1 change: 1 addition & 0 deletions node/cli/src/chain_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ pub mod tss_x25519_public_key {

// The `DEFAULT_EVE_MNEMONIC` is used to derive the public key for the tss version of eve
/// Mnemonic: "impact federal dish number fun crisp various wedding radio immense whisper glue"
#[allow(dead_code)]
pub const EVE_TSS: [u8; 32] = [
66, 106, 241, 196, 65, 224, 212, 85, 99, 184, 198, 249, 172, 237, 47, 2, 151, 182, 0, 74,
210, 39, 102, 193, 107, 13, 12, 153, 27, 83, 146, 63,
Expand Down
8 changes: 3 additions & 5 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,15 @@ impl SubstrateCli for Cli {

// | --chain | Description |
// |----------------- |----------- |
// | 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 |
// | dev | Four nodes, Four threshold servers, Alice Bob and Charlie and Dave, Development Configuration |
// | devnet-local | Four nodes, four threshold servers, Alice Bob Charlie and Dave, Development 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_three_node_config()),
"devnet-local-four-nodes" => Box::new(chain_spec::dev::devnet_local_four_node_config()),
"devnet-local" => Box::new(chain_spec::dev::devnet_local_four_node_config()),
"integration-tests" => {
Box::new(chain_spec::integration_tests::integration_tests_config())
},
Expand Down

0 comments on commit ad61c14

Please sign in to comment.