From 9306dfade2e2dc69b45072a21fc3ef69e968b9fd Mon Sep 17 00:00:00 2001 From: Joey Yandle Date: Wed, 15 Jan 2025 11:55:33 -0500 Subject: [PATCH 1/4] update for wsts 11 --- Cargo.lock | 4 ++-- signer/Cargo.toml | 2 +- signer/src/testing/wsts.rs | 11 +++++++---- signer/src/transaction_signer.rs | 9 +++++++-- signer/src/wsts_state_machine.rs | 6 ++++++ 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49caf7993..026e20e41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7987,8 +7987,8 @@ dependencies = [ [[package]] name = "wsts" -version = "10.0.0" -source = "git+https://github.com/Trust-Machines/wsts.git?rev=53ae23f5f35def420877ccc8c0fe3662e64e38a1#53ae23f5f35def420877ccc8c0fe3662e64e38a1" +version = "12.0.0" +source = "git+https://github.com/Trust-Machines/wsts.git?rev=ce901edfc17fe8bf22f741f638f16fdaff6daa5a#ce901edfc17fe8bf22f741f638f16fdaff6daa5a" dependencies = [ "aes-gcm", "bs58 0.5.1", diff --git a/signer/Cargo.toml b/signer/Cargo.toml index 61dc4dfb9..4336a9f42 100644 --- a/signer/Cargo.toml +++ b/signer/Cargo.toml @@ -52,7 +52,7 @@ tracing-attributes.workspace = true tracing-subscriber = { workspace = true } url.workspace = true # wsts.workspace = true -wsts = { git = "https://github.com/Trust-Machines/wsts.git", rev = "53ae23f5f35def420877ccc8c0fe3662e64e38a1" } +wsts = { git = "https://github.com/Trust-Machines/wsts.git", rev = "ce901edfc17fe8bf22f741f638f16fdaff6daa5a" } hex.workspace = true cfg-if = "1.0" include_dir = "0.7.4" diff --git a/signer/src/testing/wsts.rs b/signer/src/testing/wsts.rs index 2055ebe71..d2c0e552b 100644 --- a/signer/src/testing/wsts.rs +++ b/signer/src/testing/wsts.rs @@ -7,6 +7,7 @@ use std::time::Duration; use clarity::util::secp256k1::Secp256k1PublicKey; use clarity::vm::types::PrincipalData; use fake::Fake; +use rand::rngs::OsRng; use stacks_common::address::AddressHashMode; use stacks_common::address::C32_ADDRESS_VERSION_TESTNET_MULTISIG; use stacks_common::types::chainstate::StacksAddress; @@ -249,6 +250,7 @@ impl Signer { /// Participate in a DKG round and return the result pub async fn run_until_dkg_end(mut self) -> Self { let future = async move { + let mut rng = OsRng; loop { let msg = self.network.receive().await.expect("network error"); let bitcoin_chain_tip = msg.bitcoin_chain_tip; @@ -264,12 +266,12 @@ impl Signer { let outbound_packets = self .wsts_signer - .process_inbound_messages(&[packet]) + .process_inbound_messages(&[packet], &mut rng) .expect("message processing failed"); for packet in outbound_packets { self.wsts_signer - .process_inbound_messages(&[packet.clone()]) + .process_inbound_messages(&[packet.clone()], &mut rng) .expect("message processing failed"); self.send_packet(bitcoin_chain_tip, wsts_msg.txid, packet.clone()) @@ -289,6 +291,7 @@ impl Signer { /// Participate in a signing round and return the result pub async fn run_until_signature_share_response(mut self) -> Self { let future = async move { + let mut rng = OsRng; loop { let msg = self.network.receive().await.expect("network error"); let bitcoin_chain_tip = msg.bitcoin_chain_tip; @@ -304,12 +307,12 @@ impl Signer { let outbound_packets = self .wsts_signer - .process_inbound_messages(&[packet]) + .process_inbound_messages(&[packet], &mut rng) .expect("message processing failed"); for packet in outbound_packets { self.wsts_signer - .process_inbound_messages(&[packet.clone()]) + .process_inbound_messages(&[packet.clone()], &mut rng) .expect("message processing failed"); self.send_packet(bitcoin_chain_tip, wsts_msg.txid, packet.clone()) diff --git a/signer/src/transaction_signer.rs b/signer/src/transaction_signer.rs index f3cdf5076..5b8619e14 100644 --- a/signer/src/transaction_signer.rs +++ b/signer/src/transaction_signer.rs @@ -44,7 +44,11 @@ use crate::wsts_state_machine::StateMachineId; use bitcoin::hashes::Hash as _; use bitcoin::TapSighash; use futures::StreamExt; +<<<<<<< HEAD use lru::LruCache; +======= +use rand::rngs::OsRng; +>>>>>>> 6f51a822 (update for wsts 11) use wsts::net::DkgEnd; use wsts::net::DkgStatus; use wsts::net::Message as WstsNetMessage; @@ -744,17 +748,18 @@ where msg: &WstsNetMessage, bitcoin_chain_tip: &model::BitcoinBlockHash, ) -> Result<(), Error> { + let mut rng = OsRng; let Some(state_machine) = self.wsts_state_machines.get_mut(&id) else { tracing::warn!("missing signing round"); return Err(Error::MissingStateMachine); }; - let outbound_messages = state_machine.process(msg).map_err(Error::Wsts)?; + let outbound_messages = state_machine.process(msg, &mut rng).map_err(Error::Wsts)?; for outbound_message in outbound_messages.iter() { // The WSTS state machine assume we read our own messages state_machine - .process(outbound_message) + .process(outbound_message, &mut rng) .map_err(Error::Wsts)?; } diff --git a/signer/src/wsts_state_machine.rs b/signer/src/wsts_state_machine.rs index 2f8d29ea0..fa6c8cb63 100644 --- a/signer/src/wsts_state_machine.rs +++ b/signer/src/wsts_state_machine.rs @@ -14,9 +14,13 @@ use crate::storage; use crate::storage::model; use crate::storage::model::SigHash; +<<<<<<< HEAD use bitcoin::hashes::Hash as _; use hashbrown::HashMap; use hashbrown::HashSet; +======= +use rand::rngs::OsRng; +>>>>>>> 6f51a822 (update for wsts 11) use wsts::common::PolyCommitment; use wsts::state_machine::coordinator::Coordinator as _; use wsts::state_machine::coordinator::State as WstsState; @@ -65,6 +69,7 @@ impl SignerStateMachine { threshold: u32, signer_private_key: PrivateKey, ) -> Result { + let mut rng = OsRng; let signer_pub_key = PublicKey::from_private_key(&signer_private_key); let signers: hashbrown::HashMap = signers .into_iter() @@ -121,6 +126,7 @@ impl SignerStateMachine { key_ids, signer_private_key.into(), public_keys, + &mut rng, ) .map_err(Error::Wsts)?; From c986d2afbec8aa6d6d5f4e06ffd760623c5b8c2f Mon Sep 17 00:00:00 2001 From: Joey Yandle Date: Wed, 15 Jan 2025 12:47:09 -0500 Subject: [PATCH 2/4] use wsts 11.0.0 from crates --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3303c3346..83eb1b814 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,7 +75,7 @@ tracing = { version = "0.1", default-features = false } tracing-attributes = "0.1" url = "2.5" warp_lambda = "0.1.4" -wsts = "9.2.0" +wsts = "11.0.0" hex = "0.4.3" libp2p = { version = "0.54.1", default-features = false, features = [ "macros", "kad", "noise", "ping", "tcp", From 25ac3be430b9e44a93e08f6a0891949f7cd035d8 Mon Sep 17 00:00:00 2001 From: Joey Yandle Date: Fri, 24 Jan 2025 09:56:50 -0500 Subject: [PATCH 3/4] fix rebase --- signer/src/transaction_signer.rs | 3 --- signer/src/wsts_state_machine.rs | 3 --- 2 files changed, 6 deletions(-) diff --git a/signer/src/transaction_signer.rs b/signer/src/transaction_signer.rs index 5b8619e14..f39131f00 100644 --- a/signer/src/transaction_signer.rs +++ b/signer/src/transaction_signer.rs @@ -44,11 +44,8 @@ use crate::wsts_state_machine::StateMachineId; use bitcoin::hashes::Hash as _; use bitcoin::TapSighash; use futures::StreamExt; -<<<<<<< HEAD use lru::LruCache; -======= use rand::rngs::OsRng; ->>>>>>> 6f51a822 (update for wsts 11) use wsts::net::DkgEnd; use wsts::net::DkgStatus; use wsts::net::Message as WstsNetMessage; diff --git a/signer/src/wsts_state_machine.rs b/signer/src/wsts_state_machine.rs index fa6c8cb63..f346c0fba 100644 --- a/signer/src/wsts_state_machine.rs +++ b/signer/src/wsts_state_machine.rs @@ -14,13 +14,10 @@ use crate::storage; use crate::storage::model; use crate::storage::model::SigHash; -<<<<<<< HEAD use bitcoin::hashes::Hash as _; use hashbrown::HashMap; use hashbrown::HashSet; -======= use rand::rngs::OsRng; ->>>>>>> 6f51a822 (update for wsts 11) use wsts::common::PolyCommitment; use wsts::state_machine::coordinator::Coordinator as _; use wsts::state_machine::coordinator::State as WstsState; From cf1395321ecdee00d7257ffefb257e3aef6e4be2 Mon Sep 17 00:00:00 2001 From: Joey Yandle Date: Fri, 24 Jan 2025 11:38:17 -0500 Subject: [PATCH 4/4] use wsts-12.0.0 from crates --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- signer/Cargo.toml | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 026e20e41..76a072dff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -7988,7 +7988,8 @@ dependencies = [ [[package]] name = "wsts" version = "12.0.0" -source = "git+https://github.com/Trust-Machines/wsts.git?rev=ce901edfc17fe8bf22f741f638f16fdaff6daa5a#ce901edfc17fe8bf22f741f638f16fdaff6daa5a" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5768ec22f0c646d9992acdd5374cf43f6d0d5aa94bc8016ad55d685f49b72cac" dependencies = [ "aes-gcm", "bs58 0.5.1", diff --git a/Cargo.toml b/Cargo.toml index 83eb1b814..055befd59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,7 +75,7 @@ tracing = { version = "0.1", default-features = false } tracing-attributes = "0.1" url = "2.5" warp_lambda = "0.1.4" -wsts = "11.0.0" +wsts = "12.0.0" hex = "0.4.3" libp2p = { version = "0.54.1", default-features = false, features = [ "macros", "kad", "noise", "ping", "tcp", diff --git a/signer/Cargo.toml b/signer/Cargo.toml index 4336a9f42..ad10ec0c3 100644 --- a/signer/Cargo.toml +++ b/signer/Cargo.toml @@ -51,8 +51,7 @@ tracing.workspace = true tracing-attributes.workspace = true tracing-subscriber = { workspace = true } url.workspace = true -# wsts.workspace = true -wsts = { git = "https://github.com/Trust-Machines/wsts.git", rev = "ce901edfc17fe8bf22f741f638f16fdaff6daa5a" } +wsts.workspace = true hex.workspace = true cfg-if = "1.0" include_dir = "0.7.4"