Skip to content

Commit 5770194

Browse files
committed
Update to most recent SDK version
1 parent 0ecbb1b commit 5770194

File tree

10 files changed

+172
-220
lines changed

10 files changed

+172
-220
lines changed

prover/Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prover/Cargo.toml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ edition = "2021"
77

88

99
[patch.crates-io]
10-
ethers-signers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
10+
ethers-signers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
1111
halo2curves = { git = "https://github.com/scroll-tech/halo2curves", branch = "v0.1.0" }
1212
[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
13-
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
13+
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
1414
[patch."https://github.com/privacy-scaling-explorations/poseidon.git"]
1515
poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "main" }
1616
[patch."https://github.com/privacy-scaling-explorations/bls12_381"]
@@ -28,10 +28,20 @@ futures = "0.3.30"
2828
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
2929
ethers-providers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
3030
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
31-
snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] }
32-
prover_darwin = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.12.2", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] }
33-
prover_darwin_v2 = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.13.1", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] }
34-
scroll-proving-sdk = { git = "https://github.com/scroll-tech/scroll-proving-sdk.git", rev = "7f8dca4"}
31+
snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = [
32+
"loader_halo2",
33+
"loader_evm",
34+
"halo2-pse",
35+
] }
36+
prover_darwin = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.12.2", package = "prover", default-features = false, features = [
37+
"parallel_syn",
38+
"scroll",
39+
] }
40+
prover_darwin_v2 = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.13.1", package = "prover", default-features = false, features = [
41+
"parallel_syn",
42+
"scroll",
43+
] }
44+
scroll-proving-sdk = { git = "https://github.com/scroll-tech/scroll-proving-sdk.git", rev = "aa1a9fa" }
3545
base64 = "0.13.1"
3646
reqwest = { version = "0.12.4", features = ["gzip"] }
3747
reqwest-middleware = "0.3"

prover/src/main.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44
mod config;
55
mod prover;
66
mod types;
7-
mod utils;
87
mod zk_circuits_handler;
98

109
use clap::{ArgAction, Parser};
11-
use prover::LocalProver;
10+
use prover::{LocalProver, LocalProverConfig};
1211
use scroll_proving_sdk::{
13-
config::Config,
1412
prover::ProverBuilder,
1513
utils::{get_version, init_tracing},
1614
};
17-
use utils::get_prover_type;
1815

1916
#[derive(Parser, Debug)]
2017
#[clap(disable_version_flag = true)]
@@ -43,23 +40,10 @@ async fn main() -> anyhow::Result<()> {
4340
std::process::exit(0);
4441
}
4542

46-
let cfg: Config = Config::from_file(args.config_file)?;
47-
let mut prover_types = vec![];
48-
cfg.prover.circuit_types.iter().for_each(|circuit_type| {
49-
if let Some(pt) = get_prover_type(*circuit_type) {
50-
if !prover_types.contains(&pt) {
51-
prover_types.push(pt);
52-
}
53-
}
54-
});
55-
let local_prover = LocalProver::new(
56-
cfg.prover
57-
.local
58-
.clone()
59-
.ok_or_else(|| anyhow::anyhow!("Missing local prover configuration"))?,
60-
prover_types,
61-
);
62-
let prover = ProverBuilder::new(cfg)
43+
let cfg = LocalProverConfig::from_file(args.config_file)?;
44+
let sdk_config = cfg.sdk_config.clone();
45+
let local_prover = LocalProver::new(cfg);
46+
let prover = ProverBuilder::new(sdk_config)
6347
.with_proving_service(Box::new(local_prover))
6448
.build()
6549
.await?;

prover/src/prover.rs

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
use crate::{
2-
types::ProverType,
3-
utils::get_prover_type,
4-
zk_circuits_handler::{CircuitsHandler, CircuitsHandlerProvider},
5-
};
6-
use anyhow::Result;
1+
use crate::zk_circuits_handler::{CircuitsHandler, CircuitsHandlerProvider};
2+
use anyhow::{anyhow, Result};
73
use async_trait::async_trait;
84
use scroll_proving_sdk::{
9-
config::LocalProverConfig,
5+
config::Config as SdkConfig,
106
prover::{
117
proving_service::{
128
GetVkRequest, GetVkResponse, ProveRequest, ProveResponse, QueryTaskRequest,
@@ -15,15 +11,44 @@ use scroll_proving_sdk::{
1511
ProvingService,
1612
},
1713
};
14+
use serde::{Deserialize, Serialize};
1815
use std::{
16+
fs::File,
1917
sync::{Arc, Mutex},
2018
time::{SystemTime, UNIX_EPOCH},
2119
};
2220
use tokio::{runtime::Handle, sync::RwLock, task::JoinHandle};
2321

22+
#[derive(Clone, Serialize, Deserialize)]
23+
pub struct LocalProverConfig {
24+
pub sdk_config: SdkConfig,
25+
pub high_version_circuit: CircuitConfig,
26+
pub low_version_circuit: CircuitConfig,
27+
}
28+
29+
impl LocalProverConfig {
30+
pub fn from_reader<R>(reader: R) -> Result<Self>
31+
where
32+
R: std::io::Read,
33+
{
34+
serde_json::from_reader(reader).map_err(|e| anyhow!(e))
35+
}
36+
37+
pub fn from_file(file_name: String) -> Result<Self> {
38+
let file = File::open(file_name)?;
39+
Self::from_reader(&file)
40+
}
41+
}
42+
43+
#[derive(Clone, Serialize, Deserialize)]
44+
pub struct CircuitConfig {
45+
pub hard_fork_name: String,
46+
pub params_path: String,
47+
pub assets_path: String,
48+
}
49+
2450
pub struct LocalProver {
2551
config: LocalProverConfig,
26-
prover_types: Vec<ProverType>,
2752
circuits_handler_provider: RwLock<CircuitsHandlerProvider>,
2853
next_task_id: Arc<Mutex<u64>>,
2954
current_task: Arc<Mutex<Option<JoinHandle<Result<String>>>>>,
@@ -35,20 +60,11 @@ impl ProvingService for LocalProver {
3560
true
3661
}
3762
async fn get_vks(&self, req: GetVkRequest) -> GetVkResponse {
38-
let mut prover_types = vec![];
39-
req.circuit_types.iter().for_each(|circuit_type| {
40-
if let Some(pt) = get_prover_type(*circuit_type) {
41-
if !prover_types.contains(&pt) {
42-
prover_types.push(pt);
43-
}
44-
}
45-
});
46-
4763
let vks = self
4864
.circuits_handler_provider
4965
.read()
5066
.await
51-
.init_vks(&self.config, prover_types)
67+
.init_vks(&self.config, req.proof_types)
5268
.await;
5369
GetVkResponse { vks, error: None }
5470
}
@@ -57,7 +73,7 @@ impl ProvingService for LocalProver {
5773
.circuits_handler_provider
5874
.write()
5975
.await
60-
.get_circuits_handler(&req.hard_fork_name, self.prover_types.clone())
76+
.get_circuits_handler(&req.hard_fork_name)
6177
.expect("failed to get circuit handler");
6278

6379
match self.do_prove(req, handler).await {
@@ -114,13 +130,12 @@ impl ProvingService for LocalProver {
114130
}
115131

116132
impl LocalProver {
117-
pub fn new(config: LocalProverConfig, prover_types: Vec<ProverType>) -> Self {
133+
pub fn new(config: LocalProverConfig) -> Self {
118134
let circuits_handler_provider = CircuitsHandlerProvider::new(config.clone())
119135
.expect("failed to create circuits handler provider");
120136

121137
Self {
122138
config,
123-
prover_types,
124139
circuits_handler_provider: RwLock::new(circuits_handler_provider),
125140
next_task_id: Arc::new(Mutex::new(0)),
126141
current_task: Arc::new(Mutex::new(None)),
@@ -150,7 +165,7 @@ impl LocalProver {
150165

151166
Ok(ProveResponse {
152167
task_id: task_id.to_string(),
153-
circuit_type: req.circuit_type,
168+
proof_type: req.proof_type,
154169
circuit_version: req.circuit_version,
155170
hard_fork_name: req.hard_fork_name,
156171
status: TaskStatus::Proving,

prover/src/types.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,6 @@ use scroll_proving_sdk::prover::types::CircuitType;
55

66
pub type CommonHash = H256;
77

8-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9-
pub enum ProverType {
10-
Chunk,
11-
Batch,
12-
}
13-
14-
impl ProverType {
15-
fn from_u8(v: u8) -> Self {
16-
match v {
17-
1 => ProverType::Chunk,
18-
2 => ProverType::Batch,
19-
_ => {
20-
panic!("invalid prover_type")
21-
}
22-
}
23-
}
24-
}
25-
26-
impl Serialize for ProverType {
27-
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
28-
where
29-
S: Serializer,
30-
{
31-
match *self {
32-
ProverType::Chunk => serializer.serialize_u8(1),
33-
ProverType::Batch => serializer.serialize_u8(2),
34-
}
35-
}
36-
}
37-
38-
impl<'de> Deserialize<'de> for ProverType {
39-
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
40-
where
41-
D: Deserializer<'de>,
42-
{
43-
let v: u8 = u8::deserialize(deserializer)?;
44-
Ok(ProverType::from_u8(v))
45-
}
46-
}
47-
488
#[derive(Serialize, Deserialize, Default)]
499
pub struct Task {
5010
#[serde(rename = "type", default)]

prover/src/utils.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)