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:add initial support for precompile #185

Merged
merged 12 commits into from
Nov 30, 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
4 changes: 4 additions & 0 deletions emulator/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,10 @@ impl InstrumentedState {
log::trace!("set local user {:X} {:X} {:X}", a0, a1, a2);
self.state.local_user = a0;
}
0xF2 => {
log::trace!("sys_verify {:X} {:X} {:X}", a0, a1, a2);
// DO Nothing Here
}
_ => {}
}

Expand Down
2 changes: 1 addition & 1 deletion emulator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn split_prog_into_segs(
break;
}
let cycles = instrumented_state.step();
if cycles >= seg_size as u64 {
if cycles > (seg_size - 1) as u64 {
eigmax marked this conversation as resolved.
Show resolved Hide resolved
instrumented_state.split_segment(true, seg_path, new_writer);
}
}
Expand Down
20 changes: 20 additions & 0 deletions prover/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,23 @@ Or

RUST_LOG=info ELF_PATH=examples/revme/target/mips-unknown-linux-musl/release/evm HOST_PROGRAM=revm JSON_PATH=../emulator/test-vectors/test.json SEG_OUTPUT=/tmp/output SEG_SIZE=262144 cargo run --release --example zkmips prove_host_program
```

## Prove precompile code
* Build the sha2-rust
```
cd prover/examples/sha2-rust
cargo build -r --target=mips-unknown-linux-musl
```

* Build the sha2-precompile
```
cd prover/examples/sha2-precompile
cargo build -r --target=mips-unknown-linux-musl
```

* Run the host program
```
cd ../..

RUST_LOG=info PRECOMPILE_PATH=examples/sha2-rust/target/mips-unknown-linux-musl/release/sha2-rust ELF_PATH=examples/sha2-precompile/target/mips-unknown-linux-musl/release/sha2-precompile HOST_PROGRAM=sha2_precompile SEG_OUTPUT=/tmp/output cargo run --release --example zkmips prove_host_program
```
48 changes: 0 additions & 48 deletions prover/examples/add-go/add.go

This file was deleted.

7 changes: 0 additions & 7 deletions prover/examples/add-go/go.mod

This file was deleted.

278 changes: 278 additions & 0 deletions prover/examples/sha2-precompile/Cargo.lock

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

10 changes: 10 additions & 0 deletions prover/examples/sha2-precompile/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[workspace]
[package]
version = "0.1.0"
name = "sha2-precompile"
edition = "2021"

[dependencies]
# zkm-runtime = { git = "https://github.com/zkMIPS/zkm", package = "zkm-runtime" }
zkm-runtime = { path = "../../../runtime/entrypoint" }
sha2 = { version = "0.10.8", default-features = false }
4 changes: 4 additions & 0 deletions prover/examples/sha2-precompile/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "nightly-2023-04-06"
targets = ["mips-unknown-linux-musl"]
profile = "minimal"
Loading
Loading