-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Sajjon/simplify
Add RETRY logic | Cleanup
- Loading branch information
Showing
33 changed files
with
1,061 additions
and
584 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
tarpaulin-report.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ timeout = "2m" | |
locked = true | ||
all-features = true | ||
jobs = 1 | ||
out = ["html"] | ||
out = ["Html"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Debug unit tests in library 'signing'", | ||
"cargo": { | ||
"args": [ | ||
"test", | ||
"--no-run", | ||
"--lib", | ||
"--package=signing" | ||
], | ||
"filter": { | ||
"name": "signing", | ||
"kind": "lib" | ||
} | ||
}, | ||
"args": [], | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Debug integration test 'main'", | ||
"cargo": { | ||
"args": [ | ||
"test", | ||
"--no-run", | ||
"--test=main", | ||
"--package=signing" | ||
], | ||
"filter": { | ||
"name": "main", | ||
"kind": "test" | ||
} | ||
}, | ||
"args": [], | ||
"cwd": "${workspaceFolder}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"substate", | ||
"txid", | ||
"txids", | ||
"unsecurified", | ||
"Yubikey" | ||
] | ||
} |
2 changes: 1 addition & 1 deletion
2
src/drivers/signing_drivers_context.rs → ...s/is_use_factor_source_drivers_context.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
use crate::prelude::*; | ||
|
||
pub trait IsUseFactorSourceDriversContext { | ||
fn driver_for_factor_source_kind(&self, kind: FactorSourceKind) -> SigningDriver; | ||
fn driver_for_factor_source_kind(&self, kind: FactorSourceKind) -> UseFactorSourceDriver; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
mod batch_signing_response; | ||
mod batch_tx_batch_key_signing_request; | ||
mod parallel_batch_signing_driver; | ||
mod serial_batch_signing_driver; | ||
mod serial_single_signing_driver; | ||
mod signing_driver; | ||
mod signing_drivers_context; | ||
mod is_use_factor_source_drivers_context; | ||
mod parallel_batch_use_factor_sources_driver; | ||
mod serial_batch_use_factor_source_driver; | ||
mod serial_single_use_factor_source_driver; | ||
mod use_factor_source_client; | ||
mod use_factor_source_driver; | ||
|
||
pub use batch_signing_response::*; | ||
pub use batch_tx_batch_key_signing_request::*; | ||
pub use parallel_batch_signing_driver::*; | ||
pub use serial_batch_signing_driver::*; | ||
pub use serial_single_signing_driver::*; | ||
pub use signing_driver::*; | ||
pub use signing_drivers_context::*; | ||
pub use is_use_factor_source_drivers_context::*; | ||
pub use parallel_batch_use_factor_sources_driver::*; | ||
pub use serial_batch_use_factor_source_driver::*; | ||
pub use serial_single_use_factor_source_driver::*; | ||
pub use use_factor_source_client::*; | ||
pub use use_factor_source_driver::*; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use crate::prelude::*; | ||
|
||
/// A collection of factor sources to use to sign, transactions with multiple keys | ||
/// (derivations paths). | ||
pub struct ParallelBatchSigningRequest { | ||
/// Per factor source, a set of transactions to sign, with | ||
/// multiple derivations paths. | ||
pub per_factor_source: IndexMap<FactorSourceID, BatchTXBatchKeySigningRequest>, | ||
/// A collection of transactions which would be invalid if the user skips | ||
/// signing with this factor source. | ||
pub invalid_transactions_if_skipped: IndexSet<InvalidTransactionIfSkipped>, | ||
} | ||
impl ParallelBatchSigningRequest { | ||
pub fn new( | ||
per_factor_source: IndexMap<FactorSourceID, BatchTXBatchKeySigningRequest>, | ||
invalid_transactions_if_skipped: IndexSet<InvalidTransactionIfSkipped>, | ||
) -> Self { | ||
Self { | ||
per_factor_source, | ||
invalid_transactions_if_skipped, | ||
} | ||
} | ||
pub fn factor_source_ids(&self) -> IndexSet<FactorSourceID> { | ||
self.per_factor_source.keys().cloned().collect() | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
pub trait IsUseFactorSourcesDriver { | ||
async fn did_fail_ask_if_retry(&self, factor_source_ids: IndexSet<FactorSourceID>) -> bool; | ||
} | ||
|
||
#[async_trait::async_trait] | ||
pub trait IsTestUseFactorSourcesDriver: IsUseFactorSourcesDriver + Sync { | ||
fn simulated_user(&self) -> SimulatedUser; | ||
|
||
fn should_simulate_failure(&self, factor_source_ids: IndexSet<FactorSourceID>) -> bool { | ||
self.simulated_user() | ||
.simulate_failure_if_needed(factor_source_ids) | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl<T> IsUseFactorSourcesDriver for T | ||
where | ||
T: IsTestUseFactorSourcesDriver, | ||
{ | ||
async fn did_fail_ask_if_retry(&self, factor_source_ids: IndexSet<FactorSourceID>) -> bool { | ||
self.simulated_user().retry_if_needed(factor_source_ids) | ||
} | ||
} | ||
|
||
/// A driver for a factor source kind which supports *Batch* usage of | ||
/// multiple factor sources in parallel. | ||
/// | ||
/// Most FactorSourceKinds does in fact NOT support parallel usage, | ||
/// e.g. signing using multiple factors sources at once, but some do, | ||
/// typically the DeviceFactorSource does, i.e. we can load multiple | ||
/// mnemonics from secure storage in one go and sign with all of them | ||
/// "in parallel". | ||
/// | ||
/// This is a bit of a misnomer, as we don't actually use them in parallel, | ||
/// but rather we iterate through all mnemonics and derive public keys/ | ||
/// or sign a payload with each of them in sequence | ||
/// | ||
/// The user does not have the ability to SKIP a certain factor source, | ||
/// instead either ALL factor sources are used to sign the transactions | ||
/// or none. | ||
/// | ||
/// Example of a Parallel Batch Signing Driver is that for DeviceFactorSource. | ||
#[async_trait::async_trait] | ||
pub trait ParallelBatchUseFactorSourcesDriver: IsUseFactorSourcesDriver { | ||
async fn sign( | ||
&self, | ||
request: ParallelBatchSigningRequest, | ||
) -> Result<SignWithFactorSourceOrSourcesOutcome<BatchSigningResponse>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.