Skip to content

Commit

Permalink
Bubble up bonsai prover errors (#1532)
Browse files Browse the repository at this point in the history
This PR integrates the `.error_msg` + sessionID into the `bail!()`
contents for easier end user debugging of backend failures (and easier
reporting). Additionally it adds some cycle tracking stats on the debug
level.
  • Loading branch information
mothran authored and SchmErik committed Mar 8, 2024
1 parent 4e4d8fc commit 227670f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions risc0/zkvm/src/host/client/prove/bonsai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use std::time::Duration;

use anyhow::{anyhow, bail, ensure, Result};
use anyhow::{anyhow, bail, ensure, Context, Result};
use bonsai_sdk::alpha::Client;

use super::Prover;
Expand Down Expand Up @@ -90,6 +90,15 @@ impl Prover for BonsaiProver {
.receipt_url
.ok_or(anyhow!("API error, missing receipt on completed session"))?;

let stats = res
.stats
.context("Missing stats object on Bonsai status res")?;
tracing::debug!(
"Bonsai usage: cycles: {} total_cycles: {}",
stats.cycles,
stats.total_cycles
);

let receipt_buf = client.download(&receipt_url)?;
let receipt: Receipt = bincode::deserialize(&receipt_buf)?;

Expand All @@ -106,7 +115,13 @@ impl Prover for BonsaiProver {
}
return Ok(receipt);
} else {
bail!("Bonsai prover workflow exited: {}", res.status);
bail!(
"Bonsai prover workflow [{}] exited: {} err: {}",
session.uuid,
res.status,
res.error_msg
.unwrap_or("Bonsai workflow missing error_msg".into()),
);
}
}
}
Expand Down

0 comments on commit 227670f

Please sign in to comment.