Skip to content
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

feat: use workspace #141

Merged
merged 2 commits into from
Jul 6, 2024
Merged
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 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
strategy:
matrix:
toolchain:
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v2
Expand Down
57 changes: 6 additions & 51 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,51 +1,6 @@
[package]
name = "zkm"
version = "0.1.0"
edition = "2021"

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

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

bincode = "1.3.3"

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" }

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"
keccak-hash = "0.10.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 }

sysinfo = "0.30.7"

[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" }
curta = { git ="https://github.com/zkMIPS/curta.git", branch = "zkm" }

[features]
test = []
[workspace]
members = [
"runtime/*",
"prover",
]
resolver = "2"
45 changes: 0 additions & 45 deletions READMEsv.md

This file was deleted.

49 changes: 23 additions & 26 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Examples

## MIPS tools
## Prove the Golang code

* Compile the Go code to MIPS

Expand Down Expand Up @@ -38,36 +38,33 @@ BASEDIR=test-vectors RUST_LOG=info BLOCK_NO=13284491 SEG_FILE_DIR="/tmp/output"
cargo run --release --example zkmips aggregate_proof_all
```

- run bench
## Prove the Rust code

- download/install toolchain for mips
* Download and install toolchain for mips

```
wget http://musl.cc/mips-linux-muslsf-cross.tgz
tar -zxvf mips-linux-muslsf-cross.tgz
```

- modify ~/.cargo/config:

```
[target.mips-unknown-linux-musl]
linker = <path-to>/mips-linux-muslsf-gcc"
rustflags = ["--cfg", 'target_os="zkvm"',"-C", "target-feature=+crt-static", "-C", "link-arg=-g"]
```
```
wget http://musl.cc/mips-linux-muslsf-cross.tgz
tar -zxvf mips-linux-muslsf-cross.tgz
```

- build sha2
* Modify ~/.cargo/config:

```
cd examples/sha2
cargo build --target=mips-unknown-linux-musl
cd ../../
```
```
[target.mips-unknown-linux-musl]
linker = <path-to>/mips-linux-muslsf-gcc"
rustflags = ["--cfg", 'target_os="zkvm"',"-C", "target-feature=+crt-static", "-C", "link-arg=-g"]
```

- run bench
* Build the Sha2

```
RUST_LOG=info ELF_PATH=examples/sha2/target/mips-unknown-linux-musl/debug/sha2-bench SEG_OUTPUT=/tmp/output cargo run --release --example zkmips bench
```
```
cd examples/sha2
cargo build --target=mips-unknown-linux-musl
cd ../../
```

Basically, you can run the example on a 32G RAM machine, if you get OOM error, please read https://github.com/zkMIPS/zkm/issues/97.
* Run the host program

```
RUST_LOG=info ELF_PATH=examples/sha2/target/mips-unknown-linux-musl/debug/sha2-bench SEG_OUTPUT=/tmp/output cargo run --release --example zkmips bench
```
51 changes: 51 additions & 0 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[package]
name = "zkm-prover"
version = "0.1.0"
edition = "2021"

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

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

bincode = "1.3.3"

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" }

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"
keccak-hash = "0.10.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 }

sysinfo = "0.30.7"

[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" }
curta = { git ="https://github.com/zkMIPS/curta.git", branch = "zkm" }

[features]
test = []
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/cpu/kernel/elf.rs → prover/src/cpu/kernel/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,14 @@ mod test {
#[test]
fn load_and_check_mips_elf() {
env_logger::try_init().unwrap_or_default();
let mut reader = BufReader::new(File::open("test-vectors/hello").unwrap());
let mut reader = BufReader::new(File::open("../test-vectors/hello").unwrap());
let mut buffer = Vec::new();
reader.read_to_end(&mut buffer).unwrap();
let max_mem = 0x80000000;
let mut p: Program = Program::load_elf(&buffer, max_mem).unwrap();
log::info!("entry: {}", p.entry);

let real_blockpath = get_block_path("test-vectors", "13284491", "input");
let real_blockpath = get_block_path("../test-vectors", "13284491", "input");
log::info!("real block path: {}", real_blockpath);
p.load_block(&real_blockpath).unwrap();

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/mips_emulator/tests.rs → prover/src/mips_emulator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ mod tests {

#[test]
fn test_execute_hello() {
let path = PathBuf::from("./test-vectors/hello");
let path = PathBuf::from("../test-vectors/hello");
let data = fs::read(path).expect("could not read file");
let file =
ElfBytes::<AnyEndian>::minimal_parse(data.as_slice()).expect("opening elf file failed");
Expand All @@ -75,7 +75,7 @@ mod tests {

#[test]
fn test_execute_rust_fib() {
let path = PathBuf::from("./test-vectors/rust_fib");
let path = PathBuf::from("../test-vectors/rust_fib");
let data = fs::read(path).expect("could not read file");
let file =
ElfBytes::<AnyEndian>::minimal_parse(data.as_slice()).expect("opening elf file failed");
Expand All @@ -96,7 +96,7 @@ mod tests {
#[test]
#[ignore]
fn test_execute_minigeth() {
let path = PathBuf::from("./test-vectors/minigeth");
let path = PathBuf::from("../test-vectors/minigeth");
let data = fs::read(path).expect("could not read file");
let file =
ElfBytes::<AnyEndian>::minimal_parse(data.as_slice()).expect("opening elf file failed");
Expand All @@ -105,7 +105,7 @@ mod tests {
state.patch_elf(&file);
state.patch_stack(vec![]);

let block_path = get_block_path("./test-vectors", "13284491", "");
let block_path = get_block_path("../test-vectors", "13284491", "");
state.load_input(&block_path);

let mut instrumented_state = InstrumentedState::new(state, block_path);
Expand All @@ -131,7 +131,7 @@ mod tests {

#[test]
fn test_execute_split_hello() {
let path = PathBuf::from("./test-vectors/hello");
let path = PathBuf::from("../test-vectors/hello");
let data = fs::read(path).expect("could not read file");
let file =
ElfBytes::<AnyEndian>::minimal_parse(data.as_slice()).expect("opening elf file failed");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion runtime/entrypoint/src/libm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Ported from Entrypoint for SP1 zkVM.
//!
//!
#[no_mangle]
pub extern "C" fn acos(x: f64) -> f64 {
libm::acos(x)
Expand Down
3 changes: 2 additions & 1 deletion runtime/precompiles/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{syscall_hint_len, syscall_hint_read};
use serde::de::DeserializeOwned;
use std::alloc::Layout;

#[allow(dead_code)]
pub struct SyscallWriter {
fd: u32,
}
Expand Down Expand Up @@ -52,4 +53,4 @@ pub fn read_vec() -> Vec<u8> {
pub fn read<T: DeserializeOwned>() -> T {
let vec = read_vec();
bincode::deserialize(&vec).expect("deserialization failed")
}
}
Loading