Skip to content

Commit

Permalink
Merge pull request #101 from taikoxyz/integrate-r0
Browse files Browse the repository at this point in the history
update risc0 dependency to 0.21.0 to run bonsai
  • Loading branch information
Brechtpd authored Apr 13, 2024
2 parents 4fd70ee + 4c0e4a9 commit 967015f
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 110 deletions.
111 changes: 81 additions & 30 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ revm = { git = "https://github.com/taikoxyz/revm.git", branch = "fix-ecrecover",
] }

# risc zero
risc0-zkvm = { version = "0.20.1", features = ["prove", "getrandom"]}
bonsai-sdk = { version = "0.6.0", features = ["async"]}
risc0-build = { version = "0.20.1" }
risc0-zkvm = { version = "0.21.0", features = ["prove", "getrandom"]}
bonsai-sdk = { version = "0.7.0", features = ["async"]}
risc0-build = { version = "0.21.0" }

# SP1
sp1-core = { git = "https://github.com/succinctlabs/sp1.git", rev = "cb43fd74b24fad8ed24a4885499159de3680c89f" }
Expand Down Expand Up @@ -108,6 +108,7 @@ cfg-if = "1.0.0"
libflate = { version = "2.0.0" }
sha3 = { version = "0.10", default-features = false }
log = { version = "0.4" }
env_logger = { version = "0.11.3" }
typetag = { version = "0.2.15" }
hex = { version = "0.4.3" }
thiserror-no-std = "2.0.2"
Expand Down
1 change: 1 addition & 0 deletions host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ serde_json = { workspace = true }
tokio = { workspace = true }
hyper = { workspace = true }
hashbrown = { workspace = true }
env_logger = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
tracing-appender = { workspace = true }
Expand Down
44 changes: 21 additions & 23 deletions host/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,40 @@ pub async fn execute<D: Prover>(

// 2. Test run the block
memory::reset_stats();
let build_result = TaikoStrategy::build_from(&input);
let output = match &build_result {
match TaikoStrategy::build_from(&input) {
Ok((header, _mpt_node)) => {
info!("Verifying final state using provider data ...");
info!("Final block hash derived successfully. {}", header.hash());
info!("Final block header derived successfully. {:?}", header);
let pi = D::instance_hash(assemble_protocol_instance(&input, header)?);
let pi = D::instance_hash(assemble_protocol_instance(&input, &header)?);
// Make sure the blockhash from the node matches the one from the builder
assert_eq!(header.hash().0, input.block_hash, "block hash unexpected");
GuestOutput::Success((
let output = GuestOutput::Success((
WrappedHeader {
header: header.clone(),
},
pi,
))
));
memory::print_stats("Guest program peak memory used: ");

// Prove
memory::reset_stats();
let measurement = Measurement::start("Generating proof...", false);
let res = D::run(input.clone(), output, config)
.await
.map(|proof| (input, proof))
.map_err(|e| HostError::GuestError(e.to_string()));
measurement.stop_with("=> Proof generated");
memory::print_stats("Prover peak memory used: ");

total_proving_time.stop_with("====> Complete proof generated");
res
}
Err(_) => {
Err(e) => {
warn!("Proving bad block construction!");
GuestOutput::Failure
Err(HostError::GuestError(e.to_string()))
}
};
memory::print_stats("Guest program peak memory used: ");

// Prove
memory::reset_stats();
let measurement = Measurement::start("Generating proof...", false);
let res = D::run(input.clone(), output, config)
.await
.map(|proof| (input, proof))
.map_err(|e| HostError::GuestError(e.to_string()));
measurement.stop_with("=> Proof generated");
memory::print_stats("Prover peak memory used: ");

total_proving_time.stop_with("====> Complete proof generated");

res
}
}

/// prepare input data for provers
Expand Down
2 changes: 2 additions & 0 deletions host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use std::{alloc, fmt::Debug, fs::File, io::BufReader, path::PathBuf};

use anyhow::Result;
use cap::Cap;
use env_logger;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use server::serve;
Expand Down Expand Up @@ -74,6 +75,7 @@ pub struct Opt {

#[tokio::main]
async fn main() -> Result<()> {
env_logger::init();
let opt = Opt::from_args();
let config = get_config(None).unwrap();
println!("Start config:\n{:#?}", config);
Expand Down
Loading

0 comments on commit 967015f

Please sign in to comment.