diff --git a/crates/protocol/src/execute_protocol.rs b/crates/protocol/src/execute_protocol.rs index c484002b9..c387b2af2 100644 --- a/crates/protocol/src/execute_protocol.rs +++ b/crates/protocol/src/execute_protocol.rs @@ -329,6 +329,7 @@ pub async fn execute_dkg( } /// Execute proactive refresh. +#[allow(clippy::type_complexity)] #[tracing::instrument( skip_all, fields(threshold_accounts, my_idx), @@ -339,8 +340,6 @@ pub async fn execute_proactive_refresh( chans: Channels, threshold_pair: &sr25519::Pair, threshold_accounts: Vec, - verifying_key: VerifyingKey, - threshold: usize, inputs: KeyResharingInputs, ) -> Result< (ThresholdKeyShare, Broadcaster, mpsc::Receiver), diff --git a/crates/protocol/tests/helpers/mod.rs b/crates/protocol/tests/helpers/mod.rs index 627d1c912..fe20ab669 100644 --- a/crates/protocol/tests/helpers/mod.rs +++ b/crates/protocol/tests/helpers/mod.rs @@ -31,12 +31,13 @@ use entropy_shared::X25519PublicKey; use futures::future; use sp_core::{sr25519, Pair}; use std::{ + collections::BTreeSet, fmt, sync::{Arc, Mutex}, time::Duration, }; use subxt::utils::AccountId32; -use synedrion::{AuxInfo, KeyShare, ThresholdKeyShare}; +use synedrion::{AuxInfo, KeyResharingInputs, KeyShare, NewHolder, OldHolder, ThresholdKeyShare}; use tokio::{ net::{TcpListener, TcpStream}, time::timeout, @@ -131,15 +132,24 @@ pub async fn server( Ok(ProtocolOutput::Sign(RecoverableSignature { signature, recovery_id })) }, SessionId::Reshare { .. } => { - let new_keyshare = execute_proactive_refresh( - session_id, - channels, - &pair, - tss_accounts, - threshold_keyshare.unwrap(), - ) - .await?; - Ok(ProtocolOutput::Reshare(new_keyshare)) + let old_key = threshold_keyshare.unwrap(); + let party_ids: BTreeSet = + tss_accounts.iter().cloned().map(PartyId::new).collect(); + let inputs = KeyResharingInputs { + old_holder: Some(OldHolder { key_share: old_key.clone() }), + new_holder: Some(NewHolder { + verifying_key: old_key.verifying_key(), + old_threshold: party_ids.len(), + old_holders: party_ids.clone(), + }), + new_holders: party_ids.clone(), + new_threshold: old_key.threshold(), + }; + + let new_keyshare = + execute_proactive_refresh(session_id, channels, &pair, tss_accounts, inputs) + .await?; + Ok(ProtocolOutput::Reshare(new_keyshare.0)) }, SessionId::Dkg { .. } => { let keyshare_and_aux_info = diff --git a/crates/threshold-signature-server/src/signing_client/api.rs b/crates/threshold-signature-server/src/signing_client/api.rs index 73487ee5e..ad0fbd150 100644 --- a/crates/threshold-signature-server/src/signing_client/api.rs +++ b/crates/threshold-signature-server/src/signing_client/api.rs @@ -153,6 +153,7 @@ async fn handle_socket_result(socket: WebSocket, app_state: AppState) { }; } +#[allow(clippy::type_complexity)] #[tracing::instrument( skip_all, fields(validators_info, verifying_key, my_subgroup), @@ -216,16 +217,9 @@ pub async fn do_proactive_refresh( ) .await?; - let result = execute_proactive_refresh( - session_id, - channels, - signer.signer(), - tss_accounts, - old_key.verifying_key(), - old_key.threshold(), - inputs, - ) - .await?; + let result = + execute_proactive_refresh(session_id, channels, signer.signer(), tss_accounts, inputs) + .await?; Ok(result) } diff --git a/crates/threshold-signature-server/src/validator/api.rs b/crates/threshold-signature-server/src/validator/api.rs index bc6e28de0..428d4733a 100644 --- a/crates/threshold-signature-server/src/validator/api.rs +++ b/crates/threshold-signature-server/src/validator/api.rs @@ -23,9 +23,7 @@ use crate::{ launch::{FORBIDDEN_KEYS, LATEST_BLOCK_NUMBER_RESHARE}, substrate::{get_stash_address, get_validators_info, query_chain, submit_transaction}, }, - signing_client::{ - api::get_channels, protocol_transport::open_protocol_connections, ProtocolErr, - }, + signing_client::{api::get_channels, ProtocolErr}, validator::errors::ValidatorErr, AppState, }; @@ -40,20 +38,19 @@ pub use entropy_protocol::{ }, KeyParams, KeyShareWithAuxInfo, Listener, PartyId, SessionId, ValidatorInfo, }; -use entropy_shared::{OcwMessageReshare, NETWORK_PARENT_KEY, SETUP_TIMEOUT_SECONDS}; +use entropy_shared::{OcwMessageReshare, NETWORK_PARENT_KEY}; use parity_scale_codec::{Decode, Encode}; use rand_core::OsRng; use sp_core::Pair; -use std::{collections::BTreeSet, str::FromStr, time::Duration}; +use std::{collections::BTreeSet, str::FromStr}; use subxt::{ backend::legacy::LegacyRpcMethods, ext::sp_core::sr25519, tx::PairSigner, utils::AccountId32, OnlineClient, }; use synedrion::{ - make_aux_gen_session, make_key_resharing_session, sessions::SessionId as SynedrionSessionId, - AuxInfo, KeyResharingInputs, NewHolder, OldHolder, + make_aux_gen_session, sessions::SessionId as SynedrionSessionId, AuxInfo, KeyResharingInputs, + NewHolder, OldHolder, }; -use tokio::time::timeout; /// HTTP POST endpoint called by the off-chain worker (propagation pallet) during network reshare. /// @@ -183,8 +180,6 @@ pub async fn new_reshare( channels, signer.signer(), tss_accounts, - decoded_verifying_key, - threshold as usize, inputs, ) .await?;