Skip to content

For refactoring scroll monorepo #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,442 changes: 59 additions & 2,383 deletions Cargo.lock

Large diffs are not rendered by default.

28 changes: 2 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ version = "0.1.0"
edition = "2021"

[dependencies]
alloy = { version = "0.11", features = [
"provider-http",
"transport-http",
"reqwest",
"reqwest-rustls-tls",
"json-rpc",
] }
anyhow = "1.0"
log = "0.4"
serde = { version = "1.0.198", features = ["derive"] }
serde_json = "1.0.116"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
ethers-providers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
reqwest = { version = "0.12.4", features = ["gzip"] }
Expand All @@ -33,22 +26,5 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
axum = "0.6.0"
dotenv = "0.15"
rocksdb = "0.23.0"
sbv-utils = { git = "https://github.com/scroll-tech/stateless-block-verifier", branch = "zkvm/euclid-upgrade", features = [
"scroll",
], optional = true }
sbv-primitives = { git = "https://github.com/scroll-tech/stateless-block-verifier", branch = "zkvm/euclid-upgrade", features = [
"scroll",
], optional = true }
url = "2.5.4"

[features]
openvm = ["dep:sbv-utils", "dep:sbv-primitives"]

[patch.crates-io]
# patched add rkyv support & MSRV 1.77
alloy-primitives = { git = "https://github.com/scroll-tech/alloy-core", branch = "v0.8.21" }
#revm = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v55" }
#revm-interpreter = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v55" }
#revm-precompile = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v55" }
#revm-primitives = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v55" }
ruint = { git = "https://github.com/scroll-tech/uint.git", branch = "v1.12.3" }
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly-2024-12-06"
channel = "nightly-2025-02-14"
41 changes: 2 additions & 39 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::{
coordinator_handler::ProverType,
prover::{CircuitType, ProofType},
};
use crate::{coordinator_handler::ProverType, prover::ProofType};
use anyhow::{anyhow, Result};
use dotenv::dotenv;
use serde::{Deserialize, Serialize};
Expand All @@ -14,7 +11,6 @@ pub struct Config {
pub keys_dir: String,
pub db_path: Option<String>,
pub coordinator: CoordinatorConfig,
pub l2geth: Option<L2GethConfig>,
pub prover: ProverConfig,
#[serde(default = "default_health_listener_addr")]
pub health_listener_addr: String,
Expand All @@ -28,14 +24,8 @@ pub struct CoordinatorConfig {
pub connection_timeout_sec: u64,
}

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

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ProverConfig {
pub circuit_type: CircuitType,
pub supported_proof_types: Vec<ProofType>,
pub circuit_version: String,
#[serde(default = "default_n_workers")]
Expand Down Expand Up @@ -93,11 +83,6 @@ impl Config {
if let Some(val) = Self::get_env_var("COORDINATOR_BASE_URL")? {
self.coordinator.base_url = val;
}
if let Some(val) = Self::get_env_var("L2GETH_ENDPOINT")? {
if let Some(l2geth) = &mut self.l2geth {
l2geth.endpoint = val;
}
}

if let Some(val) = Self::get_env_var("PROOF_TYPES")? {
let values_vec: Vec<&str> = val
Expand Down Expand Up @@ -129,28 +114,6 @@ impl Config {
}

pub fn coordinator_prover_type(&self) -> Vec<ProverType> {
if self.prover.circuit_type == CircuitType::OpenVM {
vec![ProverType::OpenVM]
} else {
let mut prover_types = vec![];
if self
.prover
.supported_proof_types
.iter()
.any(|t| *t == ProofType::Bundle || *t == ProofType::Batch)
{
prover_types.push(ProverType::Batch)
}

if self
.prover
.supported_proof_types
.contains(&ProofType::Chunk)
{
prover_types.push(ProverType::Chunk)
}

prover_types
}
vec![ProverType::OpenVM]
}
}
12 changes: 1 addition & 11 deletions src/coordinator_handler/types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use super::error::ErrorCode;
use crate::{
prover::{ProofType, ProverProviderType},
tracing_handler::CommonHash,
};
use crate::prover::{ProofType, ProverProviderType};
use rlp::{Encodable, RlpStream};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

Expand Down Expand Up @@ -123,13 +120,6 @@ pub struct GetTaskResponseData {
pub hard_fork_name: String,
}

#[derive(Debug, Clone, Deserialize)]
pub struct ChunkTaskDetail {
pub block_hashes: Vec<CommonHash>,
pub prev_msg_queue_hash: CommonHash,
pub fork_name: String,
}

#[derive(Serialize, Deserialize)] // TODO: Default?
pub struct SubmitProofRequest {
pub uuid: String,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ pub mod config;
pub mod coordinator_handler;
pub mod db;
pub mod prover;
pub mod tracing_handler;
//pub mod tracing_handler;
pub mod utils;
20 changes: 1 addition & 19 deletions src/prover/builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tokio::sync::RwLock;

use super::{ProofType, ProverProviderType};
use super::ProverProviderType;
use crate::{
config::Config,
coordinator_handler::{CoordinatorClient, KeySigner},
Expand All @@ -9,7 +9,6 @@ use crate::{
proving_service::{GetVkRequest, ProvingService},
Prover,
},
tracing_handler::L2gethClient,
utils::format_cloud_prover_name,
};
use std::path::PathBuf;
Expand All @@ -35,16 +34,6 @@ where
anyhow::bail!("cannot use multiple workers with local proving service");
}

if self
.cfg
.prover
.supported_proof_types
.contains(&ProofType::Chunk)
&& self.cfg.l2geth.is_none()
{
anyhow::bail!("circuit_type is chunk but l2geth config is not provided");
}

let get_vk_request = GetVkRequest {
proof_types: self.cfg.prover.supported_proof_types.clone(),
circuit_version: self.cfg.prover.circuit_version.clone(),
Expand Down Expand Up @@ -98,21 +87,14 @@ where
.collect();
let coordinator_clients = coordinator_clients?;

let l2geth_client = match self.cfg.l2geth {
Some(l2geth) => Some(L2gethClient::new(l2geth)?),
None => None,
};

let db_path = self.cfg.db_path.unwrap_or_else(|| {
panic!("Missing database path");
});

Ok(Prover {
circuit_type: self.cfg.prover.circuit_type,
proof_types: self.cfg.prover.supported_proof_types,
circuit_version: self.cfg.prover.circuit_version,
coordinator_clients,
l2geth_client,
proving_service: RwLock::new(self.proving_service),
n_workers: self.cfg.prover.n_workers,
health_listener_addr: self.cfg.health_listener_addr,
Expand Down
Loading
Loading