Skip to content

Commit

Permalink
fix(raiko): revert v1 response back to previous format (#340)
Browse files Browse the repository at this point in the history
* revert v1 response back to previous format

* fix clippy

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

* Update host/src/server/api/v1/proof.rs

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

* Update host/src/server/api/v1/proof.rs

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

* Update host/src/server/api/v1/proof.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 Aug 14, 2024
1 parent b901ce6 commit 5526cc0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions host/src/server/api/v1/proof.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use axum::{debug_handler, extract::State, routing::post, Json, Router};
use raiko_core::interfaces::ProofRequest;
use raiko_lib::prover::Proof;
use raiko_tasks::get_task_manager;
use serde_json::Value;
use utoipa::OpenApi;
Expand All @@ -9,9 +8,12 @@ use crate::{
interfaces::HostResult,
metrics::{dec_current_req, inc_current_req, inc_guest_req_count, inc_host_req_count},
proof::handle_proof,
server::api::v1::Status,
ProverState,
};

use super::ProofResponse;

#[utoipa::path(post, path = "/proof",
tag = "Proving",
request_body = ProofRequestOpt,
Expand All @@ -31,7 +33,7 @@ use crate::{
async fn proof_handler(
State(prover_state): State<ProverState>,
Json(req): Json<Value>,
) -> HostResult<Json<Proof>> {
) -> HostResult<Json<Status>> {
inc_current_req();
// Override the existing proof request config from the config file and command line
// options with the request from the client.
Expand All @@ -57,7 +59,16 @@ async fn proof_handler(
dec_current_req();
e
})
.map(Json)
.map(|proof| {
dec_current_req();
Json(Status::Ok {
data: ProofResponse {
output: None,
proof: proof.proof,
quote: proof.quote,
},
})
})
}

#[derive(OpenApi)]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub type ProofKey = (ChainId, B256, u8);
#[derive(Debug, Serialize, ToSchema, Deserialize, Default)]
/// The response body of a proof request.
pub struct Proof {
/// The ZK proof.
/// The proof either TEE or ZK.
pub proof: Option<String>,
/// The TEE quote.
pub quote: Option<String>,
Expand Down

0 comments on commit 5526cc0

Please sign in to comment.