Skip to content

Commit

Permalink
Merge branch 'main' into ontake-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
petarvujovic98 committed Sep 3, 2024
2 parents 250aa67 + 8681299 commit fbb4076
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 38 deletions.
4 changes: 2 additions & 2 deletions host/config/chain_spec_list_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"verifier_address_forks": {
"HEKLA": {
"SGX":"0x532efbf6d62720d0b2a2bb9d11066e8588cae6d9",
"SP1":"0x13C845C4D4dc4c16d95Fc3B53F732e231245ae56",
"SP1":"0xFbE49f777E0078b3Fa0bae6de4794c88d6EA6DDD",
"RISC0":"0x4fEd801C5a876D4289e869cbEfA1E1A448b10714"
},
"ONTAKE": {
Expand Down Expand Up @@ -139,7 +139,7 @@
"verifier_address_forks": {
"HEKLA": {
"SGX":"0xb0f3186FC1963f774f52ff455DC86aEdD0b31F81",
"SP1":"0x13C845C4D4dc4c16d95Fc3B53F732e231245ae56",
"SP1":"0x0000000000000000000000000000000000000000",
"RISC0":"0x0000000000000000000000000000000000000000"
}
},
Expand Down
3 changes: 2 additions & 1 deletion lib/src/protocol_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::{
},
CycleTracker,
};
use log::info;
use reth_evm_ethereum::taiko::ANCHOR_GAS_LIMIT;

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -155,7 +156,7 @@ impl ProtocolInstance {

let blob_proof_type =
get_blob_proof_type(proof_type, input.taiko.blob_proof_type.clone());
println!("blob proof type: {:?}", &blob_proof_type);
info!("blob proof type: {:?}", &blob_proof_type);
match blob_proof_type {
crate::input::BlobProofType::ProofOfEquivalence => {
let ct = CycleTracker::start("proof_of_equivalence");
Expand Down
2 changes: 1 addition & 1 deletion provers/risc0/driver/src/methods/risc0_guest.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub const RISC0_GUEST_ELF: &[u8] =
include_bytes!("../../../guest/target/riscv32im-risc0-zkvm-elf/release/risc0-guest");
pub const RISC0_GUEST_ID: [u32; 8] = [
2273192126, 3371600541, 2393149482, 649684540, 896534796, 3888705079, 1226654129, 1785271921,
3154357135, 4157790813, 123789652, 116361652, 829137687, 2314522156, 1964429423, 2989684539,
];
58 changes: 27 additions & 31 deletions provers/sp1/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use sp1_sdk::{
network::client::NetworkClient,
proto::network::{ProofMode, UnclaimReason},
};
use sp1_sdk::{HashableKey, ProverClient, SP1Stdin, SP1VerifyingKey};
use sp1_sdk::{HashableKey, ProverClient, SP1Stdin};
use std::{
borrow::BorrowMut,
env, fs,
Expand Down Expand Up @@ -163,24 +163,34 @@ impl Prover for Sp1Prover {
.borrow_mut()
.public_values
.read::<[u8; 32]>();
verify_sol(&vk, &proof_bytes, &pi_hash)?;
let fixture = RaikoProofFixture {
vkey: vk.bytes32().to_string(),
public_values: B256::from_slice(&pi_hash).to_string(),
proof: reth_primitives::hex::encode_prefixed(&proof_bytes),
};

verify_sol(&fixture)?;
time.stop_with("==> Verification complete");
}

let proof_string = if proof_bytes.is_empty() {
None
} else {
// 0x + 64 bytes of the vkey + the proof
// vkey itself contains 0x prefix
Some(format!(
"{}{}",
vk.bytes32(),
reth_primitives::hex::encode(proof_bytes)
))
};

info!(
"Sp1 Prover: block {:?} completed! proof: {:?}",
output.header.number, proof_string
);
Ok::<_, ProverError>(Proof {
proof: {
if proof_bytes.is_empty() {
None
} else {
// 0x + 64 bytes of the vkey + the proof
// vkey itself contains 0x prefix
Some(format!(
"{}{}",
vk.bytes32(),
reth_primitives::hex::encode(proof_bytes)
))
}
},
proof: proof_string,
quote: None,
})
}
Expand Down Expand Up @@ -248,28 +258,14 @@ fn init_verifier() -> Result<PathBuf, ProverError> {
/// A fixture that can be used to test the verification of SP1 zkVM proofs inside Solidity.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct RaikoProofFixture {
pub(crate) struct RaikoProofFixture {
vkey: String,
public_values: String,
proof: String,
}

pub fn verify_sol(
vk: &SP1VerifyingKey,
proof_bytes: &[u8],
pi_hash: &[u8; 32],
) -> ProverResult<()> {
fn verify_sol(fixture: &RaikoProofFixture) -> ProverResult<()> {
assert!(VERIFIER.is_ok());

// Deserialize the public values.
// let pi_hash = proof.public_values.read::<[u8; 32]>();

// Create the testing fixture so we can test things end-to-end.
let fixture = RaikoProofFixture {
vkey: vk.bytes32().to_string(),
public_values: B256::from_slice(pi_hash).to_string(),
proof: format!("0x{}", reth_primitives::hex::encode(proof_bytes)),
};
debug!("===> Fixture: {:#?}", fixture);

// Save the fixture to a file.
Expand Down
Binary file modified provers/sp1/guest/elf/sp1-guest
Binary file not shown.
6 changes: 3 additions & 3 deletions script/prove-block.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ elif [ "$proof" == "sp1" ]; then
"proof_type": "sp1",
"blob_proof_type": "proof_of_equivalence",
"sp1": {
"recursion": "core",
"prover": "mock",
"recursion": "plonk",
"prover": "network",
"verify": false
}
'
Expand Down Expand Up @@ -147,5 +147,5 @@ for block in $(eval echo {$rangeStart..$rangeEnd}); do
}"
echo ""

sleep 25.0
sleep 1.0
done

0 comments on commit fbb4076

Please sign in to comment.