From 7f049fa7da3882307866607b12279b2504c30063 Mon Sep 17 00:00:00 2001 From: Rohit Narurkar Date: Sat, 25 Jan 2025 16:01:38 +0000 Subject: [PATCH] feat: evm_verify is fallible --- snark-verifier-sdk/benches/standard_plonk.rs | 2 +- snark-verifier-sdk/benches/zkevm_plus_state.rs | 4 ++-- snark-verifier-sdk/examples/standard_plonk.rs | 2 +- snark-verifier-sdk/src/evm.rs | 9 +++++++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/snark-verifier-sdk/benches/standard_plonk.rs b/snark-verifier-sdk/benches/standard_plonk.rs index 6f933bb9..62d73ef2 100644 --- a/snark-verifier-sdk/benches/standard_plonk.rs +++ b/snark-verifier-sdk/benches/standard_plonk.rs @@ -246,7 +246,7 @@ fn bench(c: &mut Criterion) { None, ); #[cfg(feature = "revm")] - evm_verify(_deployment_code, instances, _proof); + evm_verify(_deployment_code, instances, _proof).expect("evm_verify should succeed"); } } diff --git a/snark-verifier-sdk/benches/zkevm_plus_state.rs b/snark-verifier-sdk/benches/zkevm_plus_state.rs index a0aabf02..735a4fc3 100644 --- a/snark-verifier-sdk/benches/zkevm_plus_state.rs +++ b/snark-verifier-sdk/benches/zkevm_plus_state.rs @@ -123,7 +123,7 @@ fn bench(c: &mut Criterion) { None, ); - evm_verify(deployment_code, instances.clone(), proof); + evm_verify(deployment_code, instances.clone(), proof).expect("evm_verify should succeed"); let start2 = start_timer!(|| "Create EVM GWC proof"); let agg_circuit = AggregationCircuit::new::( @@ -143,7 +143,7 @@ fn bench(c: &mut Criterion) { None, ); - evm_verify(deployment_code, instances, proof); + evm_verify(deployment_code, instances, proof).expect("evm_verify should succeed"); } // run benches diff --git a/snark-verifier-sdk/examples/standard_plonk.rs b/snark-verifier-sdk/examples/standard_plonk.rs index fb0e17c1..c7a8c21c 100644 --- a/snark-verifier-sdk/examples/standard_plonk.rs +++ b/snark-verifier-sdk/examples/standard_plonk.rs @@ -215,5 +215,5 @@ fn main() { Some(Path::new("examples/StandardPlonkVerifier.sol")), ); #[cfg(feature = "revm")] - evm_verify(_deployment_code, instances, _proof); + evm_verify(_deployment_code, instances, _proof).expect("evm_verify should succeed"); } diff --git a/snark-verifier-sdk/src/evm.rs b/snark-verifier-sdk/src/evm.rs index 6519752a..22ccc7fb 100644 --- a/snark-verifier-sdk/src/evm.rs +++ b/snark-verifier-sdk/src/evm.rs @@ -175,10 +175,15 @@ pub fn gen_evm_verifier_shplonk>( } #[cfg(feature = "revm")] -pub fn evm_verify(deployment_code: Vec, instances: Vec>, proof: Vec) { +pub fn evm_verify( + deployment_code: Vec, + instances: Vec>, + proof: Vec, +) -> Result { let calldata = encode_calldata(&instances, &proof); - let gas_cost = snark_verifier::loader::evm::deploy_and_call(deployment_code, calldata).unwrap(); + let gas_cost = snark_verifier::loader::evm::deploy_and_call(deployment_code, calldata)?; dbg!(gas_cost); + Ok(gas_cost) } pub fn write_calldata(instances: &[Vec], proof: &[u8], path: &Path) -> io::Result {