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

fix(raiko): refine error return #378

Merged
merged 5 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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 docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,5 @@ if [[ -n $ZK ]]; then
update_raiko_sgx_instance_id $RAIKO_CONF_BASE_CONFIG
update_docker_chain_specs $RAIKO_CONF_CHAIN_SPECS

RUST_LOG=debug /opt/raiko/bin/raiko-host "$@"
/opt/raiko/bin/raiko-host "$@"
fi
11 changes: 6 additions & 5 deletions host/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ impl ProofActor {
}
result = Self::handle_message(proof_request, key.clone(), &opts, &chain_specs) => {
match result {
Ok(()) => {
info!("Host handling message");
Ok(status) => {
info!("Host handling message: {status:?}");
}
Err(error) => {
error!("Worker failed due to: {error:?}");
Expand Down Expand Up @@ -151,14 +151,14 @@ impl ProofActor {
key: TaskDescriptor,
opts: &Opts,
chain_specs: &SupportedChainSpecs,
) -> HostResult<()> {
) -> HostResult<TaskStatus> {
let mut manager = get_task_manager(&opts.clone().into());

let status = manager.get_task_proving_status(&key).await?;

if let Some(latest_status) = status.iter().last() {
if !matches!(latest_status.0, TaskStatus::Registered) {
return Ok(());
return Ok(latest_status.0);
}
}

Expand All @@ -178,7 +178,8 @@ impl ProofActor {
manager
.update_task_progress(key, status, proof.as_deref())
.await
.map_err(|e| e.into())
.map_err(HostError::from)?;
Ok(status)
}
}

Expand Down
10 changes: 8 additions & 2 deletions host/src/server/api/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ impl From<Vec<u8>> for Status {

impl From<TaskStatus> for Status {
fn from(status: TaskStatus) -> Self {
Self::Ok {
data: ProofResponse::Status { status },
match status {
TaskStatus::Success | TaskStatus::WorkInProgress | TaskStatus::Registered => Self::Ok {
data: ProofResponse::Status { status },
},
_ => Self::Error {
error: "task_failed".to_string(),
message: format!("Task failed with status: {:?}", status),
},
smtmfft marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
Loading