Skip to content

Commit

Permalink
Remove uneeded bounds on structs (#1027)
Browse files Browse the repository at this point in the history
* removing uneeded bound(s) on struct in src/field.rs

* removing uneeded bound(s) on struct in src/coprocessor/mod.rs

* removing uneeded bound(s) on struct in src/coprocessor/trie/mod.rs

* removing uneeded bound(s) on struct in src/coprocessor/circom.rs

* removing uneeded bound(s) on struct in src/cli/field_data.rs

* removing uneeded bound(s) on struct in src/eval/lang.rs

* removing uneeded bound(s) on struct in src/eval/mod.rs

* removing uneeded bound(s) on struct in src/lem/circuit.rs

* removing uneeded bound(s) on struct in src/lem/eval.rs

* removing uneeded trait bound(s) on impl in src/parser/error.rs

* removing uneeded trait bound(s) on impl in src/public_parameters/disk_cache.rs
  • Loading branch information
huitseeker authored Jan 9, 2024
1 parent 2542602 commit b278e9d
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/cli/field_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ mod tests {
use super::{de, ser, HasFieldModulus};

#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
struct Struct<F: LurkField> {
struct Struct<F> {
str: String,
int: i32,
ff: F,
Expand Down
2 changes: 1 addition & 1 deletion src/coprocessor/circom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Then run `lurk coprocessor --name {name} <{}_FOLDER>` to instantiate a new gadge
/// }
/// ```
#[derive(Debug)]
pub struct CircomCoprocessor<F: LurkField, C: CircomGadget<F>> {
pub struct CircomCoprocessor<F: LurkField, C> {
gadget: C,
config: CircomConfig<F>,
}
Expand Down
4 changes: 2 additions & 2 deletions src/coprocessor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub(crate) mod test {

/// A dumb Coprocessor for testing.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub(crate) struct DumbCoprocessor<F: LurkField> {
pub(crate) struct DumbCoprocessor<F> {
pub(crate) _p: PhantomData<F>,
}

Expand Down Expand Up @@ -235,7 +235,7 @@ pub(crate) mod test {

/// A coprocessor that simply halts the CEK machine, for testing purposes
#[derive(Clone, Debug, Serialize, Deserialize)]
pub(crate) struct Terminator<F: LurkField> {
pub(crate) struct Terminator<F> {
_p: PhantomData<F>,
}

Expand Down
6 changes: 3 additions & 3 deletions src/coprocessor/trie/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub enum TrieCoproc<F: LurkField> {
}

#[derive(Clone, Debug, Serialize, Default, Deserialize)]
pub struct NewCoprocessor<F: LurkField> {
pub struct NewCoprocessor<F> {
_p: PhantomData<F>,
}

Expand Down Expand Up @@ -104,7 +104,7 @@ impl<F: LurkField> CoCircuit<F> for NewCoprocessor<F> {
}

#[derive(Clone, Debug, Serialize, Default, Deserialize)]
pub struct LookupCoprocessor<F: LurkField> {
pub struct LookupCoprocessor<F> {
_p: PhantomData<F>,
}

Expand Down Expand Up @@ -208,7 +208,7 @@ impl<F: LurkField> CoCircuit<F> for LookupCoprocessor<F> {
}

#[derive(Clone, Debug, Serialize, Default, Deserialize)]
pub struct InsertCoprocessor<F: LurkField> {
pub struct InsertCoprocessor<F> {
_p: PhantomData<F>,
}

Expand Down
12 changes: 6 additions & 6 deletions src/eval/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
/// This struct is an example of a coprocessor implementation that would extend the [`crate::coprocessor::Coprocessor`] trait.
/// More implementations can be added without modifying the existing code, adhering to the open-closed principle.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DummyCoprocessor<F: LurkField> {
pub struct DummyCoprocessor<F> {
pub(crate) _p: PhantomData<F>,
}

Expand All @@ -38,7 +38,7 @@ impl<F: LurkField> Coprocessor<F> for DummyCoprocessor<F> {

impl<F: LurkField> CoCircuit<F> for DummyCoprocessor<F> {}

impl<F: LurkField> DummyCoprocessor<F> {
impl<F> DummyCoprocessor<F> {
#[allow(dead_code)]
pub(crate) fn new() -> Self {
Self {
Expand Down Expand Up @@ -73,13 +73,13 @@ pub enum Coproc<F: LurkField> {
///
// TODO: Define a trait for the Hash and parameterize on that also.
#[derive(Debug, Default, Clone, Deserialize, Serialize)]
pub struct Lang<F: LurkField, C: Coprocessor<F>> {
pub struct Lang<F, C> {
/// An IndexMap that stores coprocessors with their associated `Sym` keys.
coprocessors: IndexMap<Symbol, C>,
_p: PhantomData<F>,
}

impl<F: LurkField, C: Coprocessor<F>> Lang<F, C> {
impl<F: LurkField, C> Lang<F, C> {
#[inline]
pub fn new() -> Self {
Self {
Expand Down Expand Up @@ -154,7 +154,7 @@ impl<F: LurkField, C: Coprocessor<F>> Lang<F, C> {
/// A `Binding` associates a name (`Sym`) and `Coprocessor`. It facilitates modular construction of `Lang`s using
/// `Coprocessor`s.
#[derive(Debug)]
pub struct Binding<F: LurkField, C: Coprocessor<F>> {
pub struct Binding<F, C> {
name: Symbol,
coproc: C,
_p: PhantomData<F>,
Expand All @@ -166,7 +166,7 @@ impl<F: LurkField, C: Coprocessor<F>, S: Into<Symbol>> From<(S, C)> for Binding<
}
}

impl<F: LurkField, C: Coprocessor<F>> Binding<F, C> {
impl<F: LurkField, C> Binding<F, C> {
pub fn new<T: Into<C>, S: Into<Symbol>>(name: S, coproc: T) -> Self {
Self {
name: name.into(),
Expand Down
4 changes: 1 addition & 3 deletions src/eval/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use crate::field::LurkField;

use std::cmp::PartialEq;
use std::marker::PhantomData;

pub mod lang;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Frame<T: Copy, W: Copy, F: LurkField, C> {
pub struct Frame<T: Copy, W: Copy, F, C> {
pub input: T,
pub output: T,
pub i: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl LurkField for GrumpkinScalar {
// For working around the orphan trait impl rule
/// Wrapper struct around a field element that implements additional traits
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct FWrap<F: LurkField>(pub F);
pub struct FWrap<F>(pub F);

impl<F: LurkField> Copy for FWrap<F> {}

Expand Down
2 changes: 1 addition & 1 deletion src/lem/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ impl Block {
}
}

struct RecursiveContext<'a, F: LurkField, C: Coprocessor<F>> {
struct RecursiveContext<'a, F: LurkField, C> {
lang: &'a Lang<F, C>,
store: &'a Store<F>,
global_allocator: &'a GlobalAllocator<F>,
Expand Down
4 changes: 2 additions & 2 deletions src/lem/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ pub fn evaluate_simple<F: LurkField, C: Coprocessor<F>>(
evaluate_simple_with_env(lang_setup, expr, store.intern_nil(), store, limit)
}

pub struct EvalConfig<'a, F: LurkField, C: Coprocessor<F>> {
pub struct EvalConfig<'a, F, C> {
lang: &'a Lang<F, C>,
folding_mode: FoldingMode,
}

impl<'a, F: LurkField, C: Coprocessor<F>> EvalConfig<'a, F, C> {
impl<'a, F, C> EvalConfig<'a, F, C> {
#[inline]
pub fn new_ivc(lang: &'a Lang<F, C>) -> Self {
Self {
Expand Down
2 changes: 0 additions & 2 deletions src/parser/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ impl<'a, F: LurkField> fmt::Display for ParseError<Span<'a>, F> {
impl<I: AsBytes, F: LurkField> nom::error::ParseError<I> for ParseError<I, F>
where
I: InputLength,
I: Clone,
{
fn from_error_kind(input: I, kind: ErrorKind) -> Self {
ParseError::new(input, ParseErrorKind::Nom(kind))
Expand Down Expand Up @@ -155,7 +154,6 @@ where
impl<I: AsBytes, F: LurkField> nom::error::ContextError<I> for ParseError<I, F>
where
I: InputLength,
I: Clone,
{
fn add_context(input: I, ctx: &'static str, other: Self) -> Self {
match input.input_len().cmp(&other.input.input_len()) {
Expand Down

1 comment on commit b278e9d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks

Table of Contents

Overview

This benchmark report shows the Fibonacci GPU benchmark.
NVIDIA L4
Intel(R) Xeon(R) CPU @ 2.20GHz
125.78 GB RAM
Workflow run: https://github.com/lurk-lab/lurk-rs/actions/runs/7466317494

Benchmark Results

LEM Fibonacci Prove - rc = 100

fib-ref=25426023dfbfc68020a6db99f543a6d2cae69114 fib-ref=b278e9d43b10ba32d04e8e963c45db32b2d8d4a8
num-100 1.73 s (✅ 1.00x) 1.73 s (✅ 1.00x slower)
num-200 3.32 s (✅ 1.00x) 3.33 s (✅ 1.00x slower)

LEM Fibonacci Prove - rc = 600

fib-ref=25426023dfbfc68020a6db99f543a6d2cae69114 fib-ref=b278e9d43b10ba32d04e8e963c45db32b2d8d4a8
num-100 1.94 s (✅ 1.00x) 1.96 s (✅ 1.01x slower)
num-200 3.33 s (✅ 1.00x) 3.35 s (✅ 1.01x slower)

Made with criterion-table

Please sign in to comment.