Skip to content

Commit

Permalink
refine sp1 log and update hekla configs
Browse files Browse the repository at this point in the history
Signed-off-by: smtmfft <[email protected]>
  • Loading branch information
smtmfft committed Sep 2, 2024
1 parent 5533914 commit cf287d7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 34 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 @@ -92,7 +92,7 @@
"beacon_rpc": null,
"verifier_address":{
"SGX":"0x532efbf6d62720d0b2a2bb9d11066e8588cae6d9",
"SP1":"0x13C845C4D4dc4c16d95Fc3B53F732e231245ae56",
"SP1":"0x3a9f7A8a5De60DB861f53E258d4ACd400b007549",
"RISC0":"0x4fEd801C5a876D4289e869cbEfA1E1A448b10714"
},
"genesis_time": 0,
Expand Down Expand Up @@ -121,7 +121,7 @@
"beacon_rpc": null,
"verifier_address": {
"SGX":"0xb0f3186FC1963f774f52ff455DC86aEdD0b31F81",
"SP1":"0x13C845C4D4dc4c16d95Fc3B53F732e231245ae56",
"SP1":"0x0000000000000000000000000000000000000000",
"RISC0":"0x0000000000000000000000000000000000000000"
},
"genesis_time": 0,
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,
607296786, 1606947002, 2629660160, 1822491429, 181045099, 982315353, 2724841945, 1698180598,
];
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: format!("0x{}", reth_primitives::hex::encode(&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.

0 comments on commit cf287d7

Please sign in to comment.