-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlocal.rs
More file actions
89 lines (77 loc) · 2.12 KB
/
Copy pathlocal.rs
File metadata and controls
89 lines (77 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use async_trait::async_trait;
use clap::Parser;
use eyre::{Result, eyre};
use scroll_proving_sdk::{
config::Config as SdkConfig,
prover::{
ProverBuilder, ProvingService,
proving_service::{
GetVkRequest, GetVkResponse, ProveRequest, ProveResponse, QueryTaskRequest,
QueryTaskResponse,
},
},
utils::init_tracing,
};
use serde::{Deserialize, Serialize};
use std::fs::File;
#[derive(Parser, Debug)]
#[clap(disable_version_flag = true)]
struct Args {
/// Path of config file
#[arg(long = "config", default_value = "config.json")]
config_file: String,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LocalProverConfig {
pub sdk_config: SdkConfig,
pub conf1: String,
pub conf2: String,
}
impl LocalProverConfig {
pub fn from_reader<R>(reader: R) -> Result<Self>
where
R: std::io::Read,
{
serde_json::from_reader(reader).map_err(|e| eyre!(e))
}
pub fn from_file(file_name: String) -> Result<Self> {
let file = File::open(file_name)?;
Self::from_reader(&file)
}
pub fn from_file_and_env(file_name: String) -> Result<Self> {
let cfg = Self::from_file(file_name)?;
Ok(cfg)
}
}
struct LocalProver {}
#[async_trait]
impl ProvingService for LocalProver {
fn is_local(&self) -> bool {
true
}
async fn get_vks(&self, _req: GetVkRequest) -> GetVkResponse {
todo!()
}
async fn prove(&mut self, _req: ProveRequest) -> ProveResponse {
todo!()
}
async fn query_task(&mut self, _req: QueryTaskRequest) -> QueryTaskResponse {
todo!()
}
}
impl LocalProver {
pub fn new(_cfg: LocalProverConfig) -> Self {
Self {}
}
}
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
init_tracing();
let args = Args::parse();
let cfg = LocalProverConfig::from_file_and_env(args.config_file)?;
let sdk_config = cfg.sdk_config.clone();
let local_prover = LocalProver::new(cfg);
let prover = ProverBuilder::new(sdk_config, local_prover).build().await?;
prover.run().await;
Ok(())
}