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 Mar 2, 2024
1 parent 89e1ebf commit 08fe3e4
Show file tree
Hide file tree
Showing 9 changed files with 1,181 additions and 472 deletions.
17 changes: 4 additions & 13 deletions halo2_backend/src/plonk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +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::transcript::{ChallengeScalar, EncodedChallenge, Transcript};
use crate::poly::{Coeff, EvaluationDomain, LagrangeCoeff, PinnedEvaluationDomain, Polynomial};
use evaluation::Evaluator;
use halo2_common::plonk::{Circuit, ConstraintSystem, PinnedConstraintSystem};
use halo2_common::SerdeFormat;
Expand Down Expand Up @@ -323,12 +319,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 +348,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 +373,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 +404,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 +413,6 @@ where
l_active_row,
fixed_values,
fixed_polys,
fixed_cosets,
permutation,
ev,
})
Expand Down
Loading

0 comments on commit 08fe3e4

Please sign in to comment.