Skip to content

Commit 4005822

Browse files
authored
Merge pull request #137 from 0xMiden/ajl-delegated-prover-fix
Update delegated prover Rust example
2 parents 9455589 + 13abd50 commit 4005822

File tree

2 files changed

+40
-20
lines changed

2 files changed

+40
-20
lines changed

docs/src/rust-client/delegated_proving_tutorial.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async fn main() -> Result<(), ClientError> {
126126
// -------------------------------------------------------------------------
127127
let remote_tx_prover: RemoteTransactionProver =
128128
RemoteTransactionProver::new("https://tx-prover.testnet.miden.io");
129-
let _tx_prover: Arc<dyn TransactionProver> = Arc::new(remote_tx_prover);
129+
let tx_prover: Arc<dyn TransactionProver> = Arc::new(remote_tx_prover);
130130

131131
// We use a dummy transaction request to showcase delegated proving.
132132
// The only effect of this tx should be increasing Alice's nonce.
@@ -142,18 +142,28 @@ async fn main() -> Result<(), ClientError> {
142142
.build()
143143
.unwrap();
144144

145-
// Note: The delegated prover API has changed in v0.12
146-
// The new API would be:
147-
// 1. Execute transaction locally to get execution result
148-
// 2. Use prove_transaction_with() to generate proof with remote prover
149-
// 3. Submit the proven transaction
150-
// However, since the delegated prover is not live yet, we'll use the standard flow
145+
// Step 1: Execute the transaction locally
146+
println!("Executing transaction...");
147+
let tx_result = client
148+
.execute_transaction(alice_account.id(), transaction_request)
149+
.await?;
150+
151+
// Step 2: Prove the transaction using the remote prover
152+
println!("Proving transaction with remote prover...");
153+
let proven_transaction = client.prove_transaction_with(&tx_result, tx_prover).await?;
154+
155+
// Step 3: Submit the proven transaction
156+
println!("Submitting proven transaction...");
157+
let submission_height = client
158+
.submit_proven_transaction(proven_transaction, &tx_result)
159+
.await?;
151160

152-
let _tx_id = client
153-
.submit_new_transaction(alice_account.id(), transaction_request)
161+
// Step 4: Apply the transaction to local store
162+
client
163+
.apply_transaction(&tx_result, submission_height)
154164
.await?;
155165

156-
println!("Transaction submitted (delegated proving not available yet)");
166+
println!("Transaction submitted successfully using delegated prover!");
157167

158168
client.sync_state().await.unwrap();
159169

rust-client/src/bin/delegated_prover.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async fn main() -> Result<(), ClientError> {
6060
// -------------------------------------------------------------------------
6161
let remote_tx_prover: RemoteTransactionProver =
6262
RemoteTransactionProver::new("https://tx-prover.testnet.miden.io");
63-
let _tx_prover: Arc<dyn TransactionProver> = Arc::new(remote_tx_prover);
63+
let tx_prover: Arc<dyn TransactionProver> = Arc::new(remote_tx_prover);
6464

6565
// We use a dummy transaction request to showcase delegated proving.
6666
// The only effect of this tx should be increasing Alice's nonce.
@@ -76,18 +76,28 @@ async fn main() -> Result<(), ClientError> {
7676
.build()
7777
.unwrap();
7878

79-
// Note: The delegated prover API has changed in v0.12
80-
// The new API would be:
81-
// 1. Execute transaction locally to get execution result
82-
// 2. Use prove_transaction_with() to generate proof with remote prover
83-
// 3. Submit the proven transaction
84-
// However, since the delegated prover is not live yet, we'll use the standard flow
79+
// Step 1: Execute the transaction locally
80+
println!("Executing transaction...");
81+
let tx_result = client
82+
.execute_transaction(alice_account.id(), transaction_request)
83+
.await?;
84+
85+
// Step 2: Prove the transaction using the remote prover
86+
println!("Proving transaction with remote prover...");
87+
let proven_transaction = client.prove_transaction_with(&tx_result, tx_prover).await?;
88+
89+
// Step 3: Submit the proven transaction
90+
println!("Submitting proven transaction...");
91+
let submission_height = client
92+
.submit_proven_transaction(proven_transaction, &tx_result)
93+
.await?;
8594

86-
let _tx_id = client
87-
.submit_new_transaction(alice_account.id(), transaction_request)
95+
// Step 4: Apply the transaction to local store
96+
client
97+
.apply_transaction(&tx_result, submission_height)
8898
.await?;
8999

90-
println!("Transaction submitted (delegated proving not available yet)");
100+
println!("Transaction submitted successfully using delegated prover!");
91101

92102
client.sync_state().await.unwrap();
93103

0 commit comments

Comments
 (0)