Skip to content

Commit

Permalink
fix(raiko): refine error return (#378)
Browse files Browse the repository at this point in the history
* fix(raiko): refine error return

* fix lint

Signed-off-by: smtmfft <smtm@taiko.xyz>

* fix lint

Signed-off-by: smtmfft <smtm@taiko.xyz>

* fix zk entrypoint log level

Signed-off-by: smtmfft <smtm@taiko.xyz>

* Update host/src/server/api/v2/mod.rs

Co-authored-by: Petar Vujović <petarvujovic98@gmail.com>

---------

Signed-off-by: smtmfft <smtm@taiko.xyz>
Co-authored-by: Petar Vujović <petarvujovic98@gmail.com>
  • Loading branch information
smtmfft and petarvujovic98 authored Sep 20, 2024
1 parent c2b0db5 commit f4f818d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
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:?}"),
},
}
}
}
Expand Down

0 comments on commit f4f818d

Please sign in to comment.