Skip to content
Open
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,035 changes: 775 additions & 1,260 deletions Cargo.lock

Large diffs are not rendered by default.

48 changes: 28 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
[package]
name = "scroll-proving-sdk"
version = "0.1.0"
edition = "2021"
version = "0.2.0"
edition = "2024"

[[bin]]
name = "scroll-pover-db-tool"
path = "src/bin/pover_db_tool.rs"

[dependencies]
anyhow = "1.0"
log = "0.4"
eyre = "0.6"
color-eyre = "0.6"
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"] }
reqwest-middleware = "0.3"
reqwest-retry = "0.5"
hex = "0.4.3"
tiny-keccak = { version = "2.0.0", features = ["sha3", "keccak"] }
rand = "0.8.5"
rlp = "0.5.2"
tokio = { version = "1.37.0", features = ["full"] }
futures = "0.3"
reqwest = { version = "0.12", features = ["gzip", "json"] }
reqwest-middleware = "0.4"
reqwest-retry = "0.7"
hex = "0.4"
tiny-keccak = { version = "2.0", features = ["sha3", "keccak"] }
rand = "0.9"
alloy-rlp = { version = "0.3", features = ["derive"] }
tokio = { version = "1.48", features = ["net", "sync"] }
async-trait = "0.1"
http = "1.1.0"
http = "1.4"
clap = { version = "4.5", features = ["derive"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
axum = "0.6.0"
dotenv = "0.15"
rocksdb = "0.23.0"
url = "2.5.4"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
axum = { version = "0.8", default-features = false, features = ["tokio", "http1"] }
dotenvy = "0.15"
rocksdb = "0.24"
strum = { version = "0.27", features = ["derive"] }
serde_repr = "0.1"

# ref: https://docs.rs/color-eyre/0.6.5/color_eyre/#improving-perf-on-debug-builds
[profile.dev.package.backtrace]
opt-level = 3
20 changes: 20 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::env;

const DEFAULT_COMMIT: &str = "unknown";
const DEFAULT_ZK_VERSION: &str = "000000-000000";
const DEFAULT_TAG: &str = "v0.0.0";

fn main() {
println!(
"cargo:rustc-env=GIT_REV={}",
env::var("GIT_REV").unwrap_or_else(|_| DEFAULT_COMMIT.to_string()),
);
println!(
"cargo:rustc-env=GO_TAG={}",
env::var("GO_TAG").unwrap_or_else(|_| DEFAULT_TAG.to_string()),
);
println!(
"cargo:rustc-env=ZK_VERSION={}",
env::var("ZK_VERSION").unwrap_or_else(|_| DEFAULT_ZK_VERSION.to_string()),
);
}
3 changes: 2 additions & 1 deletion conf/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
2,
3
],
"circuit_version": "v0.13.1"
"circuit_version": "v0.13.1",
"suppress_empty_task_error": true
},
"db_path": "db"
}
19 changes: 10 additions & 9 deletions examples/cloud.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use anyhow::{anyhow, Result};
#![allow(dead_code)]
use async_trait::async_trait;
use clap::Parser;
use eyre::{Result, eyre};
use reqwest::Url;
use std::fs::File;

use scroll_proving_sdk::{
config::Config as SdkConfig,
prover::{
ProverBuilder, ProvingService,
proving_service::{
GetVkRequest, GetVkResponse, ProveRequest, ProveResponse, QueryTaskRequest,
QueryTaskResponse,
},
ProverBuilder, ProvingService,
},
utils::init_tracing,
};
Expand All @@ -37,7 +38,7 @@ impl CloudProverConfig {
where
R: std::io::Read,
{
serde_json::from_reader(reader).map_err(|e| anyhow!(e))
serde_json::from_reader(reader).map_err(|e| eyre!(e))
}

pub fn from_file(file_name: String) -> Result<Self> {
Expand All @@ -49,7 +50,7 @@ impl CloudProverConfig {
std::env::var_os(key)
.map(|val| {
val.to_str()
.ok_or_else(|| anyhow!("{key} env var is not valid UTF-8"))
.ok_or_else(|| eyre!("{key} env var is not valid UTF-8"))
.map(String::from)
})
.transpose()
Expand Down Expand Up @@ -80,13 +81,13 @@ impl ProvingService for CloudProver {
fn is_local(&self) -> bool {
false
}
async fn get_vks(&self, req: GetVkRequest) -> GetVkResponse {
async fn get_vks(&self, _req: GetVkRequest) -> GetVkResponse {
todo!()
}
async fn prove(&mut self, req: ProveRequest) -> ProveResponse {
async fn prove(&mut self, _req: ProveRequest) -> ProveResponse {
todo!()
}
async fn query_task(&mut self, req: QueryTaskRequest) -> QueryTaskResponse {
async fn query_task(&mut self, _req: QueryTaskRequest) -> QueryTaskResponse {
todo!()
}
}
Expand All @@ -101,8 +102,8 @@ impl CloudProver {
}
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
init_tracing();

let args = Args::parse();
Expand Down
18 changes: 9 additions & 9 deletions examples/local.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use anyhow::{anyhow, Result};
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,
},
ProverBuilder, ProvingService,
},
utils::init_tracing,
};
Expand All @@ -35,7 +35,7 @@ impl LocalProverConfig {
where
R: std::io::Read,
{
serde_json::from_reader(reader).map_err(|e| anyhow!(e))
serde_json::from_reader(reader).map_err(|e| eyre!(e))
}

pub fn from_file(file_name: String) -> Result<Self> {
Expand All @@ -56,25 +56,25 @@ impl ProvingService for LocalProver {
fn is_local(&self) -> bool {
true
}
async fn get_vks(&self, req: GetVkRequest) -> GetVkResponse {
async fn get_vks(&self, _req: GetVkRequest) -> GetVkResponse {
todo!()
}
async fn prove(&mut self, req: ProveRequest) -> ProveResponse {
async fn prove(&mut self, _req: ProveRequest) -> ProveResponse {
todo!()
}
async fn query_task(&mut self, req: QueryTaskRequest) -> QueryTaskResponse {
async fn query_task(&mut self, _req: QueryTaskRequest) -> QueryTaskResponse {
todo!()
}
}

impl LocalProver {
pub fn new(cfg: LocalProverConfig) -> Self {
pub fn new(_cfg: LocalProverConfig) -> Self {
Self {}
}
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
init_tracing();

let args = Args::parse();
Expand Down
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-2025-02-14"
channel = "nightly-2025-08-18"
81 changes: 81 additions & 0 deletions src/bin/pover_db_tool.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
use clap::{Parser, Subcommand};
use eyre::WrapErr;
use scroll_proving_sdk::db::{Db, PROVING_TASK_ID_KEY_PREFIX};
use scroll_proving_sdk::utils::init_color_eyre_hook;
use std::collections::HashMap;
use std::path::PathBuf;

/// Tool to interact with the prover database.
#[derive(Parser)]
struct Cli {
/// Path to the database
#[clap(long, default_value = ".work/db")]
db: PathBuf,

#[command(subcommand)]
commands: Commands,
}

#[derive(Subcommand)]
enum Commands {
/// List all coordinator and prover task ID pairs
List,
/// Get the corresponding task ID
Get {
#[command(subcommand)]
commands: GetCommands,
},
}

#[derive(Subcommand)]
enum GetCommands {
/// Get coordinator task ID by prover task ID
Coordinator { task_id: String },
/// Get prover task ID by coordinator task ID
Prover { task_id: String },
}

fn main() -> eyre::Result<()> {
init_color_eyre_hook();

let cli = Cli::parse();
let db = Db::new(&cli.db).context("open database")?;

let mut c2p = HashMap::new();
let mut p2c = HashMap::new();

for result in db.inner().prefix_iterator(PROVING_TASK_ID_KEY_PREFIX) {
let (proving_task_key_bytes, _) = result.context("iter entry")?;
let public_key =
std::str::from_utf8(&proving_task_key_bytes[PROVING_TASK_ID_KEY_PREFIX.len()..])?;

let Some((coordinator_task, prover_task_id)) = db.get_task(public_key) else {
continue;
};

c2p.insert(coordinator_task.task_id.clone(), prover_task_id.clone());
p2c.insert(prover_task_id, coordinator_task.task_id);
}

match cli.commands {
Commands::List => {
for (c_task_id, p_task_id) in c2p.iter() {
println!("{}\t{}", c_task_id, p_task_id);
}
}
Commands::Get { commands } => match commands {
GetCommands::Coordinator { task_id } => {
if let Some(coordinator_task_id) = p2c.get(&task_id) {
println!("{coordinator_task_id}");
}
}
GetCommands::Prover { task_id } => {
if let Some(prover_task_id) = c2p.get(&task_id) {
println!("{prover_task_id}");
}
}
},
}

Ok(())
}
Loading
Loading