Skip to content

Commit

Permalink
Renames + ordering fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dlubarov committed Jan 17, 2024
1 parent 9a58428 commit 9bfe764
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions machine/src/__internal/debug_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ where
type Var = SC::Val;
type M = TwoRowMatrixView<'a, SC::Val>;

fn main(&self) -> Self::M {
self.main
}

fn is_first_row(&self) -> Self::Expr {
self.is_first_row
}
Expand All @@ -42,10 +46,6 @@ where
}
}

fn main(&self) -> Self::M {
self.main
}

fn assert_zero<I: Into<Self::Expr>>(&mut self, x: I) {
assert_eq!(
x.into(),
Expand All @@ -71,8 +71,8 @@ where
SC: StarkConfig,
{
type EF = SC::Challenge;
type VarEF = SC::Challenge;
type ExprEF = SC::Challenge;
type VarEF = SC::Challenge;
type MP = TwoRowMatrixView<'a, SC::Challenge>;

fn permutation(&self) -> Self::MP {
Expand Down
24 changes: 12 additions & 12 deletions machine/src/__internal/folding_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ use crate::{Machine, ValidaAirBuilder};
use p3_air::{AirBuilder, PairBuilder, PermutationAirBuilder, TwoRowMatrixView};
use valida_machine::config::StarkConfig;

pub struct ConstraintFolder<'a, M: Machine<SC::Val>, SC: StarkConfig> {
pub struct ProverConstraintFolder<'a, M: Machine<SC::Val>, SC: StarkConfig> {
pub(crate) machine: &'a M,
pub(crate) main: TwoRowMatrixView<'a, SC::Val>,
pub(crate) preprocessed: TwoRowMatrixView<'a, SC::Val>,
pub(crate) perm: TwoRowMatrixView<'a, SC::Challenge>,
pub(crate) rand_elems: &'a [SC::Challenge],
pub(crate) perm_challenges: &'a [SC::Challenge],
pub(crate) is_first_row: SC::Val,
pub(crate) is_last_row: SC::Val,
pub(crate) is_transition: SC::Val,
}

impl<'a, M, SC> AirBuilder for ConstraintFolder<'a, M, SC>
impl<'a, M, SC> AirBuilder for ProverConstraintFolder<'a, M, SC>
where
M: Machine<SC::Val>,
SC: StarkConfig,
Expand All @@ -23,6 +23,10 @@ where
type Var = SC::Val; // TODO: PackedVal
type M = TwoRowMatrixView<'a, SC::Val>; // TODO: PackedVal

fn main(&self) -> Self::M {
self.main
}

fn is_first_row(&self) -> Self::Expr {
self.is_first_row
}
Expand All @@ -39,16 +43,12 @@ where
}
}

fn main(&self) -> Self::M {
self.main
}

fn assert_zero<I: Into<Self::Expr>>(&mut self, _x: I) {
// TODO
}
}

impl<'a, M, SC> PairBuilder for ConstraintFolder<'a, M, SC>
impl<'a, M, SC> PairBuilder for ProverConstraintFolder<'a, M, SC>
where
M: Machine<SC::Val>,
SC: StarkConfig,
Expand All @@ -58,14 +58,14 @@ where
}
}

impl<'a, M, SC> PermutationAirBuilder for ConstraintFolder<'a, M, SC>
impl<'a, M, SC> PermutationAirBuilder for ProverConstraintFolder<'a, M, SC>
where
M: Machine<SC::Val>,
SC: StarkConfig,
{
type EF = SC::Challenge;
type VarEF = SC::Challenge;
type ExprEF = SC::Challenge;
type VarEF = SC::Challenge;
type MP = TwoRowMatrixView<'a, SC::Challenge>; // TODO: packed challenge?

fn permutation(&self) -> Self::MP {
Expand All @@ -74,11 +74,11 @@ where

fn permutation_randomness(&self) -> &[Self::EF] {
// TODO: implement
self.rand_elems
self.perm_challenges
}
}

impl<'a, M, SC> ValidaAirBuilder for ConstraintFolder<'a, M, SC>
impl<'a, M, SC> ValidaAirBuilder for ProverConstraintFolder<'a, M, SC>
where
M: Machine<SC::Val>,
SC: StarkConfig,
Expand Down
4 changes: 2 additions & 2 deletions machine/src/chip.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Machine;
use crate::__internal::{ConstraintFolder, DebugConstraintBuilder};
use crate::__internal::{DebugConstraintBuilder, ProverConstraintFolder};
use alloc::vec;
use alloc::vec::Vec;
use valida_util::batch_multiplicative_inverse;
Expand All @@ -10,7 +10,7 @@ use p3_field::{AbstractExtensionField, AbstractField, ExtensionField, Field, Pow
use p3_matrix::{dense::RowMajorMatrix, Matrix, MatrixRowSlices};

pub trait Chip<M: Machine<SC::Val>, SC: StarkConfig>:
for<'a> Air<ConstraintFolder<'a, M, SC>> + for<'a> Air<DebugConstraintBuilder<'a, M, SC>>
for<'a> Air<ProverConstraintFolder<'a, M, SC>> + for<'a> Air<DebugConstraintBuilder<'a, M, SC>>
{
/// Generate the main trace for the chip given the provided machine.
fn generate_trace(&self, machine: &M) -> RowMajorMatrix<SC::Val>;
Expand Down

0 comments on commit 9bfe764

Please sign in to comment.