Skip to content

Commit

Permalink
feat: Make TransactionProver maybe_async_trait (#913)
Browse files Browse the repository at this point in the history
* feat: Make TransactionProver maybe_async_trait

* chore: format
  • Loading branch information
igamigo authored Oct 9, 2024
1 parent deafad8 commit 8fe07cf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 0.6.0 (TBD)

- [BREAKING] Changed `TransactionProver` trait to be `maybe_async_trait` based on the `async` feature (#913).
- [BREAKING] Changed `TransactionExecutor` and `TransactionHost` to use trait objects (#897).
- Implemented kernel procedure to set transaction expiration block delta (#897).
- Created a proving service that receives `TransactionWitness` and returns the proof using gRPC (#881).
Expand Down
11 changes: 7 additions & 4 deletions miden-tx/src/prover/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "async")]
use alloc::boxed::Box;
use alloc::{sync::Arc, vec::Vec};

use miden_lib::transaction::TransactionKernel;
Expand All @@ -8,7 +10,7 @@ use miden_objects::{
use miden_prover::prove;
pub use miden_prover::ProvingOptions;
use vm_processor::MemAdviceProvider;
use winter_maybe_async::maybe_async;
use winter_maybe_async::*;

use super::{TransactionHost, TransactionProverError};
use crate::executor::TransactionMastStore;
Expand All @@ -18,6 +20,7 @@ use crate::executor::TransactionMastStore;

/// The [TransactionProver] trait defines the interface that transaction witness objects use to
/// prove transactions and generate a [ProvenTransaction].
#[maybe_async_trait]
pub trait TransactionProver {
/// Proves the provided transaction and returns a [ProvenTransaction].
///
Expand All @@ -28,7 +31,7 @@ pub trait TransactionProver {
#[maybe_async]
fn prove(
&self,
transaction: impl Into<TransactionWitness>,
tx_witness: TransactionWitness,
) -> Result<ProvenTransaction, TransactionProverError>;
}

Expand Down Expand Up @@ -64,13 +67,13 @@ impl Default for LocalTransactionProver {
}
}

#[maybe_async_trait]
impl TransactionProver for LocalTransactionProver {
#[maybe_async]
fn prove(
&self,
transaction: impl Into<TransactionWitness>,
tx_witness: TransactionWitness,
) -> Result<ProvenTransaction, TransactionProverError> {
let tx_witness: TransactionWitness = transaction.into();
let TransactionWitness { tx_inputs, tx_args, advice_witness } = tx_witness;

let account = tx_inputs.account();
Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ fn prove_witness_and_verify() {

let proof_options = ProvingOptions::default();
let prover = LocalTransactionProver::new(proof_options);
let proven_transaction = prover.prove(executed_transaction).unwrap();
let proven_transaction = prover.prove(executed_transaction.into()).unwrap();

assert_eq!(proven_transaction.id(), executed_transaction_id);

Expand Down
2 changes: 1 addition & 1 deletion miden-tx/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn prove_and_verify_transaction(

let proof_options = ProvingOptions::default();
let prover = LocalTransactionProver::new(proof_options);
let proven_transaction = prover.prove(executed_transaction).unwrap();
let proven_transaction = prover.prove(executed_transaction.into()).unwrap();

assert_eq!(proven_transaction.id(), executed_transaction_id);

Expand Down

0 comments on commit 8fe07cf

Please sign in to comment.