Skip to content

Commit

Permalink
Merge branch 'master' of github.com:entropyxyz/entropy-core into prog…
Browse files Browse the repository at this point in the history
…rams-version
  • Loading branch information
JesseAbram committed Sep 12, 2024
2 parents 03daff8 + 815c356 commit 9660576
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 160 deletions.
7 changes: 4 additions & 3 deletions 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 crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ reqwest ={ version="0.12.7", features=["json", "stream"], optional=true
base64 ={ version="0.22.0", optional=true }
synedrion ={ git="https://github.com/entropyxyz/synedrion", rev="1d210d149dfeb0dca1dd41d7fac4d0bf03c686fa", optional=true }
hex ={ version="0.4.3", optional=true }
anyhow ="1.0.87"
anyhow ="1.0.88"

# Only for the browser
js-sys={ version="0.3.70", optional=true }
Expand Down
9 changes: 6 additions & 3 deletions crates/client/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ pub async fn get_signers_from_chain(
.await?
.ok_or_else(|| SubgroupGetError::ChainFetch("Get all validators error"))?;

// TODO #898 For now we use a fix proportion of the number of validators as the threshold
let threshold = (validators.len() as f32 * 0.75) as usize;
let key_info_query = entropy::storage().parameters().signers_info();
let threshold = query_chain(api, rpc, key_info_query, None)
.await?
.ok_or_else(|| SubgroupGetError::ChainFetch("Failed to get signers info"))?
.threshold;

// TODO #899 For now we just take the first t validators as the ones to perform signing
validators.truncate(threshold);
validators.truncate(threshold as usize);

let block_hash = rpc.chain_get_block_hash(None).await?;
let mut handles = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ schnorrkel ={ version="0.11.4", default-features=false, features=["std"
[dev-dependencies]
serial_test="3.1.1"
sp-keyring ="34.0.0"
anyhow ="1.0.87"
anyhow ="1.0.88"
num_cpus ="1.16.0"

[features]
Expand Down
2 changes: 1 addition & 1 deletion crates/test-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ clap ={ version="4.5.17", features=["derive"] }
colored ="2.0.4"
subxt ="0.35.3"
sp-core ="31.0.0"
anyhow ="1.0.87"
anyhow ="1.0.88"
tokio ={ version="1.40", features=["macros", "rt-multi-thread", "io-util", "process"] }
hex ="0.4.3"
bincode ="1.3.3"
Expand Down
36 changes: 19 additions & 17 deletions crates/threshold-signature-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition ='2021'
# Common
serde ={ version="1.0", default-features=false, features=["derive"] }
serde_json ="1.0"
anyhow ="1.0.87"
anyhow ="1.0.88"
thiserror ="1.0.63"
blake2 ="0.10.4"
x25519-dalek ={ version="2.0.1", features=["static_secrets"] }
Expand Down Expand Up @@ -57,21 +57,23 @@ uuid ={ version="1.10.0", features=["v4"] }

# Misc
tokio-tungstenite="0.23.1"
bincode ="1.3.3"
bip32 ={ version="0.5.2" }
bip39 ={ version="2.0.0", features=["zeroize"] }
bytes ={ version="1.7", default-features=false, features=["serde"] }
base64 ="0.22.1"
clap ={ version="4.5.17", features=["derive"] }
num ="0.4.3"
snow ="0.9.6"
sha3 ="0.10.8"
hostname ="0.4"
sha1 ="0.10.6"
sha2 ="0.10.8"
hkdf ="0.12.4"
project-root ={ version="0.2.2", optional=true }
tdx-quote ={ git="https://github.com/entropyxyz/tdx-quote", optional=true, features=["mock"] }
bincode="1.3.3"
bip32={ version="0.5.2" }
bip39={ version="2.0.0", features=["zeroize"] }
bytes={ version="1.7", default-features=false, features=["serde"] }
base64="0.22.1"
clap={ version="4.5.17", features=["derive"] }
num="0.4.3"
snow="0.9.6"
sha3="0.10.8"
hostname="0.4"
sha1="0.10.6"
sha2="0.10.8"
hkdf="0.12.4"
project-root={ version="0.2.2", optional=true }
tdx-quote={ git="https://github.com/entropyxyz/tdx-quote", rev="f7968ff", optional=true, features=[
"mock",
] }

[dev-dependencies]
serial_test ="3.1.1"
Expand All @@ -85,7 +87,7 @@ ethers-core ="2.0.14"
schnorrkel ={ version="0.11.4", default-features=false, features=["std"] }
schemars ={ version="0.8.21" }
subxt-signer="0.35.3"
tdx-quote ={ git="https://github.com/entropyxyz/tdx-quote", features=["mock"] }
tdx-quote ={ git="https://github.com/entropyxyz/tdx-quote", rev="f7968ff", features=["mock"] }

# Note: We don't specify versions here because otherwise we run into a cyclical dependency between
# `entropy-tss` and `entropy-testing-utils` when we try and publish the `entropy-tss` crate.
Expand Down
43 changes: 43 additions & 0 deletions crates/threshold-signature-server/src/helpers/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ use crate::{
use axum::{routing::IntoMakeService, Router};
use entropy_kvdb::{encrypted_sled::PasswordMethod, get_db_path, kv_manager::KvManager};
use entropy_protocol::PartyId;
#[cfg(test)]
use entropy_shared::EncodedVerifyingKey;
use entropy_shared::{DAVE_VERIFYING_KEY, EVE_VERIFYING_KEY, NETWORK_PARENT_KEY};
use std::time::Duration;
use subxt::{
Expand Down Expand Up @@ -291,3 +293,44 @@ pub async fn jump_start_network_with_signer(
submit_transaction(api, rpc, &tss_signer, &jump_start_confirm_request, None).await.unwrap();
}
}

/// Helper to store a program and register a user. Returns the verify key and program hash.
#[cfg(test)]
pub async fn store_program_and_register(
api: &OnlineClient<EntropyConfig>,
rpc: &LegacyRpcMethods<EntropyConfig>,
user: &sr25519::Pair,
deployer: &sr25519::Pair,
) -> (EncodedVerifyingKey, sp_core::H256) {
use entropy_client::{
self as test_client,
chain_api::entropy::runtime_types::pallet_registry::pallet::ProgramInstance,
};
use entropy_testing_utils::constants::TEST_PROGRAM_WASM_BYTECODE;
use sp_core::Pair;

let program_hash = test_client::store_program(
api,
rpc,
deployer,
TEST_PROGRAM_WASM_BYTECODE.to_owned(),
vec![],
vec![],
vec![],
0u8,
)
.await
.unwrap();

let (verifying_key, _registered_info) = test_client::register(
api,
rpc,
user.clone(),
SubxtAccountId32(deployer.public().0), // Program modification account
BoundedVec(vec![ProgramInstance { program_pointer: program_hash, program_config: vec![] }]),
)
.await
.unwrap();

(verifying_key, program_hash)
}
Loading

0 comments on commit 9660576

Please sign in to comment.