Skip to content

Commit

Permalink
refactor: public NUM_*_CONSTRAINTS constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Mar 11, 2024
1 parent 863e3b8 commit abd15be
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 137 deletions.
4 changes: 2 additions & 2 deletions triton-vm/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,7 @@ pub(crate) mod tests {
use crate::table::cross_table_argument::CrossTableArg;
use crate::table::cross_table_argument::EvalArg;
use crate::table::cross_table_argument::GrandCrossTableArg;
use crate::table::extension_table;
use crate::table::extension_table::Evaluable;
use crate::table::extension_table::Quotientable;
use crate::table::hash_table;
Expand All @@ -1116,7 +1117,6 @@ pub(crate) mod tests {
use crate::table::jump_stack_table::ExtJumpStackTable;
use crate::table::lookup_table;
use crate::table::lookup_table::ExtLookupTable;
use crate::table::master_table::all_degrees_with_origin;
use crate::table::master_table::MasterExtTable;
use crate::table::master_table::TableId::LookupTable;
use crate::table::master_table::TableId::ProcessorTable;
Expand Down Expand Up @@ -1377,7 +1377,7 @@ pub(crate) mod tests {
let padded_height = 2;
let num_trace_randomizers = 2;
let interpolant_degree = interpolant_degree(padded_height, num_trace_randomizers);
for deg in all_degrees_with_origin(interpolant_degree, padded_height) {
for deg in extension_table::all_degrees_with_origin(interpolant_degree, padded_height) {
println!("{deg}");
}
}
Expand Down
103 changes: 101 additions & 2 deletions triton-vm/src/table/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,119 @@
//! Run `cargo run --bin constraint-evaluation-generator`
//! to fill in this file with optimized constraints.

use ndarray::ArrayView1;
use twenty_first::prelude::BFieldElement;
use twenty_first::prelude::XFieldElement;
use twenty_first::shared_math::mpolynomial::Degree;
use crate::table::challenges::Challenges;

use crate::table::extension_table::Evaluable;
use crate::table::extension_table::Quotientable;
use crate::table::master_table::MasterExtTable;

impl Evaluable<BFieldElement> for MasterExtTable {}
pub(crate) const ERROR_MESSAGE_GENERATE_CONSTRAINTS: &str =
"Constraints must be in place. Run: `cargo run --bin constraint-evaluation-generator`";
const ERROR_MESSAGE_GENERATE_DEGREE_BOUNDS: &str =
"Degree bounds must be in place. Run: `cargo run --bin constraint-evaluation-generator`";

impl Evaluable<XFieldElement> for MasterExtTable {}
impl Evaluable<BFieldElement> for MasterExtTable {
fn evaluate_initial_constraints(
_: ArrayView1<BFieldElement>,
_: ArrayView1<XFieldElement>,
_: &Challenges,
) -> Vec<XFieldElement> {
panic!("{ERROR_MESSAGE_GENERATE_CONSTRAINTS}")
}

fn evaluate_consistency_constraints(
_: ArrayView1<BFieldElement>,
_: ArrayView1<XFieldElement>,
_: &Challenges,
) -> Vec<XFieldElement> {
panic!("{ERROR_MESSAGE_GENERATE_CONSTRAINTS}")
}

fn evaluate_transition_constraints(
_: ArrayView1<BFieldElement>,
_: ArrayView1<XFieldElement>,
_: ArrayView1<BFieldElement>,
_: ArrayView1<XFieldElement>,
_: &Challenges,
) -> Vec<XFieldElement> {
panic!("{ERROR_MESSAGE_GENERATE_CONSTRAINTS}")
}

fn evaluate_terminal_constraints(
_: ArrayView1<BFieldElement>,
_: ArrayView1<XFieldElement>,
_: &Challenges,
) -> Vec<XFieldElement> {
panic!("{ERROR_MESSAGE_GENERATE_CONSTRAINTS}")
}
}

impl Evaluable<XFieldElement> for MasterExtTable {
fn evaluate_initial_constraints(
_: ArrayView1<XFieldElement>,
_: ArrayView1<XFieldElement>,
_: &Challenges,
) -> Vec<XFieldElement> {
panic!("{ERROR_MESSAGE_GENERATE_CONSTRAINTS}")
}

fn evaluate_consistency_constraints(
_: ArrayView1<XFieldElement>,
_: ArrayView1<XFieldElement>,
_: &Challenges,
) -> Vec<XFieldElement> {
panic!("{ERROR_MESSAGE_GENERATE_CONSTRAINTS}")
}

fn evaluate_transition_constraints(
_: ArrayView1<XFieldElement>,
_: ArrayView1<XFieldElement>,
_: ArrayView1<XFieldElement>,
_: ArrayView1<XFieldElement>,
_: &Challenges,
) -> Vec<XFieldElement> {
panic!("{ERROR_MESSAGE_GENERATE_CONSTRAINTS}")
}

fn evaluate_terminal_constraints(
_: ArrayView1<XFieldElement>,
_: ArrayView1<XFieldElement>,
_: &Challenges,
) -> Vec<XFieldElement> {
panic!("{ERROR_MESSAGE_GENERATE_CONSTRAINTS}")
}
}

impl Quotientable for MasterExtTable {
const NUM_INITIAL_CONSTRAINTS: usize = 0;
const NUM_CONSISTENCY_CONSTRAINTS: usize = 0;
const NUM_TRANSITION_CONSTRAINTS: usize = 0;
const NUM_TERMINAL_CONSTRAINTS: usize = 0;


fn initial_quotient_degree_bounds(_: Degree) -> Vec<Degree> {
panic!("{ERROR_MESSAGE_GENERATE_DEGREE_BOUNDS}")
}

fn consistency_quotient_degree_bounds(
_: Degree,
_: usize,
) -> Vec<Degree> {
panic!("{ERROR_MESSAGE_GENERATE_DEGREE_BOUNDS}")
}

fn transition_quotient_degree_bounds(
_: Degree,
_: usize,
) -> Vec<Degree> {
panic!("{ERROR_MESSAGE_GENERATE_DEGREE_BOUNDS}")
}

fn terminal_quotient_degree_bounds(_: Degree) -> Vec<Degree> {
panic!("{ERROR_MESSAGE_GENERATE_DEGREE_BOUNDS}")
}
}
Loading

0 comments on commit abd15be

Please sign in to comment.