From 851217d577e12fea16cfde618714f1965ba3b84d Mon Sep 17 00:00:00 2001 From: Joey Yandle Date: Fri, 29 Sep 2023 15:48:02 -0400 Subject: [PATCH] update stacks-signer and tests to use generic wsts state machines --- Cargo.lock | 2 +- stacks-signer/src/main.rs | 9 ++++++--- stacks-signer/src/runloop.rs | 5 +++-- testnet/stacks-node/src/tests/signer.rs | 9 ++++++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75e1588fd..738c620b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4416,7 +4416,7 @@ dependencies = [ [[package]] name = "wsts" version = "4.0.0" -source = "git+https://github.com/Trust-Machines/wsts?branch=add-network-types#d7829b67907bf914a76a7c3220aa1298e95390b1" +source = "git+https://github.com/Trust-Machines/wsts?branch=add-network-types#ee9076af85a1a97523db8e99e3b04291230ef218" dependencies = [ "aes-gcm 0.10.2", "bs58 0.5.0", diff --git a/stacks-signer/src/main.rs b/stacks-signer/src/main.rs index fcd7c0132..8934f3472 100644 --- a/stacks-signer/src/main.rs +++ b/stacks-signer/src/main.rs @@ -56,7 +56,10 @@ use std::{ sync::mpsc::{channel, Receiver, Sender}, time::Duration, }; -use wsts::state_machine::{coordinator::Coordinator as FrostCoordinator, OperationResult}; +use wsts::{ + state_machine::{coordinator::Coordinator as FrostCoordinator, OperationResult}, + v1, +}; struct SpawnedSigner { running_signer: RunningSigner>, @@ -90,11 +93,11 @@ fn spawn_running_signer(path: &PathBuf) -> SpawnedSigner { let (cmd_send, cmd_recv) = channel(); let (res_send, res_recv) = channel(); let ev = StackerDBEventReceiver::new(vec![config.stackerdb_contract_id.clone()]); - let runloop: RunLoop = RunLoop::from(&config); + let runloop: RunLoop> = RunLoop::from(&config); let mut signer: Signer< RunLoopCommand, Vec, - RunLoop, + RunLoop>, StackerDBEventReceiver, > = Signer::new(runloop, ev, cmd_recv, res_send); let endpoint = config.node_host; diff --git a/stacks-signer/src/runloop.rs b/stacks-signer/src/runloop.rs index 4a478bdd8..a2dd35906 100644 --- a/stacks-signer/src/runloop.rs +++ b/stacks-signer/src/runloop.rs @@ -12,6 +12,7 @@ use wsts::{ signer::SigningRound, OperationResult, PublicKeys, }, + v1, }; /// Which operation to perform @@ -50,7 +51,7 @@ pub struct RunLoop { /// The signing round used to sign messages // TODO: update this to use frost_signer directly instead of the frost signing round // See: https://github.com/stacks-network/stacks-blockchain/issues/3913 - pub signing_round: SigningRound, + pub signing_round: SigningRound, /// The stacks client pub stacks_client: StacksClient, /// Received Commands that need to be processed @@ -175,7 +176,7 @@ impl RunLoop { } } -impl From<&Config> for RunLoop { +impl From<&Config> for RunLoop> { /// Creates new runloop from a config fn from(config: &Config) -> Self { // TODO: this should be a config option diff --git a/testnet/stacks-node/src/tests/signer.rs b/testnet/stacks-node/src/tests/signer.rs index a5b3e92aa..c8fb73b20 100644 --- a/testnet/stacks-node/src/tests/signer.rs +++ b/testnet/stacks-node/src/tests/signer.rs @@ -24,7 +24,10 @@ use stacks_signer::{ runloop::RunLoopCommand, utils::{build_signer_config_tomls, build_stackerdb_contract}, }; -use wsts::state_machine::{coordinator::Coordinator as FrostCoordinator, OperationResult}; +use wsts::{ + state_machine::{coordinator::Coordinator as FrostCoordinator, OperationResult}, + v1, +}; // Helper struct for holding the btc and stx neon nodes #[allow(dead_code)] @@ -42,12 +45,12 @@ fn spawn_signer( ) -> RunningSigner> { let config = stacks_signer::config::Config::load_from_str(data).unwrap(); let ev = StackerDBEventReceiver::new(vec![config.stackerdb_contract_id.clone()]); - let runloop: stacks_signer::runloop::RunLoop = + let runloop: stacks_signer::runloop::RunLoop> = stacks_signer::runloop::RunLoop::from(&config); let mut signer: Signer< RunLoopCommand, Vec, - stacks_signer::runloop::RunLoop, + stacks_signer::runloop::RunLoop>, StackerDBEventReceiver, > = Signer::new(runloop, ev, receiver, sender); let endpoint = config.endpoint;