Skip to content

Commit

Permalink
change: Apply memory optimisation technique from Scroll
Browse files Browse the repository at this point in the history
This incorporates the work done in
scroll-tech#28 in order to lower the
memory consumption significantly trading off for some performance.

A much more deep analysis can be found here: axiom-crypto#17
  • Loading branch information
CPerezz committed Feb 26, 2024
1 parent 94fb307 commit 5f0ba9d
Show file tree
Hide file tree
Showing 9 changed files with 1,181 additions and 471 deletions.
16 changes: 4 additions & 12 deletions halo2_backend/src/plonk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use crate::helpers::{
self, polynomial_slice_byte_length, read_polynomial_vec, write_polynomial_slice,
SerdeCurveAffine, SerdePrimeField,
};
use crate::poly::{
Coeff, EvaluationDomain, ExtendedLagrangeCoeff, LagrangeCoeff, PinnedEvaluationDomain,
Polynomial,
};
use crate::poly::{Coeff, EvaluationDomain, LagrangeCoeff, PinnedEvaluationDomain, Polynomial};
use evaluation::Evaluator;
use halo2_common::plonk::{Circuit, ConstraintSystem, PinnedConstraintSystem};
use halo2_common::transcript::{EncodedChallenge, Transcript};
Expand Down Expand Up @@ -323,12 +320,11 @@ pub struct PinnedVerificationKey<'a, C: CurveAffine> {
#[derive(Clone, Debug)]
pub struct ProvingKey<C: CurveAffine> {
vk: VerifyingKey<C>,
l0: Polynomial<C::Scalar, ExtendedLagrangeCoeff>,
l_last: Polynomial<C::Scalar, ExtendedLagrangeCoeff>,
l_active_row: Polynomial<C::Scalar, ExtendedLagrangeCoeff>,
l0: Polynomial<C::Scalar, Coeff>,
l_last: Polynomial<C::Scalar, Coeff>,
l_active_row: Polynomial<C::Scalar, Coeff>,
fixed_values: Vec<Polynomial<C::Scalar, LagrangeCoeff>>,
fixed_polys: Vec<Polynomial<C::Scalar, Coeff>>,
fixed_cosets: Vec<Polynomial<C::Scalar, ExtendedLagrangeCoeff>>,
permutation: permutation::ProvingKey<C>,
ev: Evaluator<C>,
}
Expand All @@ -353,7 +349,6 @@ where
+ scalar_len * (self.l0.len() + self.l_last.len() + self.l_active_row.len())
+ polynomial_slice_byte_length(&self.fixed_values)
+ polynomial_slice_byte_length(&self.fixed_polys)
+ polynomial_slice_byte_length(&self.fixed_cosets)
+ self.permutation.bytes_length()
}
}
Expand All @@ -379,7 +374,6 @@ where
self.l_active_row.write(writer, format)?;
write_polynomial_slice(&self.fixed_values, writer, format)?;
write_polynomial_slice(&self.fixed_polys, writer, format)?;
write_polynomial_slice(&self.fixed_cosets, writer, format)?;
self.permutation.write(writer, format)?;
Ok(())
}
Expand Down Expand Up @@ -411,7 +405,6 @@ where
let l_active_row = Polynomial::read(reader, format)?;
let fixed_values = read_polynomial_vec(reader, format)?;
let fixed_polys = read_polynomial_vec(reader, format)?;
let fixed_cosets = read_polynomial_vec(reader, format)?;
let permutation = permutation::ProvingKey::read(reader, format)?;
let ev = Evaluator::new(vk.cs());
Ok(Self {
Expand All @@ -421,7 +414,6 @@ where
l_active_row,
fixed_values,
fixed_polys,
fixed_cosets,
permutation,
ev,
})
Expand Down
Loading

0 comments on commit 5f0ba9d

Please sign in to comment.