Skip to content

Commit 421afe9

Browse files
committed
deprecate halo2 provers, start openvm prover
1 parent ca8d930 commit 421afe9

File tree

13 files changed

+111
-1393
lines changed

13 files changed

+111
-1393
lines changed

coordinator/internal/types/prover.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const (
2727
ProverTypeChunk
2828
// ProverTypeBatch signals it's a batch prover, which can prove batch_tasks and bundle_tasks
2929
ProverTypeBatch
30+
// ProverTypeOpenVM signals it's an openvm prover
31+
ProverTypeOpenVM
3032
)
3133

3234
// MakeProverType make ProverType from ProofType

prover/src/config.rs

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
use anyhow::{bail, Result};
1+
use anyhow::Result;
22
use serde::{Deserialize, Serialize};
3-
use std::fs::File;
3+
use std::{collections::HashMap, fs::File};
44

55
use crate::types::ProverType;
66

7-
#[derive(Debug, Serialize, Deserialize)]
7+
#[derive(Debug, Serialize, Deserialize, Clone)]
88
pub struct CircuitConfig {
99
pub hard_fork_name: String,
10-
pub params_path: String,
11-
pub assets_path: String,
10+
pub workspace_path: String,
1211
}
1312

14-
#[derive(Debug, Serialize, Deserialize)]
13+
#[derive(Debug, Serialize, Deserialize, Clone)]
1514
pub struct CoordinatorConfig {
1615
pub base_url: String,
1716
pub retry_count: u32,
1817
pub retry_wait_time_sec: u64,
1918
pub connection_timeout_sec: u64,
2019
}
2120

22-
#[derive(Debug, Serialize, Deserialize)]
21+
#[derive(Debug, Serialize, Deserialize, Clone)]
2322
pub struct L2GethConfig {
2423
pub endpoint: String,
2524
}
2625

27-
#[derive(Debug, Deserialize)]
26+
#[derive(Debug, Deserialize, Clone)]
2827
pub struct Config {
2928
pub prover_name: String,
3029
pub keystore_path: String,
3130
pub keystore_password: String,
3231
pub db_path: String,
3332
pub prover_type: ProverType,
34-
pub low_version_circuit: CircuitConfig,
35-
pub high_version_circuit: CircuitConfig,
33+
pub circuits: HashMap<String, CircuitConfig>,
3634
pub coordinator: CoordinatorConfig,
3735
pub l2geth: Option<L2GethConfig>,
3836
}
@@ -50,53 +48,3 @@ impl Config {
5048
Config::from_reader(&file)
5149
}
5250
}
53-
54-
static SCROLL_PROVER_ASSETS_DIR_ENV_NAME: &str = "SCROLL_PROVER_ASSETS_DIR";
55-
static mut SCROLL_PROVER_ASSETS_DIRS: Vec<String> = vec![];
56-
57-
#[derive(Debug)]
58-
pub struct AssetsDirEnvConfig {}
59-
60-
impl AssetsDirEnvConfig {
61-
pub fn init() -> Result<()> {
62-
let value = std::env::var(SCROLL_PROVER_ASSETS_DIR_ENV_NAME)?;
63-
let dirs: Vec<&str> = value.split(',').collect();
64-
if dirs.len() != 2 {
65-
bail!("env variable SCROLL_PROVER_ASSETS_DIR value must be 2 parts seperated by comma.")
66-
}
67-
unsafe {
68-
SCROLL_PROVER_ASSETS_DIRS = dirs.into_iter().map(|s| s.to_string()).collect();
69-
log::info!(
70-
"init SCROLL_PROVER_ASSETS_DIRS: {:?}",
71-
SCROLL_PROVER_ASSETS_DIRS
72-
);
73-
}
74-
Ok(())
75-
}
76-
77-
pub fn enable_first() {
78-
unsafe {
79-
log::info!(
80-
"set env {SCROLL_PROVER_ASSETS_DIR_ENV_NAME} to {}",
81-
&SCROLL_PROVER_ASSETS_DIRS[0]
82-
);
83-
std::env::set_var(
84-
SCROLL_PROVER_ASSETS_DIR_ENV_NAME,
85-
&SCROLL_PROVER_ASSETS_DIRS[0],
86-
);
87-
}
88-
}
89-
90-
pub fn enable_second() {
91-
unsafe {
92-
log::info!(
93-
"set env {SCROLL_PROVER_ASSETS_DIR_ENV_NAME} to {}",
94-
&SCROLL_PROVER_ASSETS_DIRS[1]
95-
);
96-
std::env::set_var(
97-
SCROLL_PROVER_ASSETS_DIR_ENV_NAME,
98-
&SCROLL_PROVER_ASSETS_DIRS[1],
99-
);
100-
}
101-
}
102-
}

prover/src/coordinator_client.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub mod listener;
44
pub mod types;
55

66
use anyhow::{bail, Context, Ok, Result};
7-
use std::rc::Rc;
87

98
use api::Api;
109
use errors::*;
@@ -16,20 +15,20 @@ use crate::{config::Config, key_signer::KeySigner};
1615

1716
pub use errors::ProofStatusNotOKError;
1817

19-
pub struct CoordinatorClient<'a> {
18+
pub struct CoordinatorClient {
2019
api: Api,
2120
token: Option<String>,
22-
config: &'a Config,
23-
key_signer: Rc<KeySigner>,
21+
config: Config,
22+
key_signer: KeySigner,
2423
rt: Runtime,
2524
listener: Box<dyn Listener>,
2625
vks: Vec<String>,
2726
}
2827

29-
impl<'a> CoordinatorClient<'a> {
28+
impl CoordinatorClient {
3029
pub fn new(
31-
config: &'a Config,
32-
key_signer: Rc<KeySigner>,
30+
config: Config,
31+
key_signer: KeySigner,
3332
listener: Box<dyn Listener>,
3433
vks: Vec<String>,
3534
) -> Result<Self> {

prover/src/geth_client.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
use crate::types::CommonHash;
21
use anyhow::Result;
32
use ethers_core::types::BlockNumber;
43
use tokio::runtime::Runtime;
54

6-
use serde::{de::DeserializeOwned, Serialize};
7-
use std::fmt::Debug;
8-
95
use ethers_providers::{Http, Provider};
106

117
pub struct GethClient {
@@ -28,24 +24,6 @@ impl GethClient {
2824
})
2925
}
3026

31-
pub fn get_block_trace_by_hash<T>(&mut self, hash: &CommonHash) -> Result<T>
32-
where
33-
T: Serialize + DeserializeOwned + Debug + Send,
34-
{
35-
log::info!(
36-
"{}: calling get_block_trace_by_hash, hash: {:#?}",
37-
self.id,
38-
hash
39-
);
40-
41-
let trace_future = self
42-
.provider
43-
.request("scroll_getBlockTraceByNumberOrHash", [format!("{hash:#x}")]);
44-
45-
let trace = self.rt.block_on(trace_future)?;
46-
Ok(trace)
47-
}
48-
4927
pub fn block_number(&mut self) -> Result<BlockNumber> {
5028
log::info!("{}: calling block_number", self.id);
5129

prover/src/main.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod zk_circuits_handler;
1515

1616
use anyhow::Result;
1717
use clap::{ArgAction, Parser};
18-
use config::{AssetsDirEnvConfig, Config};
18+
use config::Config;
1919
use prover::Prover;
2020
use std::rc::Rc;
2121
use task_cache::{ClearCacheCoordinatorListener, TaskCache};
@@ -49,29 +49,23 @@ fn start() -> Result<()> {
4949
utils::log_init(args.log_file);
5050

5151
let config: Config = Config::from_file(args.config_file)?;
52-
53-
if let Err(e) = AssetsDirEnvConfig::init() {
54-
log::error!("AssetsDirEnvConfig init failed: {:#}", e);
55-
std::process::exit(-2);
56-
}
57-
5852
let task_cache = Rc::new(TaskCache::new(&config.db_path)?);
5953

6054
let coordinator_listener = Box::new(ClearCacheCoordinatorListener {
6155
task_cache: task_cache.clone(),
6256
});
6357

64-
let prover = Prover::new(&config, coordinator_listener)?;
58+
let prover = Prover::new(config.clone(), coordinator_listener)?;
6559

6660
log::info!(
67-
"prover start successfully. name: {}, type: {:?}, publickey: {}, version: {}",
61+
"starting prover. name: {}, type: {:?}, publickey: {}, version: {}",
6862
config.prover_name,
6963
config.prover_type,
70-
prover.get_public_key(),
64+
prover.public_key,
7165
version::get_version(),
7266
);
7367

74-
let task_processor = TaskProcessor::new(&prover, task_cache);
68+
let task_processor = TaskProcessor::new(prover, task_cache);
7569

7670
task_processor.start();
7771

0 commit comments

Comments
 (0)