Skip to content
Open
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
30 changes: 30 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/e2e-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2024"

[dependencies]
hashi = { path = "../hashi" }
mpc = { path = "../mpc" }
hashi-screener = { path = "../hashi-screener", features = ["test-utils"] }
hashi-types = { path = "../hashi-types" }

Expand Down
15 changes: 6 additions & 9 deletions crates/e2e-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ mod tests {
mgr.committee.clone()
};
let (refill_tx, _) = tokio::sync::watch::channel(0u32);
let signing_manager = hashi::mpc::SigningManager::new(
let signing_manager = mpc::SigningManager::new(
info.address,
committee,
t,
Expand All @@ -679,9 +679,8 @@ mod tests {
epoch: u64,
sui_request_id: sui_sdk_types::Address,
global_presig_index: u64,
) -> Vec<
hashi::mpc::types::SigningResult<fastcrypto::groups::secp256k1::schnorr::SchnorrSignature>,
> {
) -> Vec<mpc::types::SigningResult<fastcrypto::groups::secp256k1::schnorr::SchnorrSignature>>
{
let beacon_value = S::rand(&mut rand::thread_rng());
let sign_futures: Vec<_> = nodes
.iter()
Expand All @@ -691,7 +690,7 @@ mod tests {
.signing_manager_for(epoch)
.unwrap_or_else(|| panic!("SigningManager not initialized for epoch {epoch}"));
let onchain_state = node.hashi().onchain_state().clone();
let p2p_channel = hashi::mpc::rpc::RpcP2PChannel::new(
let p2p_channel = hashi::mpc_p2p_channel::RpcP2PChannel::new(
onchain_state,
epoch,
hashi::metrics::MPC_LABEL_SIGNING,
Expand All @@ -709,7 +708,7 @@ mod tests {
&beacon,
None,
SIGNING_TIMEOUT,
&metrics,
&metrics.mpc,
)
.await
}
Expand All @@ -720,9 +719,7 @@ mod tests {

fn assert_all_signatures_match(
results: Vec<
hashi::mpc::types::SigningResult<
fastcrypto::groups::secp256k1::schnorr::SchnorrSignature,
>,
mpc::types::SigningResult<fastcrypto::groups::secp256k1::schnorr::SchnorrSignature>,
>,
) {
let mut signatures = Vec::new();
Expand Down
1 change: 1 addition & 0 deletions crates/hashi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sui-transaction-builder.workspace = true
sui-futures = { workspace = true }

hashi-types = { path = "../hashi-types" }
mpc = { path = "../mpc" }

# Bitcoin dependencies
bitcoin.workspace = true
Expand Down
4 changes: 1 addition & 3 deletions crates/hashi/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ pub const BITCOIN_SIGNET_CHAIN_ID: &str =
pub const BITCOIN_REGTEST_CHAIN_ID: &str =
"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206";

/// Trigger presignature refill when remaining presignatures drop to
/// `initial_pool_size / PRESIG_REFILL_DIVISOR`.
pub const PRESIG_REFILL_DIVISOR: usize = 2;
pub use mpc::constants::PRESIG_REFILL_DIVISOR;

pub fn is_production_sui_chain(chain_id: &str) -> bool {
chain_id == SUI_MAINNET_CHAIN_ID || chain_id == SUI_TESTNET_CHAIN_ID
Expand Down
6 changes: 3 additions & 3 deletions crates/hashi/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use hashi_types::committee::EncryptionPrivateKey;

use serde::de::DeserializeOwned;

use crate::mpc::types::RotationMessages;
use mpc::types::RotationMessages;

pub struct Database {
db: fjall::Database,
Expand Down Expand Up @@ -442,13 +442,13 @@ fn prune_keyspace(keyspace: &Keyspace, cutoff_epoch: u64) -> Result<()> {

#[cfg(test)]
mod tests {
use crate::mpc::EncryptionGroupElement;
use fastcrypto_tbls::nodes::Node;
use fastcrypto_tbls::nodes::Nodes;
use fastcrypto_tbls::threshold_schnorr::avss;
use fastcrypto_tbls::threshold_schnorr::batch_avss;
use hashi_types::committee::EncryptionPrivateKey;
use hashi_types::committee::EncryptionPublicKey;
use mpc::EncryptionGroupElement;
use sui_sdk_types::Address;

use super::Database;
Expand Down Expand Up @@ -1069,7 +1069,7 @@ mod tests {
#[test]
fn test_epoch_store_writes_at_explicit_epoch_not_self_epoch() {
use crate::storage::EpochPublicMessagesStore;
use crate::storage::PublicMessagesStore;
use mpc::PublicMessagesStore;
use std::collections::BTreeMap;
use std::num::NonZeroU16;

Expand Down
37 changes: 7 additions & 30 deletions crates/hashi/src/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ impl HttpService {
Self { inner: hashi }
}

pub(crate) fn metrics(&self) -> &crate::metrics::Metrics {
&self.inner.metrics
}

pub async fn start(self) -> (std::net::SocketAddr, Service) {
let router = {
let max_decoding_message_size = self.inner.config.grpc_max_decoding_message_size();
let bridge_service =
hashi_types::proto::bridge_service_server::BridgeServiceServer::new(self.clone())
.max_decoding_message_size(max_decoding_message_size);
let mpc_service =
hashi_types::proto::mpc_service_server::MpcServiceServer::new(self.clone())
.max_decoding_message_size(max_decoding_message_size);
let mpc_service = hashi_types::proto::mpc_service_server::MpcServiceServer::new(
mpc::MpcServiceImpl::new(
self.inner.mpc_state.clone(),
Arc::new(self.inner.metrics.mpc.clone()),
),
)
.max_decoding_message_size(max_decoding_message_size);

let (health_reporter, health_service) = tonic_health::server::health_reporter();

Expand Down Expand Up @@ -136,32 +136,9 @@ impl HttpService {
(local_addr, service)
}

pub fn mpc_manager(
&self,
) -> Result<Arc<std::sync::RwLock<crate::mpc::MpcManager>>, tonic::Status> {
self.inner
.mpc_manager()
.ok_or_else(|| tonic::Status::unavailable("DKG manager not yet initialized"))
}

pub fn signing_manager_for(
&self,
epoch: u64,
) -> Result<Arc<crate::mpc::SigningManager>, tonic::Status> {
self.inner.signing_manager_for(epoch).ok_or_else(|| {
tonic::Status::unavailable(format!(
"SigningManager not available for epoch {epoch}; retry"
))
})
}

pub fn btc_monitor(&self) -> &crate::btc_monitor::monitor::MonitorClient {
self.inner.btc_monitor()
}

pub fn get_reconfig_signature(&self, epoch: u64) -> Option<Vec<u8>> {
self.inner.get_reconfig_signature(epoch)
}
}

async fn health() -> impl axum::response::IntoResponse {
Expand Down
Loading
Loading