Skip to content

Commit

Permalink
feat: add GetVkResponse (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmountaintop authored Sep 27, 2024
1 parent 4322c71 commit f958c9c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
10 changes: 5 additions & 5 deletions examples/cloud.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use clap::Parser;
use std::sync::Arc;

use scroll_proving_sdk::{
config::{CloudProverConfig, Config},
prover::{
proving_service::{
GetVkRequest, ProveRequest, ProveResponse, QueryTaskRequest, QueryTaskResponse,
GetVkRequest, GetVkResponse, ProveRequest, ProveResponse, QueryTaskRequest,
QueryTaskResponse,
},
ProverBuilder, ProvingService,
},
Expand All @@ -21,15 +21,15 @@ struct Args {
}

struct CloudProver {
endpoint: String,
base_url: String,
api_key: String,
}

impl ProvingService for CloudProver {
fn is_local(&self) -> bool {
false
}
fn get_vk(&self, req: GetVkRequest) -> String {
fn get_vk(&self, req: GetVkRequest) -> GetVkResponse {
todo!()
}
fn prove(&self, req: ProveRequest) -> ProveResponse {
Expand All @@ -43,7 +43,7 @@ impl ProvingService for CloudProver {
impl CloudProver {
pub fn new(cfg: CloudProverConfig) -> Self {
Self {
endpoint: cfg.endpoint,
base_url: cfg.base_url,
api_key: cfg.api_key,
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/local.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use clap::Parser;
use std::sync::Arc;

use scroll_proving_sdk::{
config::{Config, LocalProverConfig},
prover::{
proving_service::{
GetVkRequest, ProveRequest, ProveResponse, QueryTaskRequest, QueryTaskResponse,
GetVkRequest, GetVkResponse, ProveRequest, ProveResponse, QueryTaskRequest,
QueryTaskResponse,
},
ProverBuilder, ProvingService,
},
Expand All @@ -26,7 +26,7 @@ impl ProvingService for LocalProver {
fn is_local(&self) -> bool {
true
}
fn get_vk(&self, req: GetVkRequest) -> String {
fn get_vk(&self, req: GetVkRequest) -> GetVkResponse {
todo!()
}
fn prove(&self, req: ProveRequest) -> ProveResponse {
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct ProverConfig {

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CloudProverConfig {
pub endpoint: String,
pub base_url: String,
pub api_key: String,
}

Expand Down
7 changes: 5 additions & 2 deletions src/prover/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ impl ProverBuilder {
circuit_type: self.cfg.prover.circuit_type,
circuit_version: self.cfg.prover.circuit_version.clone(),
};
let vk = self
let get_vk_response = self
.proving_service
.as_ref()
.unwrap()
.get_vk(get_vk_request);
if let Some(error) = get_vk_response.error {
anyhow::bail!("failed to get vk: {}", error);
}

let key_signers: Result<Vec<_>, _> = (0..self.cfg.prover.n_workers)
.map(|i| {
Expand All @@ -66,7 +69,7 @@ impl ProverBuilder {
CoordinatorClient::new(
self.cfg.coordinator.clone(),
self.cfg.prover.circuit_type,
vec![vk.clone()],
vec![get_vk_response.vk.clone()],
self.cfg.prover.circuit_version.clone(),
format!("{}{}", self.cfg.prover_name_prefix, i),
key_signers[i].clone(),
Expand Down
11 changes: 8 additions & 3 deletions src/prover/proving_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ use super::CircuitType;

pub trait ProvingService {
fn is_local(&self) -> bool;
fn get_vk(&self, req: GetVkRequest) -> String; // TODO: Result<String, Error>
fn prove(&self, req: ProveRequest) -> ProveResponse; // TODO: Result<ProveResponse, Error>
fn query_task(&self, req: QueryTaskRequest) -> QueryTaskResponse; // TODO: Result<QueryTaskResponse, Error>
fn get_vk(&self, req: GetVkRequest) -> GetVkResponse;
fn prove(&self, req: ProveRequest) -> ProveResponse;
fn query_task(&self, req: QueryTaskRequest) -> QueryTaskResponse;
}

pub struct GetVkRequest {
pub circuit_type: CircuitType,
pub circuit_version: String,
}

pub struct GetVkResponse {
pub vk: String,
pub error: Option<String>,
}

pub struct ProveRequest {
pub circuit_type: CircuitType,
pub circuit_version: String,
Expand Down

0 comments on commit f958c9c

Please sign in to comment.