Skip to content

Commit

Permalink
Merge pull request #3 from Sajjon/infra
Browse files Browse the repository at this point in the history
Sajjon authored Jun 25, 2024
2 parents 4131979 + 5303ba5 commit 59c2060
Showing 17 changed files with 169 additions and 228 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -82,10 +82,10 @@ jobs:
locked: true

- name: Code Coverage - Generate
run: cargo tarpaulin
run: cargo tarpaulin --out xml

- name: Code Coverage - Upload to CodeCov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV }}
fail_ci_if_error: true
fail_ci_if_error: true
9 changes: 9 additions & 0 deletions .tarpaulin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[all]
exclude-files = ["src/existing_types_in_sargon.rs"]
verbose = false
force-clean = true
timeout = "2m"
locked = true
all-features = true
jobs = 1
out = ["html"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[![Average](https://codecov.io/gh/sajjon/one-does-not-simply-sign/graph/badge.svg?token=8QPKIUSAQD)](https://codecov.io/github/sajjon/one-does-not-simply-sign)
[![codecov](https://codecov.io/github/Sajjon/one-does-not-simply-sign/branch/main/graph/badge.svg?token=PTFupnAjyZ)](https://codecov.io/github/Sajjon/one-does-not-simply-sign)
19 changes: 19 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
codecov:
notify:
wait_for_ci: true
max_report_age: off
require_ci_to_pass: true
comment:
behavior: default
layout: "reach, diff, flags, files"
show_carryforward_flags: false
coverage:
precision: 1
range: 80...98 # red -> yellow (the inside range) -> green
status:
patch:
default:
target: auto
threshold: 80%
base: auto
only_pulls: true
62 changes: 0 additions & 62 deletions src/types/sargon.rs β†’ src/existing_types_in_sargon.rs
Original file line number Diff line number Diff line change
@@ -137,21 +137,6 @@ impl FactorInstance {
}
}

#[derive(Clone, PartialEq, Eq, std::hash::Hash, derive_more::Debug)]
#[debug("{:?}: {:?}", owner, factor_instance)]
pub struct OwnedFactorInstance {
pub factor_instance: FactorInstance,
pub owner: AccountAddressOrIdentityAddress,
}
impl OwnedFactorInstance {
pub fn new(factor_instance: FactorInstance, owner: AccountAddressOrIdentityAddress) -> Self {
Self {
factor_instance,
owner,
}
}
}

#[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)]
pub struct Hash {
id: Uuid,
@@ -245,19 +230,6 @@ impl Entity {
}
}

impl From<&Entity> for OwnedMatrixOfFactorInstances {
fn from(value: &Entity) -> Self {
let matrix = match value.security_state.clone() {
EntitySecurityState::Securified(matrix) => matrix.clone(),
EntitySecurityState::Unsecured(instance) => MatrixOfFactorInstances::from(instance),
};
OwnedMatrixOfFactorInstances {
address_of_owner: value.address.clone(),
matrix,
}
}
}

#[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)]
pub struct MatrixOfFactorInstances {
pub threshold_factors: Vec<FactorInstance>,
@@ -308,23 +280,6 @@ impl From<FactorInstance> for MatrixOfFactorInstances {
}
}

#[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)]
pub struct OwnedMatrixOfFactorInstances {
pub address_of_owner: AccountAddressOrIdentityAddress,
pub matrix: MatrixOfFactorInstances,
}
impl OwnedMatrixOfFactorInstances {
pub fn new(
address_of_owner: AccountAddressOrIdentityAddress,
matrix: MatrixOfFactorInstances,
) -> Self {
Self {
address_of_owner,
matrix,
}
}
}

#[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)]
pub struct IntentHash {
hash: Hash,
@@ -377,20 +332,3 @@ pub enum CommonError {
#[error("Failed")]
Failure,
}

#[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)]
pub struct InvalidTransactionIfSkipped {
pub intent_hash: IntentHash,
pub entities_which_would_fail_auth: Vec<AccountAddressOrIdentityAddress>,
}
impl InvalidTransactionIfSkipped {
pub fn new(
intent_hash: IntentHash,
entities_which_would_fail_auth: Vec<AccountAddressOrIdentityAddress>,
) -> Self {
Self {
intent_hash,
entities_which_would_fail_auth,
}
}
}
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -2,9 +2,11 @@
//! SingleSigningDrivers other than the fact that BatchSigningDerivers can sign
//! many transactions with many derivations paths at once?
mod existing_types_in_sargon;
mod types;

pub mod prelude {
pub use crate::existing_types_in_sargon::*;
pub use crate::types::*;

pub use async_trait::async_trait;
@@ -359,7 +361,7 @@ mod tests {
let signature = &context.sign().await.unwrap().all_signatures()[0];

assert_eq!(
&signature.owned_factor_instance.factor_instance,
signature.owned_factor_instance.factor_instance(),
account
.security_state
.all_factor_instances()
@@ -495,7 +497,7 @@ mod tests {
assert_eq!(
signature
.owned_factor_instance
.factor_instance
.factor_instance()
.factor_source_id,
FactorSourceID::fs4()
);
@@ -518,7 +520,7 @@ mod tests {
assert_eq!(
signature
.owned_factor_instance
.factor_instance
.factor_instance()
.factor_source_id
.kind,
FactorSourceKind::Device
2 changes: 1 addition & 1 deletion src/types/drivers/batch_tx_batch_key_signing_request.rs
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ impl BatchKeySigningRequest {
) -> Self {
assert!(owned_factor_instances
.iter()
.all(|f| f.factor_instance.factor_source_id == factor_source_id));
.all(|f| f.by_factor_source(factor_source_id)));
Self {
intent_hash,
factor_source_id,
21 changes: 21 additions & 0 deletions src/types/hd_signature.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use crate::prelude::*;

/// A signature of `intent_hash` by `entity` using `factor_source_id` and `derivation_path`, with `public_key` used for verification.
#[derive(Clone, PartialEq, Eq, Hash, derive_more::Debug)]
#[debug("HDSignature {{ instance: {:?} }}", owned_factor_instance)]
pub struct HDSignature {
/// Hash which was signed.
pub intent_hash: IntentHash,

/// The ECDSA/EdDSA signature produced by the private key of the
/// `owned_hd_factor_instance.public_key`,
/// derived by the FactorSource identified by
/// `owned_hd_factor_instance.factor_source_id` and which
/// was derived at `owned_hd_factor_instance.derivation_path`.
pub signature: Signature,

/// The account or identity address of the entity which signed the hash,
/// with expected public key and with derivation path to derive PrivateKey
/// with.
pub owned_factor_instance: OwnedFactorInstance,
}
18 changes: 18 additions & 0 deletions src/types/invalid_transaction_if_skipped.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use crate::prelude::*;

#[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)]
pub struct InvalidTransactionIfSkipped {
pub intent_hash: IntentHash,
pub entities_which_would_fail_auth: Vec<AccountAddressOrIdentityAddress>,
}
impl InvalidTransactionIfSkipped {
pub fn new(
intent_hash: IntentHash,
entities_which_would_fail_auth: Vec<AccountAddressOrIdentityAddress>,
) -> Self {
Self {
intent_hash,
entities_which_would_fail_auth,
}
}
}
12 changes: 10 additions & 2 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
mod drivers;
mod hd_signature;
mod invalid_transaction_if_skipped;
mod new_types;
mod owned;
mod owned_factor_instance;
mod owned_matrix_of_factor_instances;
mod petitions;
mod sargon;
mod signatures_building_coordinator;
mod signatures_outcome;
mod signing_driver;
mod signing_drivers_context;
mod simulated_user;

pub use drivers::*;
pub use hd_signature::*;
pub use invalid_transaction_if_skipped::*;
pub use new_types::*;
pub use owned::*;
pub use owned_factor_instance::*;
pub use owned_matrix_of_factor_instances::*;
pub use petitions::*;
pub use sargon::*;
pub use signatures_building_coordinator::*;
pub use signatures_outcome::*;
pub use signing_driver::*;
20 changes: 0 additions & 20 deletions src/types/new_types.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
use crate::prelude::*;

/// A signature of `intent_hash` by `entity` using `factor_source_id` and `derivation_path`, with `public_key` used for verification.
#[derive(Clone, PartialEq, Eq, Hash, derive_more::Debug)]
#[debug("HDSignature {{ instance: {:?} }}", owned_factor_instance)]
pub struct HDSignature {
/// Hash which was signed.
pub intent_hash: IntentHash,

/// The ECDSA/EdDSA signature produced by the private key of the
/// `owned_hd_factor_instance.public_key`,
/// derived by the FactorSource identified by
/// `owned_hd_factor_instance.factor_source_id` and which
/// was derived at `owned_hd_factor_instance.derivation_path`.
pub signature: Signature,

/// The account or identity address of the entity which signed the hash,
/// with expected public key and with derivation path to derive PrivateKey
/// with.
pub owned_factor_instance: OwnedFactorInstance,
}

impl HDSignature {
pub fn new(
intent_hash: IntentHash,
14 changes: 14 additions & 0 deletions src/types/owned.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use crate::prelude::*;

#[derive(Clone, PartialEq, Eq, std::hash::Hash, derive_more::Debug)]
#[debug("{:?}: {:?}", owner, value)]
pub struct Owned<T> {
pub owner: AccountAddressOrIdentityAddress,
pub value: T,
}

impl<T> Owned<T> {
pub fn new(owner: AccountAddressOrIdentityAddress, value: T) -> Self {
Self { owner, value }
}
}
21 changes: 21 additions & 0 deletions src/types/owned_factor_instance.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use std::borrow::Borrow;

use crate::prelude::*;

pub type OwnedFactorInstance = Owned<FactorInstance>;

impl OwnedFactorInstance {
pub fn owned_factor_instance(
owner: AccountAddressOrIdentityAddress,
factor_instance: FactorInstance,
) -> Self {
Self::new(owner, factor_instance)
}
pub fn factor_instance(&self) -> &FactorInstance {
&self.value
}
pub fn by_factor_source(&self, factor_source_id: impl Borrow<FactorSourceID>) -> bool {
let factor_source_id = factor_source_id.borrow();
self.factor_instance().factor_source_id() == *factor_source_id
}
}
22 changes: 22 additions & 0 deletions src/types/owned_matrix_of_factor_instances.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use crate::prelude::*;

pub type OwnedMatrixOfFactorInstances = Owned<MatrixOfFactorInstances>;

impl OwnedMatrixOfFactorInstances {
pub fn owned_matrix(
owner: AccountAddressOrIdentityAddress,
matrix: MatrixOfFactorInstances,
) -> Self {
Self::new(owner, matrix)
}
}

impl From<&Entity> for OwnedMatrixOfFactorInstances {
fn from(value: &Entity) -> Self {
let matrix = match value.security_state.clone() {
EntitySecurityState::Securified(matrix) => matrix.clone(),
EntitySecurityState::Unsecured(instance) => MatrixOfFactorInstances::from(instance),
};
OwnedMatrixOfFactorInstances::owned_matrix(value.address.clone(), matrix)
}
}
112 changes: 25 additions & 87 deletions src/types/petitions.rs
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ impl PetitionOfTransactionByEntity {
.unwrap_or_default();

o.union(&t)
.map(|f| OwnedFactorInstance::new(f.clone(), self.entity.clone()))
.map(|f| OwnedFactorInstance::owned_factor_instance(self.entity.clone(), f.clone()))
.collect::<IndexSet<_>>()
}

@@ -207,17 +207,15 @@ impl PetitionOfTransactionByEntity {

/// `Ok(true)` means "continue", `Ok(false)` means "stop, we are done". `Err(_)` means "stop, we have failed".
pub(super) fn continue_if_necessary(&self) -> Result<bool> {
let status = match self.status() {
match self.status() {
PetitionForFactorListStatus::InProgress => Ok(true),
PetitionForFactorListStatus::Finished(PetitionForFactorListStatusFinished::Fail) => {
Err(CommonError::Failure)
}
PetitionForFactorListStatus::Finished(PetitionForFactorListStatusFinished::Success) => {
Ok(false)
}
};
println!("🚦 status: {:?}", &status);
status
}
}
}

@@ -254,11 +252,7 @@ impl PetitionOfTransactionByEntity {
) -> PetitionForFactorListStatus {
let simulation = self.clone();
simulation.did_skip(factor_source_id, true);

print!("πŸ•ΉοΈ if skipping, simulated status: ",);
let simulated_status = simulation.status();
println!("{:?}", simulated_status);
simulated_status
simulation.status()
}

pub fn did_skip(&self, factor_source_id: &FactorSourceID, simulated: bool) {
@@ -290,26 +284,16 @@ impl PetitionOfTransactionByEntity {

match (maybe_threshold, maybe_override) {
(None, None) => panic!("Programmer error! Should have at least one factors list."),
(Some(threshold), None) => {
println!("πŸ¦€ ONLY threshold status: {:?}", threshold);
threshold
}
(None, Some(r#override)) => {
println!("πŸ¦€ ONLY override status: {:?}", r#override);
r#override
}
(Some(threshold), Some(r#override)) => {
println!("πŸ¦€ threshold status: {:?}", threshold);
println!("πŸ¦€ override status: {:?}", r#override);
match (threshold, r#override) {
(InProgress, InProgress) => PetitionForFactorListStatus::InProgress,
(Finished(Fail), InProgress) => PetitionForFactorListStatus::InProgress,
(InProgress, Finished(Fail)) => PetitionForFactorListStatus::InProgress,
(Finished(Fail), Finished(Fail)) => PetitionForFactorListStatus::Finished(Fail),
(Finished(Success), _) => PetitionForFactorListStatus::Finished(Success),
(_, Finished(Success)) => PetitionForFactorListStatus::Finished(Success),
}
}
(Some(threshold), None) => threshold,
(None, Some(r#override)) => r#override,
(Some(threshold), Some(r#override)) => match (threshold, r#override) {
(InProgress, InProgress) => PetitionForFactorListStatus::InProgress,
(Finished(Fail), InProgress) => PetitionForFactorListStatus::InProgress,
(InProgress, Finished(Fail)) => PetitionForFactorListStatus::InProgress,
(Finished(Fail), Finished(Fail)) => PetitionForFactorListStatus::Finished(Fail),
(Finished(Success), _) => PetitionForFactorListStatus::Finished(Success),
(_, Finished(Success)) => PetitionForFactorListStatus::Finished(Success),
},
}
}
}
@@ -352,6 +336,7 @@ impl PetitionWithFactors {
pub fn new_unsecurified(factor: FactorInstance) -> Self {
Self::new_threshold(vec![factor], 1).unwrap() // define as 1/1 threshold factor, which is a good definition.
}

pub fn new_override(factors: Vec<FactorInstance>) -> Option<Self> {
if factors.is_empty() {
return None;
@@ -361,6 +346,7 @@ impl PetitionWithFactors {
PetitionWithFactorsInput::new_override(IndexSet::from_iter(factors)),
))
}

pub fn new_not_used() -> Self {
Self {
petition_kind: Petition::Override, // does not matter..
@@ -377,11 +363,11 @@ impl PetitionWithFactors {
self.state.borrow_mut().did_skip(factor_instance, simulated);
}

pub fn has_instance_with_id(&self, factor_instance: &OwnedFactorInstance) -> bool {
pub fn has_instance_with_id(&self, owned_factor_instance: &OwnedFactorInstance) -> bool {
self.input
.factors
.iter()
.any(|f| f == &factor_instance.factor_instance)
.any(|f| f == owned_factor_instance.factor_instance())
}

pub fn add_signature(&self, signature: &HDSignature) {
@@ -444,7 +430,9 @@ impl FactorSourceReferencing for FactorInstance {

impl FactorSourceReferencing for HDSignature {
fn factor_source_id(&self) -> FactorSourceID {
self.owned_factor_instance.factor_instance.factor_source_id
self.owned_factor_instance
.factor_instance()
.factor_source_id
}
}

@@ -500,14 +488,12 @@ impl PetitionWithFactorsState {

pub(crate) fn did_skip(&self, factor_instance: &FactorInstance, simulated: bool) {
if !simulated {
println!("πŸ™…πŸ»β€β™€οΈ did_skip: {:?}", factor_instance);
self.assert_not_referencing_factor_source(factor_instance.factor_source_id);
}
self.skipped.borrow_mut().insert(factor_instance);
}

pub(crate) fn add_signature(&self, signature: &HDSignature) {
println!("πŸ–ŠοΈ add_signature: {:?}", signature);
self.assert_not_referencing_factor_source(signature.factor_source_id());
self.signed.borrow_mut().insert(signature)
}
@@ -532,10 +518,6 @@ impl PetitionWithFactorsState {
.borrow()
.references_factor_source_by_id(factor_source_id)
{
println!(
"🐍 Found factor_source_id: {:?} in signed list",
factor_source_id
);
return true;
}

@@ -544,10 +526,6 @@ impl PetitionWithFactorsState {
.borrow()
.references_factor_source_by_id(factor_source_id)
{
println!(
"🐍 Found factor_source_id: {:?} in skipped list",
factor_source_id
);
return true;
}

@@ -599,28 +577,13 @@ impl PetitionWithFactorsInput {
}

fn factors_left_to_prompt(&self, snapshot: PetitionWithFactorsStateSnapshot) -> i8 {
let left = self.factors_count() - snapshot.prompted_count();
println!(
"πŸ™ factors_count: {}, prompted_count: {}, left: {}",
self.factors_count(),
snapshot.prompted_count(),
left
);
left
self.factors_count() - snapshot.prompted_count()
}

fn is_failure_with(&self, snapshot: PetitionWithFactorsStateSnapshot) -> bool {
let signed_or_pending =
self.factors_left_to_prompt(snapshot.clone()) + snapshot.signed_count();
let is_failure = signed_or_pending < self.required;
println!(
"🐳 factors_left_to_prompt: {}, required: {}, signed_or_pending: {} => is_failure: {} (factors_left_to_prompt < required)",
self.factors_left_to_prompt(snapshot),
self.required,
signed_or_pending,
is_failure
);
is_failure
signed_or_pending < self.required
}
}

@@ -644,12 +607,6 @@ impl PetitionWithFactors {
}

fn is_finished_successfully(&self) -> bool {
println!(
"🐯 PetitionWithFactors kind: {:?}, input: {:?}, state_snapshot: {:?}",
self.petition_kind,
self.input,
self.state_snapshot()
);
self.input.is_fulfilled_by(self.state_snapshot())
}

@@ -801,14 +758,12 @@ impl Petitions {
}

fn skip_factor_source_with_id(&self, skipped_factor_source_id: &FactorSourceID) {
println!("🚫 Skipping factor source: {:?}", skipped_factor_source_id);
let binding = self.txid_to_petition.borrow();
let txids = self.factor_to_txid.get(skipped_factor_source_id).unwrap();
txids.into_iter().for_each(|txid| {
let petition = binding.get(txid).unwrap();
petition.skipped_factor_source(skipped_factor_source_id)
});
println!("🚫 Skipped factor source: {:?}", skipped_factor_source_id);
}

pub(crate) fn process_single_response(
@@ -846,21 +801,6 @@ impl Petitions {
}
}
}

// pub(super) fn process_outcome(
// &self,
// outcome: SignWithFactorSourceOrSourcesOutcome,
// factor_sources: IndexSet<FactorSource>,
// ) {
// for factor_source in factor_sources {
// let txids = self.factor_to_txid.get(&factor_source.id).unwrap();
// for txid in txids {
// let binding = self.txid_to_petition.borrow();
// let petition = binding.get(txid).unwrap();
// petition.process_outcome(&outcome, &factor_source);
// }
// }
// }
}

/// Essentially a wrapper around `Iterator<Item = PetitionOfTransactionByEntity>`.
@@ -915,18 +855,16 @@ impl PetitionOfTransaction {
) -> IndexSet<OwnedFactorInstance> {
self._all_factor_instances()
.into_iter()
.filter(|f| f.factor_instance.factor_source_id == *factor_source_id)
.filter(|f| f.factor_instance().factor_source_id == *factor_source_id)
.collect()
}

pub fn add_signature(&self, signature: HDSignature) {
println!("❓ Adding signature: {:?}", signature);
let for_entities = self.for_entities.borrow_mut();
let for_entity = for_entities
.get(&signature.owned_factor_instance.owner)
.unwrap();
for_entity.add_signature(signature.clone());
println!("⁉️ Added signature? {:?}", signature);
}

pub fn skipped_factor_source(&self, factor_source_id: &FactorSourceID) {
@@ -943,7 +881,7 @@ impl PetitionOfTransaction {
let owned_factors = self
.all_factor_instances_of_source(factor_source_id)
.into_iter()
.filter(|fi| fi.factor_instance.factor_source_id() == *factor_source_id)
.filter(|fi| fi.by_factor_source(factor_source_id))
.collect::<IndexSet<_>>();

owned_factors
28 changes: 0 additions & 28 deletions src/types/signatures_building_coordinator.rs
Original file line number Diff line number Diff line change
@@ -79,12 +79,6 @@ impl SignaturesBuildingCoordinator {

add(primary_role_matrix.override_factors.clone());
add(primary_role_matrix.threshold_factors.clone());

// let builder = SignaturesBuilderLevel2::new_securified(
// address.clone(),
// primary_role_matrix,
// );
// builders_level_2.insert(address.clone(), builder);
let petition = PetitionOfTransactionByEntity::new_securified(
transaction_index.clone(),
address.clone(),
@@ -96,15 +90,6 @@ impl SignaturesBuildingCoordinator {
let factor_instance = uec;
let factor_source_id = factor_instance.factor_source_id;
use_factor_in_tx(&factor_source_id, &transaction.intent_hash);

// let builder =
// SignaturesBuilderLevel2::new_unsecurified(
// address.clone(),
// factor_instance,
// );
// builders_level_2
// .insert(address.clone(), builder);

let petition = PetitionOfTransactionByEntity::new_unsecurified(
transaction_index.clone(),
address.clone(),
@@ -114,14 +99,6 @@ impl SignaturesBuildingCoordinator {
}
}
}
// builders_level_0.insert(
// transaction.intent_hash.clone(),
// SignaturesBuilderLevel1::new(
// transaction.intent_hash.clone(),
// builders_level_2,
// ),
// );

let petition_of_tx =
PetitionOfTransaction::new(transaction.intent_hash.clone(), petitions_for_entities);

@@ -178,11 +155,9 @@ impl SignaturesBuildingCoordinator {
async fn do_sign(&self) -> Result<()> {
let factors_of_kind = self.factors_of_kind.clone();
for (kind, factor_sources) in factors_of_kind.into_iter() {
println!("✍🏻 sign with factor sources: {:?}", factor_sources);
self.sign_with_factor_sources(factor_sources, kind).await?;
let should_continue = self.continue_if_necessary()?;
if !should_continue {
println!("🌈 finished early");
return Ok(()); // finished early, we have fulfilled signing requirements of all transactions
}
}
@@ -233,7 +208,6 @@ impl SignaturesBuildingCoordinator {
&self,
response: SignWithFactorSourceOrSourcesOutcome<HDSignature>,
) -> bool {
println!("πŸ”₯ process_single_response: {:?}", response);
{
let petitions = self.petitions.borrow_mut();
petitions.process_single_response(response);
@@ -244,7 +218,6 @@ impl SignaturesBuildingCoordinator {
&self,
response: SignWithFactorSourceOrSourcesOutcome<BatchSigningResponse>,
) {
println!("πŸ”₯ process_batch_response: {:?}", response);
let petitions = self.petitions.borrow_mut();
petitions.process_batch_response(response)
}
@@ -253,7 +226,6 @@ impl SignaturesBuildingCoordinator {
impl SignaturesBuildingCoordinator {
pub async fn sign(self) -> Result<SignaturesOutcome> {
self.do_sign().await?;
println!("πŸ€·β€β™‚οΈ finished signing?");
let outcome = self.petitions.into_inner().outcome();
Ok(outcome)
}
23 changes: 1 addition & 22 deletions src/types/signing_driver.rs
Original file line number Diff line number Diff line change
@@ -24,10 +24,8 @@ impl SigningDriver {
factor_sources: IndexSet<FactorSource>,
signatures_building_coordinator: &SignaturesBuildingCoordinator,
) {
let factor_source_count = factor_sources.len();
match self {
Self::ParallelBatch(driver) => {
println!("πŸš€ Signing with Parallel Batch driver...");
let per_factor_source = factor_sources
.clone()
.into_iter()
@@ -50,12 +48,7 @@ impl SigningDriver {
signatures_building_coordinator.process_batch_response(response);
}
Self::SerialBatch(driver) => {
println!("πŸš— Signing with Serial Batch driver... #{} factor sources, signing with one factor source at a time", factor_source_count);
for factor_source in factor_sources {
println!(
"πŸš— Signing with Serial Batch driver, signing with factor source: {:?}",
factor_source.id
);
let batch_signing_request = signatures_building_coordinator
.input_for_parallel_batch_driver(&factor_source.id);

@@ -68,24 +61,14 @@ impl SigningDriver {
);

let response = driver.sign(request).await;

println!(
"β˜‘οΈ Got 1 response (of #{}) from Serial Batch driver: {:?}",
factor_source_count, &response
);
signatures_building_coordinator.process_batch_response(response);
}
}
Self::SerialSingle(driver) => {
println!("🐌 Signing with Serial Single driver...#{} factor sources, signing with one factor source at a time, many times, one time for each factor instance", factor_source_count);
for factor_source in factor_sources {
let invalid_transactions_if_skipped = signatures_building_coordinator
.invalid_transactions_if_skipped(&factor_source.id);

println!(
"🐌 Signing with Serial Single, signing with factor source: {:?}",
factor_source.id
);
let requests_per_transaction = signatures_building_coordinator
.inputs_for_serial_single_driver(&factor_source.id);
for (_, requests_for_transaction) in requests_per_transaction {
@@ -94,15 +77,11 @@ impl SigningDriver {
partial_request,
invalid_transactions_if_skipped.clone(),
);
println!(
"🐌 Signing with Serial Single, signing with instance: {:?}",
&request.input.owned_factor_instance
);

let response = driver.sign(request).await;
let should_continue_with_factor_source =
signatures_building_coordinator.process_single_response(response);
if !should_continue_with_factor_source {
println!("⁉️ Breaking, should continue with next factor source....");
break;
}
}

0 comments on commit 59c2060

Please sign in to comment.