Skip to content

Commit

Permalink
fix(sp1): convert to proper types
Browse files Browse the repository at this point in the history
  • Loading branch information
petarvujovic98 committed Oct 9, 2024
1 parent e9bd312 commit c55f162
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 5 additions & 6 deletions provers/sp1/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ static FIXTURE_PATH: Lazy<PathBuf> =
Lazy::new(|| Path::new(env!("CARGO_MANIFEST_DIR")).join("../contracts/src/fixtures/"));
static CONTRACT_PATH: Lazy<PathBuf> =
Lazy::new(|| Path::new(env!("CARGO_MANIFEST_DIR")).join("../contracts/src/exports/"));

pub static VERIFIER: Lazy<Result<PathBuf, ProverError>> = Lazy::new(init_verifier);

#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Sp1Param {
Expand Down Expand Up @@ -191,8 +191,8 @@ impl Prover for Sp1Prover {
.read::<[u8; 32]>();
let fixture = RaikoProofFixture {
vkey: vk.bytes32(),
public_values: pi_hash.into(),
proof: proof_bytes.clone(),
public_values: B256::from_slice(&pi_hash).to_string(),
proof: reth_primitives::hex::encode_prefixed(&proof_bytes),
};

verify_sol_by_contract_call(&fixture).await?;
Expand Down Expand Up @@ -253,7 +253,6 @@ impl Prover for Sp1Prover {
_store: Option<&mut dyn IdWrite>,
) -> ProverResult<Proof> {
let param = Sp1Param::deserialize(config.get("sp1").unwrap()).unwrap();
let mode = param.prover.clone().unwrap_or_else(get_env_mock);

info!("aggregate proof with param: {param:?}");

Expand All @@ -269,7 +268,7 @@ impl Prover for Sp1Prover {
let stark_vk = block_proof_vk.vk.clone();
let image_id = block_proof_vk.hash_u32();
let aggregation_input = ZkAggregationGuestInput {
image_id: image_id,
image_id,
block_inputs,
};
info!(
Expand Down Expand Up @@ -343,7 +342,7 @@ impl Prover for Sp1Prover {

Ok::<_, ProverError>(
Sp1Response {
proof: proof,
proof,
sp1_proof: None,
vkey: None,
}
Expand Down
8 changes: 3 additions & 5 deletions provers/sp1/driver/src/proof_verify/remote_contract_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ pub(crate) async fn verify_sol_by_contract_call(fixture: &RaikoProofFixture) ->

let provider = ProviderBuilder::new().on_http(Url::parse(&sp1_verifier_rpc_url).unwrap());
let program_key: B256 = B256::from_str(&fixture.vkey).unwrap();
let public_value = fixture.public_values;
let public_value = fixture.public_values.clone();
let proof_bytes = fixture.proof.clone();

info!(
"verify sp1 proof with program key: {:?} public value: {:?} proof: {:?}",
program_key,
public_value,
"verify sp1 proof with program key: {program_key:?} public value: {public_value:?} proof: {:?}",
reth_primitives::hex::encode(&proof_bytes)
);

Expand All @@ -50,7 +48,7 @@ pub(crate) async fn verify_sol_by_contract_call(fixture: &RaikoProofFixture) ->
if verify_call_res.is_ok() {
info!("SP1 proof verified successfully using {sp1_verifier_addr:?}!");
} else {
error!("SP1 proof verification failed: {:?}!", verify_call_res);
error!("SP1 proof verification failed: {verify_call_res:?}!");
}

Ok(())
Expand Down

0 comments on commit c55f162

Please sign in to comment.