privacy-scaling-explorations / halo2

https://privacy-scaling-explorations.github.io/halo2/
Other
201 stars 121 forks source link

Make Expression copiable using singleton arena #354

Open adria0 opened 2 months ago

adria0 commented 2 months ago

NOTE: Relevant files to review are halo2_frontend/src/plonk/circuit/{expession.rs, arena.rs}

This an experiment about making expression copiable. To implement this we go with this strategy:

pub trait FieldFront: Field {
    // Since base trait is not referenciable, we need a way to access it.
    // This is necessary to provide a way to transform fields from/to backend.
    type Field: Field;
    fn into_field(self) -> Self::Field;
    fn into_fieldfront(f: Self::Field) -> Self;

    // Allocate a new expression
    fn alloc(expr: Expression<Self>) -> ExprRef<Self>;

    // Get an expression
    fn get(ref_: &ExprRef<Self>) -> Expression<Self>;

    // Replace an expression
    fn replace(expr: Expression<Self>, ref_: &ExprRef<Self>);
}

This means:

codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 81.97065% with 86 lines in your changes missing coverage. Please review.

Project coverage is 81.81%. Comparing base (32599e8) to head (c8c7ff9). Report is 1 commits behind head on main.

Files Patch % Lines
halo2_frontend/src/plonk/circuit/expression.rs 69.11% 63 Missing :warning:
halo2_frontend/src/dev/failure.rs 12.50% 7 Missing :warning:
halo2_frontend/src/plonk/circuit.rs 0.00% 4 Missing :warning:
halo2_proofs/src/plonk/prover.rs 98.05% 4 Missing :warning:
halo2_frontend/src/dev/tfp.rs 0.00% 3 Missing :warning:
halo2_proofs/src/plonk.rs 50.00% 2 Missing :warning:
halo2_frontend/src/dev/failure/emitter.rs 0.00% 1 Missing :warning:
halo2_frontend/src/dev/gates.rs 0.00% 1 Missing :warning:
...o2_frontend/src/plonk/circuit/constraint_system.rs 66.66% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #354 +/- ## ========================================== - Coverage 82.09% 81.81% -0.29% ========================================== Files 83 83 Lines 17228 17452 +224 ========================================== + Hits 14143 14278 +135 - Misses 3085 3174 +89 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.