-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec8860b
commit 6729ff9
Showing
14 changed files
with
131 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ pub mod prove; | |
pub enum CairoVersion { | ||
V0, | ||
V1, | ||
PIE, | ||
} | ||
|
||
impl FromStr for CairoVersion { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
mod cairo; | ||
mod cairo0; | ||
|
||
mod pie; | ||
pub use cairo::{CairoCompiledProgram, CairoProverInput}; | ||
pub use cairo0::{Cairo0CompiledProgram, Cairo0ProverInput}; | ||
pub use pie::PieProverInput; | ||
|
||
#[derive(Debug)] | ||
pub enum ProverInput { | ||
Cairo0(Cairo0ProverInput), | ||
Cairo(CairoProverInput), | ||
Pie(PieProverInput), | ||
} | ||
|
||
impl ProverInput { | ||
pub fn to_json_value(&self) -> serde_json::Value { | ||
match self { | ||
ProverInput::Cairo0(input) => serde_json::to_value(input).unwrap(), | ||
ProverInput::Cairo(input) => serde_json::to_value(input).unwrap(), | ||
ProverInput::Pie(input) => serde_json::to_value(input).unwrap(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Module: prover_input/pie.rs | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
pub struct PieProverInput { | ||
pub pie_zip: Vec<u8>, | ||
pub layout: String, | ||
pub n_queries: Option<u32>, | ||
pub pow_bits: Option<u32>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
use axum::{routing::post, Router}; | ||
|
||
use crate::server::AppState; | ||
mod bootloader; | ||
mod cairo; | ||
mod cairo0; | ||
mod pie; | ||
|
||
pub fn router(app_state: AppState) -> Router { | ||
Router::new() | ||
.route("/cairo0", post(cairo0::root)) | ||
.route("/cairo", post(cairo::root)) | ||
.route("/pie", post(pie::root)) | ||
.with_state(app_state) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::auth::jwt::Claims; | ||
use crate::extractors::workdir::TempDirHandle; | ||
use crate::server::AppState; | ||
use crate::threadpool::{CairoVersionedInput, ExecuteParams}; | ||
use axum::Json; | ||
use axum::{extract::State, http::StatusCode, response::IntoResponse}; | ||
use common::prover_input::PieProverInput; | ||
use serde_json::json; | ||
|
||
pub async fn root( | ||
State(app_state): State<AppState>, | ||
TempDirHandle(dir): TempDirHandle, | ||
_claims: Claims, | ||
Json(program_input): Json<PieProverInput>, | ||
) -> impl IntoResponse { | ||
let thread_pool = app_state.thread_pool.clone(); | ||
let job_store = app_state.job_store.clone(); | ||
let job_id = job_store.create_job().await; | ||
let thread = thread_pool.lock().await; | ||
let execution_params = ExecuteParams { | ||
job_id, | ||
job_store, | ||
dir, | ||
program_input: CairoVersionedInput::Pie(program_input.clone()), | ||
sse_tx: app_state.sse_tx.clone(), | ||
n_queries: program_input.clone().n_queries, | ||
pow_bits: program_input.pow_bits, | ||
}; | ||
thread.execute(execution_params).await.into_response(); | ||
|
||
let body = json!({ | ||
"job_id": job_id | ||
}); | ||
(StatusCode::ACCEPTED, body.to_string()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.