Skip to content

Commit

Permalink
feat: Add initial support for rust runtime (#140)
Browse files Browse the repository at this point in the history
* add zkvm runtime

* remove unused mod

* fix mips disas problem

* add benchmark test(tofix)

* fix input and fmt

* add trace support for hint ops

* fix input ptr in segment files

* fix hint read syscall and rebase

* add port header and update sha2 bench test

* add missed files

* fix clippy

* remove unused commit func

* update readme
  • Loading branch information
weilzkm authored Jul 5, 2024
1 parent b0a8989 commit f79ca33
Show file tree
Hide file tree
Showing 27 changed files with 2,426 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ edition = "2021"
#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" }
Expand Down
32 changes: 32 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,36 @@ BASEDIR=test-vectors RUST_LOG=info BLOCK_NO=13284491 SEG_FILE_DIR="/tmp/output"
cargo run --release --example zkmips aggregate_proof_all
```

- run bench

- download/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"]
```

- build sha2

```
cd examples/sha2
cargo build --target=mips-unknown-linux-musl
cd ../../
```

- run bench

```
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
```

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.

350 changes: 350 additions & 0 deletions examples/sha2/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f79ca33

Please sign in to comment.