Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(host,provers,tasks): handle local job cancellation #345

Merged
merged 4 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion host/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl ProofActor {
)
.await
.or_else(|e| {
if e.to_string().contains("no id found") {
if e.to_string().contains("No data for query") {
warn!("Task already cancelled or not yet started!");
Ok(())
} else {
Expand Down
11 changes: 10 additions & 1 deletion provers/risc0/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,16 @@ impl Prover for Risc0Prover {
}

async fn cancel(key: ProofKey, id_store: Box<&mut dyn IdStore>) -> ProverResult<()> {
let uuid = id_store.read_id(key).await?;
let uuid = match id_store.read_id(key).await {
Ok(uuid) => uuid,
Err(e) => {
if e.to_string().contains("No data for query") {
return Ok(());
} else {
return Err(ProverError::GuestError(e.to_string()));
}
}
};
cancel_proof(uuid)
.await
.map_err(|e| ProverError::GuestError(e.to_string()))?;
Expand Down
11 changes: 10 additions & 1 deletion provers/sp1/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,16 @@ impl Prover for Sp1Prover {
}

async fn cancel(key: ProofKey, id_store: Box<&mut dyn IdStore>) -> ProverResult<()> {
let proof_id = id_store.read_id(key).await?;
let proof_id = match id_store.read_id(key).await {
Ok(proof_id) => proof_id,
Err(e) => {
if e.to_string().contains("No data for query") {
return Ok(());
} else {
return Err(ProverError::GuestError(e.to_string()));
}
}
};
let private_key = env::var("SP1_PRIVATE_KEY").map_err(|_| {
ProverError::GuestError("SP1_PRIVATE_KEY must be set for remote proving".to_owned())
})?;
Expand Down
12 changes: 10 additions & 2 deletions tasks/src/adv_sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,14 +824,22 @@ impl TaskDb {
1;
"#,
)?;
let query = statement.query_row(
let query = match statement.query_row(
named_params! {
":chain_id": chain_id,
":blockhash": blockhash.to_vec(),
":proofsys_id": proof_key,
},
|row| row.get::<_, String>(0),
)?;
) {
Ok(q) => q,
Err(e) => {
return match e {
rusqlite::Error::QueryReturnedNoRows => Err(TaskManagerError::NoData),
e => Err(e.into()),
}
}
};

Ok(query)
}
Expand Down
2 changes: 2 additions & 0 deletions tasks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub enum TaskManagerError {
IOError(IOErrorKind),
#[error("SQL Error {0}")]
SqlError(String),
#[error("No data for query")]
NoData,
#[error("Anyhow error: {0}")]
Anyhow(String),
}
Expand Down
2 changes: 1 addition & 1 deletion tasks/src/mem_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl InMemoryTaskDb {
self.store
.get(&key)
.cloned()
.ok_or_else(|| TaskManagerError::SqlError("no id found".to_owned()))
.ok_or(TaskManagerError::NoData)
}
}

Expand Down
Loading