Skip to content

Commit

Permalink
upgrade risc0 to v0.19 (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wollac committed Nov 1, 2023
1 parent 69402de commit eed232b
Show file tree
Hide file tree
Showing 11 changed files with 399 additions and 199 deletions.
275 changes: 202 additions & 73 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ lto = true
opt-level = 3

[workspace.dependencies]
bonsai-sdk = "0.4"
bonsai-sdk = "0.5"
hashbrown = { version = "0.14", features = ["inline-more"] }
risc0-build = "0.18"
risc0-zkvm = { version = "0.18", default-features = false }
risc0-build = "0.19"
risc0-zkvm = { version = "0.19", default-features = false }
revm = { version = "3.5", default-features = false, features = ["std", "serde", "optional_no_base_fee", "optional_balance_check"] }
64 changes: 50 additions & 14 deletions guests/eth-block/Cargo.lock

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

2 changes: 1 addition & 1 deletion guests/eth-block/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
k256 = { version = "=0.13.1", features = ["std", "ecdsa"], default_features = false }
risc0-zkvm = { version = "0.18", default-features = false, features = ['std'] }
risc0-zkvm = { version = "0.19", default-features = false, features = ['std'] }
zeth-lib = { path = "../../lib", default-features = false }

[patch.crates-io]
Expand Down
64 changes: 50 additions & 14 deletions guests/op-block/Cargo.lock

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

2 changes: 1 addition & 1 deletion guests/op-block/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
k256 = { version = "=0.13.1", features = ["std", "ecdsa"], default_features = false }
risc0-zkvm = { version = "0.18", default-features = false, features = ['std'] }
risc0-zkvm = { version = "0.19", default-features = false, features = ['std'] }
zeth-lib = { path = "../../lib", default-features = false }

[patch.crates-io]
Expand Down
21 changes: 11 additions & 10 deletions host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ use clap::Parser;
use ethers_core::types::Transaction as EthersTransaction;
use log::{error, info};
use risc0_zkvm::{
serde::{from_slice, to_vec},
Executor, ExecutorEnv, FileSegmentRef, MemoryImage, Program, Receipt,
serde::to_vec, ExecutorEnv, ExecutorImpl, FileSegmentRef, MemoryImage, Program, Receipt,
};
use serde::{Deserialize, Serialize};
use tempfile::tempdir;
Expand Down Expand Up @@ -70,7 +69,7 @@ struct Args {
#[clap(short, long, require_equals = true, num_args = 0..=1, default_missing_value = "20")]
/// Runs the verification inside the zkvm executor locally. Accepts a custom maximum
/// segment cycle count as a power of 2. [default: 20]
local_exec: Option<usize>,
local_exec: Option<u32>,

#[clap(short, long, default_value_t = false)]
/// Whether to submit the proving workload to Bonsai.
Expand Down Expand Up @@ -276,14 +275,14 @@ where
builder
.session_limit(None)
.segment_limit_po2(segment_limit_po2)
.add_input(&input);
.write_slice(&input);

if args.profile {
builder.trace_callback(profiler.make_trace_callback());
}

let env = builder.build().unwrap();
let mut exec = Executor::from_elf(env, guest_elf).unwrap();
let mut exec = ExecutorImpl::from_elf(env, guest_elf).unwrap();

let segment_dir = tempdir().unwrap();

Expand Down Expand Up @@ -318,7 +317,7 @@ where
);

let expected_hash = init.fini_block.hash();
let found_hash: BlockHash = from_slice(&session.journal).unwrap();
let found_hash: BlockHash = session.journal.decode().unwrap();

if found_hash == expected_hash {
info!("Block hash (from executor): {}", found_hash);
Expand All @@ -335,12 +334,13 @@ where
// Run in Bonsai (if requested)
if bonsai_session_uuid.is_none() && args.submit_to_bonsai {
info!("Creating Bonsai client");
let client = bonsai_sdk::Client::from_env().expect("Could not create Bonsai client");
let client = bonsai_sdk::Client::from_env(risc0_zkvm::VERSION)
.expect("Could not create Bonsai client");

// create the memoryImg, upload it and return the imageId
info!("Uploading memory image");
let img_id = {
let program = Program::load_elf(guest_elf, risc0_zkvm::MEM_SIZE as u32)
let program = Program::load_elf(guest_elf, risc0_zkvm::GUEST_MAX_MEM as u32)
.expect("Could not load ELF");
let image = MemoryImage::new(&program, risc0_zkvm::PAGE_SIZE as u32)
.expect("Could not create memory image");
Expand Down Expand Up @@ -373,7 +373,8 @@ where

// Verify receipt from Bonsai (if requested)
if let Some(session_uuid) = bonsai_session_uuid {
let client = bonsai_sdk::Client::from_env().expect("Could not create Bonsai client");
let client = bonsai_sdk::Client::from_env(risc0_zkvm::VERSION)
.expect("Could not create Bonsai client");
let session = bonsai_sdk::SessionId { uuid: session_uuid };

loop {
Expand All @@ -400,7 +401,7 @@ where
.expect("Receipt verification failed");

let expected_hash = init.fini_block.hash();
let found_hash: BlockHash = from_slice(&receipt.journal).unwrap();
let found_hash: BlockHash = receipt.journal.decode().unwrap();

if found_hash == expected_hash {
info!("Block hash (from Bonsai): {}", found_hash);
Expand Down
Loading

0 comments on commit eed232b

Please sign in to comment.