Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to wsts 12 #1265

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
cylewitruk marked this conversation as resolved.
Show resolved Hide resolved
hex = "0.4.3"
libp2p = { version = "0.54.1", default-features = false, features = [
"macros", "kad", "noise", "ping", "tcp",
Expand Down
2 changes: 1 addition & 1 deletion signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 7 additions & 4 deletions signer/src/testing/wsts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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())
Expand All @@ -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;
Expand All @@ -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())
Expand Down
6 changes: 4 additions & 2 deletions signer/src/transaction_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use bitcoin::hashes::Hash as _;
use bitcoin::TapSighash;
use futures::StreamExt;
use lru::LruCache;
use rand::rngs::OsRng;
use wsts::net::DkgEnd;
use wsts::net::DkgStatus;
use wsts::net::Message as WstsNetMessage;
Expand Down Expand Up @@ -744,17 +745,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)?;
}

Expand Down
3 changes: 3 additions & 0 deletions signer/src/wsts_state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::storage::model::SigHash;
use bitcoin::hashes::Hash as _;
use hashbrown::HashMap;
use hashbrown::HashSet;
use rand::rngs::OsRng;
use wsts::common::PolyCommitment;
use wsts::state_machine::coordinator::Coordinator as _;
use wsts::state_machine::coordinator::State as WstsState;
Expand Down Expand Up @@ -65,6 +66,7 @@ impl SignerStateMachine {
threshold: u32,
signer_private_key: PrivateKey,
) -> Result<Self, error::Error> {
let mut rng = OsRng;
let signer_pub_key = PublicKey::from_private_key(&signer_private_key);
let signers: hashbrown::HashMap<u32, _> = signers
.into_iter()
Expand Down Expand Up @@ -121,6 +123,7 @@ impl SignerStateMachine {
key_ids,
signer_private_key.into(),
public_keys,
&mut rng,
)
.map_err(Error::Wsts)?;

Expand Down