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

Suggestions for no-relay template on Feb 15 #80

Merged
merged 3 commits into from
Feb 16, 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
29 changes: 1 addition & 28 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
[build]
rustflags = [
"-Dclippy::correctness",
"-Dclippy::suspicious",
"-Wclippy::complexity",
"-Wclippy::perf",
"-Wclippy::style",
"-Wclippy::unwrap_used",
"-Wclippy::expect_used",
"-Dclippy::needless_return",
"-Dbad_style",
"-Dbare_trait_objects",
"-Ddead_code",
"-Dimproper_ctypes",
"-Dno_mangle_generic_items",
"-Dnon_shorthand_field_patterns",
"-Doverflowing_literals",
"-Dpath_statements",
"-Dpatterns_in_fns_without_body",
"-Dprivate_in_public",
"-Dtrivial_casts",
"-Dtrivial_numeric_casts",
"-Dunconditional_recursion",
"-Dunused_allocation",
"-Dunused_comparisons",
"-Wunused_extern_crates",
"-Dunused_parens",
"-Dwhile_true",
]
rustflags = ["-Dclippy::all", "-Dwarnings"]

[net]
git-fetch-with-cli = true
62 changes: 31 additions & 31 deletions Cargo.lock

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

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
resolver = "2"
members = ["apps", "methods"]
exclude = ["lib"]

[workspace.package]
version = "0.1.0"
Expand All @@ -17,9 +18,12 @@ ethers = { version = "2.0" }
hex = { version = "0.4" }
log = { version = "0.4" }
methods = { path = "./methods", package = "bonsai-starter-methods" }
risc0-build = { git = "http://github.com/risc0/risc0", branch = "capossele/foundry-template-0.20", features = ["guest-list", "docker"] }
risc0-ethereum-contracts = { git = "http://github.com/risc0/risc0-ethereum", rev = "3be9ef901d723e8f3efd4536bcd742f33d6fb16d" }
# DO NOT MERGE: Figure out what reference to use for this. Cherry pick to the release branch?
risc0-build = { git = "https://github.com/risc0/risc0", rev = "7f73166", features = ["docker"] }
# NOTE: Forge requires risc0-ethereum as a submodule, so we reuse it here as a path dependency.
risc0-ethereum-contracts = { path = "lib/risc0-ethereum/contracts" }
risc0-zkvm = { version = "0.20", default-features = false }
risc0-zkp = { version = "0.20", default-features = false }
serde = { version = "1.0", features = ["derive", "std"] }

[profile.release]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Your new project consists of:

### Run the Tests

- Use `RISC0_DEV_MODE=true cargo test` to run the tests in your zkVM program.
- Use `cargo test` to run the tests in your zkVM program.
- Use `RISC0_DEV_MODE=true forge test -vvv` to test your Solidity contracts and their interaction with your zkVM program.

## Develop Your Application
Expand Down Expand Up @@ -148,4 +148,4 @@ Below are the primary files in the project directory
[deployment guide]: /deployment-guide.md
[Sepolia]: https://www.alchemy.com/overviews/sepolia-testnet
[RISC Zero installation]: https://dev.risczero.com/api/zkvm/install
[Publisher]: ./apps/README.md
[Publisher]: ./apps/README.md
4 changes: 1 addition & 3 deletions methods/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ methods = ["guest"]
[build-dependencies]
hex = { workspace = true }
risc0-build = { workspace = true }

[dependencies]
risc0-build = { workspace = true }
risc0-zkp = { workspace = true }

[dev-dependencies]
alloy-primitives = { workspace = true }
Expand Down
9 changes: 5 additions & 4 deletions methods/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use std::{collections::HashMap, env, fs, process::Command};

use risc0_build::{embed_methods_with_options, DockerOptions, GuestOptions};
use risc0_zkp::core::digest::Digest;

const SOL_HEADER: &str = r#"// Copyright 2024 RISC Zero, Inc.
//
Expand Down Expand Up @@ -66,12 +67,12 @@ fn main() {
.iter()
.map(|method| {
let name = method.name.to_uppercase().replace('-', "_");
let image_id = hex::encode(method.make_image_id());
let image_id = hex::encode(Digest::from(method.image_id));
let image_id_declaration =
format!("bytes32 public constant {name}_ID = bytes32(0x{image_id});");

let elf = method.elf_path.to_string_lossy().to_string();
let elf_declaration = format!("string public constant {name}_PATH = \"{elf}\";");
let elf_path = method.path.to_string();
let elf_declaration = format!("string public constant {name}_PATH = \"{elf_path}\";");

(image_id_declaration, elf_declaration)
})
Expand All @@ -82,7 +83,7 @@ fn main() {

// Building the final image_ID file content.
let file_content = format!("{SOL_HEADER}{IMAGE_ID_LIB_HEADER}\n{image_ids}\n}}");
fs::write(SOLIDITY_IMAGE_ID_PATH, &file_content).unwrap_or_else(|err| {
fs::write(SOLIDITY_IMAGE_ID_PATH, file_content).unwrap_or_else(|err| {
panic!(
"failed to save changes to {}: {}",
SOLIDITY_IMAGE_ID_PATH, err
Expand Down
10 changes: 6 additions & 4 deletions methods/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include!(concat!(env!("OUT_DIR"), "/methods.rs"));
mod tests {
use alloy_primitives::U256;
use alloy_sol_types::SolValue;
use risc0_zkvm::{default_prover, ExecutorEnv};
use risc0_zkvm::{default_executor, ExecutorEnv};

#[test]
fn proves_even_number() {
Expand All @@ -30,9 +30,10 @@ mod tests {
.build()
.unwrap();

let receipt = default_prover().prove(env, super::IS_EVEN_ELF).unwrap();
// NOTE: Use the executor to run tests without proving.
let session_info = default_executor().execute(env, super::IS_EVEN_ELF).unwrap();

let x = U256::abi_decode(&receipt.journal.bytes, true).unwrap();
let x = U256::abi_decode(&session_info.journal.bytes, true).unwrap();
assert_eq!(x, even_number);
}

Expand All @@ -46,6 +47,7 @@ mod tests {
.build()
.unwrap();

default_prover().prove(env, super::IS_EVEN_ELF).unwrap();
// NOTE: Use the executor to run tests without proving.
default_executor().execute(env, super::IS_EVEN_ELF).unwrap();
}
}
Loading