Skip to content

Commit

Permalink
sdk(network prover)
Browse files Browse the repository at this point in the history
  • Loading branch information
xander42280 committed Sep 4, 2024
1 parent 2a4bea0 commit 15b2097
Show file tree
Hide file tree
Showing 11 changed files with 810 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [

"host-program"
"host-program",
"sdk"
]
resolver = "2"
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly-2024-07-20"
64 changes: 64 additions & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[package]
name = "zkm-sdk"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
##zkm-emulator = { path = "../emulator" }
#plonky2 = { path = "../plonky2/plonky2" }
##starky = { path = "../plonky2/starky" }
#plonky2_util = { path = "../plonky2/util" }
#plonky2_maybe_rayon = { path = "../plonky2/maybe_rayon" }

bincode = "1.3.3"

async-trait = "0.1"

stage-service = {package = "service", git = "https://github.com/zkMIPS/zkm-prover", branch = "main", default-features = false }
zkm-prover = { git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }
zkm-emulator = { git = "https://github.com/zkMIPS/zkm", branch = "main", default-features = false }
common = { git = "https://github.com/zkMIPS/zkm-prover", branch = "main", default-features = false }
plonky2 = { git = "https://github.com/zkMIPS/plonky2.git", branch = "zkm_dev" }
#starky = { git = "https://github.com/zkMIPS/plonky2.git", branch = "zkm_dev" }
plonky2_util = { git = "https://github.com/zkMIPS/plonky2.git", branch = "zkm_dev" }
plonky2_maybe_rayon = { git = "https://github.com/zkMIPS/plonky2.git", branch = "zkm_dev" }

tonic = "0.8.1"
prost = "0.11.0"
tokio = { version = "1.21.0", features = ["macros", "rt-multi-thread", "signal"] }
ethers = "2.0.14"

itertools = "0.11.0"
log = { version = "0.4.14", default-features = false }
anyhow = "1.0.75"
num = "0.4.0"
num-bigint = "0.4.3"
serde = { version = "1.0.144", features = ["derive"] }
serde_json = "1.0"
tiny-keccak = "2.0.2"
rand = "0.8.5"
rand_chacha = "0.3.1"
once_cell = "1.13.0"
static_assertions = "1.1.0"
byteorder = "1.5.0"
hex = "0.4"
hashbrown = { version = "0.14.0", default-features = false, features = ["ahash", "serde"] } # NOTE: When upgrading, see `ahash` dependency.
lazy_static = "1.4.0"

elf = { version = "0.7", default-features = false }
uuid = { version = "1.2", features = ["v4", "fast-rng", "macro-diagnostics"] }

##[dev-dependencies]
env_logger = "0.10.0"
keccak-hash = "0.10.0"
plonky2x = { git = "https://github.com/zkMIPS/succinctx.git", package = "plonky2x", branch = "zkm" }
plonky2x-derive = { git = "https://github.com/zkMIPS/succinctx.git", package = "plonky2x-derive", branch = "zkm" }

[build-dependencies]
tonic-build = "0.8.0"

[features]
test = []

4 changes: 4 additions & 0 deletions sdk/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::compile_protos("src/proto/stage.proto")?;
Ok(())
}
43 changes: 43 additions & 0 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

pub mod prover;
pub mod local;
pub mod network;

use std::env;
use prover::Prover;
use network::prover::NetworkProver;

pub struct ProverClient {
pub prover: Box<dyn Prover>,
}

impl ProverClient {
pub fn new() -> Self {
#[allow(unreachable_code)]
match env::var("ZKM_PROVER").unwrap_or("network".to_string()).to_lowercase().as_str() {
// "local" => Self {
// prover: Box::new(CpuProver::new()),
// },
"network" => Self {
prover: Box::new(NetworkProver::default()),
},
_ => panic!(
"invalid value for ZKM_PROVER enviroment variable: expected 'local', or 'network'"
),
}
}

// pub fn local() -> Self {
// Self { prover: Box::new(CpuProver::new()) }
// }

pub fn network() -> Self {
Self { prover: Box::new(NetworkProver::default()) }
}
}

impl Default for ProverClient {
fn default() -> Self {
Self::new()
}
}
Loading

0 comments on commit 15b2097

Please sign in to comment.