Skip to content

Commit

Permalink
lovely cascading changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cylewitruk committed Feb 4, 2025
1 parent 267c5a4 commit 716e5c2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
5 changes: 3 additions & 2 deletions signer/src/testing/transaction_coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,9 @@ where
.into();

let dkg_txid = testing::dummy::txid(&fake::Faker, rng);
let (aggregate_key, all_dkg_shares) =
signer_set.run_dkg(bitcoin_chain_tip, dkg_txid, rng).await;
let (aggregate_key, all_dkg_shares) = signer_set
.run_dkg(bitcoin_chain_tip, dkg_txid.into(), rng)
.await;

let encrypted_dkg_shares = all_dkg_shares.first().unwrap();

Expand Down
6 changes: 4 additions & 2 deletions signer/src/testing/transaction_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ where
coordinator_signer_info,
self.signing_threshold,
);
let aggregate_key = coordinator.run_dkg(bitcoin_chain_tip, dummy_txid).await;
let aggregate_key = coordinator
.run_dkg(bitcoin_chain_tip, dummy_txid.into())
.await;

for handle in event_loop_handles.into_iter() {
assert!(handle
Expand Down Expand Up @@ -260,7 +262,7 @@ async fn run_dkg_and_store_results_for_signers<'s: 'r, 'r, S, Rng>(
let dkg_txid = testing::dummy::txid(&fake::Faker, rng);
let bitcoin_chain_tip = *chain_tip;
let (_, all_dkg_shares) = testing_signer_set
.run_dkg(bitcoin_chain_tip, dkg_txid, rng)
.run_dkg(bitcoin_chain_tip, dkg_txid.into(), rng)
.await;

for (storage, encrypted_dkg_shares) in stores.into_iter().zip(all_dkg_shares) {
Expand Down
15 changes: 8 additions & 7 deletions signer/src/testing/wsts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Coordinator {
pub async fn run_dkg(
&mut self,
bitcoin_chain_tip: model::BitcoinBlockHash,
txid: bitcoin::Txid,
id: WstsMessageId,
) -> PublicKey {
self.wsts_coordinator
.move_to(coordinator::State::DkgPublicDistribute)
Expand All @@ -148,10 +148,9 @@ impl Coordinator {
.start_public_shares()
.expect("failed to start public shares");

self.send_packet(bitcoin_chain_tip, txid.into(), outbound)
.await;
self.send_packet(bitcoin_chain_tip, id, outbound).await;

match self.loop_until_result(bitcoin_chain_tip, txid.into()).await {
match self.loop_until_result(bitcoin_chain_tip, id).await {
wsts::state_machine::OperationResult::Dkg(aggregate_key) => {
PublicKey::try_from(&aggregate_key).expect("Got the point at infinity")
}
Expand Down Expand Up @@ -405,7 +404,7 @@ impl SignerSet {
pub async fn run_dkg<Rng: rand::RngCore + rand::CryptoRng>(
&mut self,
bitcoin_chain_tip: model::BitcoinBlockHash,
txid: bitcoin::Txid,
id: WstsMessageId,
rng: &mut Rng,
) -> (PublicKey, Vec<model::EncryptedDkgShares>) {
let mut signer_handles = Vec::new();
Expand All @@ -414,7 +413,7 @@ impl SignerSet {
signer_handles.push(handle);
}

let aggregate_key = self.coordinator.run_dkg(bitcoin_chain_tip, txid).await;
let aggregate_key = self.coordinator.run_dkg(bitcoin_chain_tip, id).await;

for handle in signer_handles {
let signer = handle.await.expect("signer crashed");
Expand Down Expand Up @@ -554,7 +553,9 @@ mod tests {
let signer_info = generate_signer_info(&mut rng, num_signers);
let mut signer_set = SignerSet::new(&signer_info, threshold, || network.connect());

let (_, dkg_shares) = signer_set.run_dkg(bitcoin_chain_tip, txid, &mut rng).await;
let (_, dkg_shares) = signer_set
.run_dkg(bitcoin_chain_tip, txid.into(), &mut rng)
.await;

assert_eq!(dkg_shares.len(), num_signers as usize);
}
Expand Down
5 changes: 3 additions & 2 deletions signer/tests/integration/emily.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ where
.into();

let dkg_txid = testing::dummy::txid(&fake::Faker, rng);
let (aggregate_key, all_dkg_shares) =
signer_set.run_dkg(bitcoin_chain_tip, dkg_txid, rng).await;
let (aggregate_key, all_dkg_shares) = signer_set
.run_dkg(bitcoin_chain_tip, dkg_txid.into(), rng)
.await;

let encrypted_dkg_shares = all_dkg_shares.first().unwrap();
signer_set
Expand Down
2 changes: 1 addition & 1 deletion signer/tests/integration/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ async fn should_return_the_same_last_key_rotation_as_in_memory_store() {
testing::wsts::SignerSet::new(&signer_info, threshold, || dummy_wsts_network.connect());
let dkg_txid = testing::dummy::txid(&fake::Faker, &mut rng);
let (_, all_shares) = testing_signer_set
.run_dkg(chain_tip, dkg_txid, &mut rng)
.run_dkg(chain_tip, dkg_txid.into(), &mut rng)
.await;

let shares = all_shares.first().unwrap();
Expand Down
7 changes: 4 additions & 3 deletions signer/tests/integration/transaction_coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ where
.into();

let dkg_txid = testing::dummy::txid(&fake::Faker, rng);
let (aggregate_key, all_dkg_shares) =
signer_set.run_dkg(bitcoin_chain_tip, dkg_txid, rng).await;
let (aggregate_key, all_dkg_shares) = signer_set
.run_dkg(bitcoin_chain_tip, dkg_txid.into(), rng)
.await;

let encrypted_dkg_shares = all_dkg_shares.first().unwrap();
signer_set
Expand Down Expand Up @@ -3214,7 +3215,7 @@ async fn test_conservative_initial_sbtc_limits() {
let dkg_txid = testing::dummy::txid(&fake::Faker, &mut rng);

let (aggregate_key, encrypted_shares) = signer_set
.run_dkg(chain_tip_info.hash.into(), dkg_txid, &mut rng)
.run_dkg(chain_tip_info.hash.into(), dkg_txid.into(), &mut rng)
.await;

for ((_, db, _, _), dkg_shares) in signers.iter_mut().zip(&encrypted_shares) {
Expand Down

0 comments on commit 716e5c2

Please sign in to comment.