Skip to content

Commit

Permalink
fix(uniffi-bindgen): the udl file can be satisfied no matter the gpu …
Browse files Browse the repository at this point in the history
…feature flag in on or off
  • Loading branch information
moven0831 authored and oskarth committed Jan 17, 2024
1 parent 5504123 commit 67dfe33
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 16 additions & 0 deletions mopro-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ pub struct SetupResult {
pub provingKey: Vec<u8>,
}

// NOTE: Need to hardcode the types here, otherwise UniFFI will complain if the gpu-benchmarks feature is not enabled
#[derive(Debug, Clone)]
#[cfg(not(feature = "gpu-benchmarks"))]
pub struct BenchmarkResult {
pub num_msm: u32,
pub avg_processing_time: f64,
pub total_processing_time: f64,
pub allocated_memory: u32,
}

// pub inputs: Vec<u8>,

impl From<mopro_core::MoproError> for FFIError {
Expand Down Expand Up @@ -167,6 +177,12 @@ pub fn run_msm_benchmark(num_msm: Option<u32>) -> Result<BenchmarkResult, MoproE
Ok(benchmarks)
}

#[cfg(not(feature = "gpu-benchmarks"))]
pub fn run_msm_benchmark(num_msm: Option<u32>) -> Result<BenchmarkResult, MoproError> {
println!("gpu-benchmarks feature not enabled!");
panic!("gpu-benchmarks feature not enabled!");
}

fn add(a: u32, b: u32) -> u32 {
a + b
}
Expand Down
16 changes: 8 additions & 8 deletions mopro-ffi/src/mopro.udl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace mopro {
[Throws=MoproError]
boolean verify_proof2(bytes proof, bytes public_input);

// [Throws=MoproError]
// BenchmarkResult run_msm_benchmark(u32? num_msm);
[Throws=MoproError]
BenchmarkResult run_msm_benchmark(u32? num_msm);
};

dictionary SetupResult {
Expand All @@ -27,12 +27,12 @@ dictionary GenerateProofResult {
bytes inputs;
};

// dictionary BenchmarkResult {
// u32 num_msm;
// double avg_processing_time;
// double total_processing_time;
// u32 allocated_memory;
// };
dictionary BenchmarkResult {
u32 num_msm;
double avg_processing_time;
double total_processing_time;
u32 allocated_memory;
};

[Error]
enum MoproError {
Expand Down

0 comments on commit 67dfe33

Please sign in to comment.