diff --git a/triton-vm/src/stark.rs b/triton-vm/src/stark.rs index dc4b1e5e4..84e50649f 100644 --- a/triton-vm/src/stark.rs +++ b/triton-vm/src/stark.rs @@ -186,11 +186,8 @@ impl Stark { prof_stop!(maybe_profiler, "Fiat-Shamir 1"); prof_start!(maybe_profiler, "extend"); - let ext_trace_tables = ExtTableCollection::extend_tables( - &base_trace_tables, - &extension_challenges, - self.parameters.num_trace_randomizers, - ); + let ext_trace_tables = + ExtTableCollection::extend_tables(&base_trace_tables, &extension_challenges); prof_stop!(maybe_profiler, "extend"); prof_start!(maybe_profiler, "dual LDE 2"); @@ -672,12 +669,7 @@ impl Stark { prof_start!(maybe_profiler, "degree bounds"); prof_start!(maybe_profiler, "generate tables"); - let ext_table_collection = ExtTableCollection::for_verifier( - self.parameters.num_trace_randomizers, - padded_height, - &extension_challenges, - maybe_profiler, - ); + let ext_table_collection = ExtTableCollection::for_verifier(padded_height, maybe_profiler); prof_stop!(maybe_profiler, "generate tables"); prof_start!(maybe_profiler, "base"); @@ -1208,11 +1200,7 @@ pub(crate) mod triton_stark_tests { parse_simulate_pad(code, stdin, secret_in); let dummy_challenges = AllChallenges::placeholder(); - let ext_tables = ExtTableCollection::extend_tables( - &base_tables, - &dummy_challenges, - num_trace_randomizers, - ); + let ext_tables = ExtTableCollection::extend_tables(&base_tables, &dummy_challenges); ( stdout, @@ -1457,15 +1445,11 @@ pub(crate) mod triton_stark_tests { #[test] fn extend_does_not_change_base_table() { - let (base_tables, _, num_trace_randomizers, _) = + let (base_tables, _, _, _) = parse_simulate_pad(sample_programs::FIBONACCI_LT, vec![], vec![]); let dummy_challenges = AllChallenges::placeholder(); - let ext_tables = ExtTableCollection::extend_tables( - &base_tables, - &dummy_challenges, - num_trace_randomizers, - ); + let ext_tables = ExtTableCollection::extend_tables(&base_tables, &dummy_challenges); for (base_table, extension_table) in base_tables.into_iter().zip(ext_tables.into_iter()) { for column in 0..base_table.base_width() { diff --git a/triton-vm/src/table/base_table.rs b/triton-vm/src/table/base_table.rs index 531242125..da1f63b6a 100644 --- a/triton-vm/src/table/base_table.rs +++ b/triton-vm/src/table/base_table.rs @@ -24,18 +24,6 @@ pub struct Table { /// The name of the table. Mostly for debugging purpose. pub name: String, - - /// AIR constraints, to be populated upon extension - pub(crate) initial_constraints: Option>>, - pub(crate) consistency_constraints: Option>>, - pub(crate) transition_constraints: Option>>, - pub(crate) terminal_constraints: Option>>, - - /// quotient degrees, to be populated upon extension - pub(crate) initial_quotient_degree_bounds: Option>, - pub(crate) consistency_quotient_degree_bounds: Option>, - pub(crate) transition_quotient_degree_bounds: Option>, - pub(crate) terminal_quotient_degree_bounds: Option>, } #[allow(clippy::too_many_arguments)] @@ -46,14 +34,6 @@ impl Table { full_width, matrix, name, - initial_constraints: None, - consistency_constraints: None, - transition_constraints: None, - terminal_constraints: None, - initial_quotient_degree_bounds: None, - consistency_quotient_degree_bounds: None, - transition_quotient_degree_bounds: None, - terminal_quotient_degree_bounds: None, } } @@ -201,45 +181,6 @@ pub trait Extendable: TableLike { full_width, ) } - - #[allow(clippy::too_many_arguments)] - fn extension( - &self, - extended_matrix: Vec>, - interpolant_degree: Degree, - padded_height: usize, - initial_constraints: Vec>, - consistency_constraints: Vec>, - transition_constraints: Vec>, - terminal_constraints: Vec>, - ) -> Table { - let bqdb = - self.get_initial_quotient_degree_bounds(&initial_constraints, interpolant_degree); - let cqdb = self.get_consistency_quotient_degree_bounds( - &consistency_constraints, - interpolant_degree, - padded_height, - ); - let tqdb = self.get_transition_quotient_degree_bounds( - &transition_constraints, - interpolant_degree, - padded_height, - ); - let termqdb = - self.get_terminal_quotient_degree_bounds(&terminal_constraints, interpolant_degree); - let new_table = self.new_from_lifted_matrix(extended_matrix); - Table { - initial_constraints: Some(initial_constraints), - consistency_constraints: Some(consistency_constraints), - transition_constraints: Some(transition_constraints), - terminal_constraints: Some(terminal_constraints), - initial_quotient_degree_bounds: Some(bqdb), - consistency_quotient_degree_bounds: Some(cqdb), - transition_quotient_degree_bounds: Some(tqdb), - terminal_quotient_degree_bounds: Some(termqdb), - ..new_table - } - } } fn disjoint_domain(domain_length: usize, disjoint_domain: &[FF]) -> Vec { diff --git a/triton-vm/src/table/constraints/hash_table_constraints.rs b/triton-vm/src/table/constraints/hash_table_constraints.rs index f9e4d45a2..a1466cbe3 100644 --- a/triton-vm/src/table/constraints/hash_table_constraints.rs +++ b/triton-vm/src/table/constraints/hash_table_constraints.rs @@ -1,3 +1,7 @@ +use twenty_first::shared_math::mpolynomial::Degree; +use twenty_first::shared_math::x_field_element::XFieldElement; + +use crate::table::challenges::AllChallenges; use crate::table::extension_table::Evaluable; use crate::table::extension_table::Quotientable; use crate::table::hash_table::ExtHashTable; @@ -5,6 +9,87 @@ use crate::table::hash_table::ExtHashTable; // This file is a placeholder for auto-generated code // Run `cargo run --bin constraint-evaluation-generator` // to fill in this file with optimized constraints. -impl Evaluable for ExtHashTable {} +impl Evaluable for ExtHashTable { + fn evaluate_initial_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_consistency_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_transition_constraints( + &self, + _current_row: &[XFieldElement], + _next_row: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_terminal_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} + +impl Quotientable for ExtHashTable { + fn get_initial_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_consistency_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_transition_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } -impl Quotientable for ExtHashTable {} + fn get_terminal_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} diff --git a/triton-vm/src/table/constraints/instruction_table_constraints.rs b/triton-vm/src/table/constraints/instruction_table_constraints.rs index 1906c9b16..727ffa529 100644 --- a/triton-vm/src/table/constraints/instruction_table_constraints.rs +++ b/triton-vm/src/table/constraints/instruction_table_constraints.rs @@ -1,3 +1,7 @@ +use twenty_first::shared_math::mpolynomial::Degree; +use twenty_first::shared_math::x_field_element::XFieldElement; + +use crate::table::challenges::AllChallenges; use crate::table::extension_table::Evaluable; use crate::table::extension_table::Quotientable; use crate::table::instruction_table::ExtInstructionTable; @@ -5,6 +9,87 @@ use crate::table::instruction_table::ExtInstructionTable; // This file is a placeholder for auto-generated code // Run `cargo run --bin constraint-evaluation-generator` // to fill in this file with optimized constraints. -impl Evaluable for ExtInstructionTable {} +impl Evaluable for ExtInstructionTable { + fn evaluate_initial_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_consistency_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_transition_constraints( + &self, + _current_row: &[XFieldElement], + _next_row: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_terminal_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} + +impl Quotientable for ExtInstructionTable { + fn get_initial_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_consistency_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_transition_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } -impl Quotientable for ExtInstructionTable {} + fn get_terminal_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} diff --git a/triton-vm/src/table/constraints/jump_stack_table_constraints.rs b/triton-vm/src/table/constraints/jump_stack_table_constraints.rs index 723eb8ddb..16d9fec54 100644 --- a/triton-vm/src/table/constraints/jump_stack_table_constraints.rs +++ b/triton-vm/src/table/constraints/jump_stack_table_constraints.rs @@ -1,3 +1,7 @@ +use twenty_first::shared_math::mpolynomial::Degree; +use twenty_first::shared_math::x_field_element::XFieldElement; + +use crate::table::challenges::AllChallenges; use crate::table::extension_table::Evaluable; use crate::table::extension_table::Quotientable; use crate::table::jump_stack_table::ExtJumpStackTable; @@ -5,6 +9,87 @@ use crate::table::jump_stack_table::ExtJumpStackTable; // This file is a placeholder for auto-generated code // Run `cargo run --bin constraint-evaluation-generator` // to fill in this file with optimized constraints. -impl Evaluable for ExtJumpStackTable {} +impl Evaluable for ExtJumpStackTable { + fn evaluate_initial_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_consistency_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_transition_constraints( + &self, + _current_row: &[XFieldElement], + _next_row: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_terminal_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} + +impl Quotientable for ExtJumpStackTable { + fn get_initial_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_consistency_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_transition_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } -impl Quotientable for ExtJumpStackTable {} + fn get_terminal_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} diff --git a/triton-vm/src/table/constraints/op_stack_table_constraints.rs b/triton-vm/src/table/constraints/op_stack_table_constraints.rs index f33f0de14..4b161b5d7 100644 --- a/triton-vm/src/table/constraints/op_stack_table_constraints.rs +++ b/triton-vm/src/table/constraints/op_stack_table_constraints.rs @@ -1,3 +1,7 @@ +use twenty_first::shared_math::mpolynomial::Degree; +use twenty_first::shared_math::x_field_element::XFieldElement; + +use crate::table::challenges::AllChallenges; use crate::table::extension_table::Evaluable; use crate::table::extension_table::Quotientable; use crate::table::op_stack_table::ExtOpStackTable; @@ -5,6 +9,87 @@ use crate::table::op_stack_table::ExtOpStackTable; // This file is a placeholder for auto-generated code // Run `cargo run --bin constraint-evaluation-generator` // to fill in this file with optimized constraints. -impl Evaluable for ExtOpStackTable {} +impl Evaluable for ExtOpStackTable { + fn evaluate_initial_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_consistency_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_transition_constraints( + &self, + _current_row: &[XFieldElement], + _next_row: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_terminal_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} + +impl Quotientable for ExtOpStackTable { + fn get_initial_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_consistency_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_transition_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } -impl Quotientable for ExtOpStackTable {} + fn get_terminal_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} diff --git a/triton-vm/src/table/constraints/processor_table_constraints.rs b/triton-vm/src/table/constraints/processor_table_constraints.rs index e75d04535..1b9a1f882 100644 --- a/triton-vm/src/table/constraints/processor_table_constraints.rs +++ b/triton-vm/src/table/constraints/processor_table_constraints.rs @@ -1,3 +1,7 @@ +use twenty_first::shared_math::mpolynomial::Degree; +use twenty_first::shared_math::x_field_element::XFieldElement; + +use crate::table::challenges::AllChallenges; use crate::table::extension_table::Evaluable; use crate::table::extension_table::Quotientable; use crate::table::processor_table::ExtProcessorTable; @@ -5,6 +9,87 @@ use crate::table::processor_table::ExtProcessorTable; // This file is a placeholder for auto-generated code // Run `cargo run --bin constraint-evaluation-generator` // to fill in this file with optimized constraints. -impl Evaluable for ExtProcessorTable {} +impl Evaluable for ExtProcessorTable { + fn evaluate_initial_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_consistency_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_transition_constraints( + &self, + _current_row: &[XFieldElement], + _next_row: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_terminal_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} + +impl Quotientable for ExtProcessorTable { + fn get_initial_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_consistency_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_transition_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } -impl Quotientable for ExtProcessorTable {} + fn get_terminal_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} diff --git a/triton-vm/src/table/constraints/program_table_constraints.rs b/triton-vm/src/table/constraints/program_table_constraints.rs index fe2f2b095..01f35ed9b 100644 --- a/triton-vm/src/table/constraints/program_table_constraints.rs +++ b/triton-vm/src/table/constraints/program_table_constraints.rs @@ -1,3 +1,7 @@ +use twenty_first::shared_math::mpolynomial::Degree; +use twenty_first::shared_math::x_field_element::XFieldElement; + +use crate::table::challenges::AllChallenges; use crate::table::extension_table::Evaluable; use crate::table::extension_table::Quotientable; use crate::table::program_table::ExtProgramTable; @@ -5,6 +9,87 @@ use crate::table::program_table::ExtProgramTable; // This file is a placeholder for auto-generated code // Run `cargo run --bin constraint-evaluation-generator` // to fill in this file with optimized constraints. -impl Evaluable for ExtProgramTable {} +impl Evaluable for ExtProgramTable { + fn evaluate_initial_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_consistency_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_transition_constraints( + &self, + _current_row: &[XFieldElement], + _next_row: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_terminal_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} + +impl Quotientable for ExtProgramTable { + fn get_initial_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_consistency_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_transition_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } -impl Quotientable for ExtProgramTable {} + fn get_terminal_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} diff --git a/triton-vm/src/table/constraints/ram_table_constraints.rs b/triton-vm/src/table/constraints/ram_table_constraints.rs index d9ee4eb49..6ce559ffe 100644 --- a/triton-vm/src/table/constraints/ram_table_constraints.rs +++ b/triton-vm/src/table/constraints/ram_table_constraints.rs @@ -1,3 +1,7 @@ +use twenty_first::shared_math::mpolynomial::Degree; +use twenty_first::shared_math::x_field_element::XFieldElement; + +use crate::table::challenges::AllChallenges; use crate::table::extension_table::Evaluable; use crate::table::extension_table::Quotientable; use crate::table::ram_table::ExtRamTable; @@ -5,6 +9,87 @@ use crate::table::ram_table::ExtRamTable; // This file is a placeholder for auto-generated code // Run `cargo run --bin constraint-evaluation-generator` // to fill in this file with optimized constraints. -impl Evaluable for ExtRamTable {} +impl Evaluable for ExtRamTable { + fn evaluate_initial_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_consistency_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_transition_constraints( + &self, + _current_row: &[XFieldElement], + _next_row: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn evaluate_terminal_constraints( + &self, + _evaluation_point: &[XFieldElement], + _challenges: &AllChallenges, + ) -> Vec { + panic!( + "Constraints must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} + +impl Quotientable for ExtRamTable { + fn get_initial_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_consistency_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } + + fn get_transition_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } -impl Quotientable for ExtRamTable {} + fn get_terminal_quotient_degree_bounds( + &self, + _padded_height: usize, + _num_trace_randomizers: usize, + ) -> Vec { + panic!( + "Degree bounds must be in place. Run `cargo run --bin constraint-evaluation-generator`." + ) + } +} diff --git a/triton-vm/src/table/extension_table.rs b/triton-vm/src/table/extension_table.rs index db79e1353..43042b720 100644 --- a/triton-vm/src/table/extension_table.rs +++ b/triton-vm/src/table/extension_table.rs @@ -46,75 +46,38 @@ pub trait ExtensionTable: TableLike + Sync { } pub trait Evaluable: ExtensionTable { - /// Evaluate initial constraints if they are set. This default impl - /// can be overridden by running the `constraint-evaluation-generator`. + /// The code for this method must be generated by running + /// `OUTPUT_RUST_SOURCE_CODE=1 cargo run --bin constraint-evaluation-generator` fn evaluate_initial_constraints( &self, evaluation_point: &[XFieldElement], _challenges: &AllChallenges, - ) -> Vec { - if let Some(initial_constraints) = &self.inherited_table().initial_constraints { - initial_constraints - .iter() - .map(|ic| ic.evaluate(evaluation_point)) - .collect() - } else { - panic!("{} does not have initial constraints!", &self.name()); - } - } + ) -> Vec; - /// Evaluate consistency constraints if they are set. This default impl - /// can be overridden by running the `constraint-evaluation-generator`. + /// The code for this method must be generated by running + /// `OUTPUT_RUST_SOURCE_CODE=1 cargo run --bin constraint-evaluation-generator` fn evaluate_consistency_constraints( &self, evaluation_point: &[XFieldElement], _challenges: &AllChallenges, - ) -> Vec { - if let Some(consistency_constraints) = &self.inherited_table().consistency_constraints { - consistency_constraints - .iter() - .map(|cc| cc.evaluate(evaluation_point)) - .collect() - } else { - panic!("{} does not have consistency constraints!", &self.name()); - } - } + ) -> Vec; - /// Evaluate transition constraints if they are set. This default impl - /// can be overridden by running the `constraint-evaluation-generator`. + /// The code for this method must be generated by running + /// `OUTPUT_RUST_SOURCE_CODE=1 cargo run --bin constraint-evaluation-generator` fn evaluate_transition_constraints( &self, current_row: &[XFieldElement], next_row: &[XFieldElement], _challenges: &AllChallenges, - ) -> Vec { - let evaluation_point = vec![current_row, next_row].concat(); - if let Some(transition_constraints) = &self.inherited_table().transition_constraints { - transition_constraints - .iter() - .map(|tc| tc.evaluate(&evaluation_point)) - .collect() - } else { - panic!("{} does not have transition constraints!", &self.name()); - } - } + ) -> Vec; - /// Evaluate terminal constraints if they are set. This default impl - /// can be overridden by running the `constraint-evaluation-generator`. + /// The code for this method must be generated by running + /// `OUTPUT_RUST_SOURCE_CODE=1 cargo run --bin constraint-evaluation-generator` fn evaluate_terminal_constraints( &self, evaluation_point: &[XFieldElement], _challenges: &AllChallenges, - ) -> Vec { - if let Some(terminal_constraints) = &self.inherited_table().terminal_constraints { - terminal_constraints - .iter() - .map(|termc| termc.evaluate(evaluation_point)) - .collect() - } else { - panic!("{} does not have terminal constraints!", &self.name()); - } - } + ) -> Vec; } pub trait Quotientable: ExtensionTable + Evaluable { @@ -440,73 +403,25 @@ pub trait Quotientable: ExtensionTable + Evaluable { &self, padded_height: usize, num_trace_randomizers: usize, - ) -> Vec { - if let Some(db) = &self.inherited_table().initial_quotient_degree_bounds { - db.to_owned() - } else { - let interpolant_degree = interpolant_degree(padded_height, num_trace_randomizers); - let max_degrees = vec![interpolant_degree; self.full_width()]; - let zerofier_degree = 1; - self.dynamic_initial_constraints(&AllChallenges::placeholder()) - .iter() - .map(|air| air.symbolic_degree_bound(&max_degrees) - zerofier_degree) - .collect() - } - } + ) -> Vec; fn get_consistency_quotient_degree_bounds( &self, padded_height: usize, num_trace_randomizers: usize, - ) -> Vec { - if let Some(db) = &self.inherited_table().consistency_quotient_degree_bounds { - db.to_owned() - } else { - let interpolant_degree = interpolant_degree(padded_height, num_trace_randomizers); - let max_degrees = vec![interpolant_degree; self.full_width()]; - let zerofier_degree = padded_height as Degree; - self.dynamic_consistency_constraints(&AllChallenges::placeholder()) - .iter() - .map(|air| air.symbolic_degree_bound(&max_degrees) - zerofier_degree) - .collect() - } - } + ) -> Vec; fn get_transition_quotient_degree_bounds( &self, padded_height: usize, num_trace_randomizers: usize, - ) -> Vec { - if let Some(db) = &self.inherited_table().transition_quotient_degree_bounds { - db.to_owned() - } else { - let interpolant_degree = interpolant_degree(padded_height, num_trace_randomizers); - let max_degrees = vec![interpolant_degree; 2 * self.full_width()]; - let zerofier_degree = padded_height as Degree - 1; - self.dynamic_transition_constraints(&AllChallenges::placeholder()) - .iter() - .map(|air| air.symbolic_degree_bound(&max_degrees) - zerofier_degree) - .collect() - } - } + ) -> Vec; fn get_terminal_quotient_degree_bounds( &self, padded_height: usize, num_trace_randomizers: usize, - ) -> Vec { - if let Some(db) = &self.inherited_table().terminal_quotient_degree_bounds { - db.to_owned() - } else { - let interpolant_degree = interpolant_degree(padded_height, num_trace_randomizers); - let max_degrees = vec![interpolant_degree; self.full_width()]; - let zerofier_degree = 1 as Degree; - self.dynamic_terminal_constraints(&AllChallenges::placeholder()) - .iter() - .map(|air| air.symbolic_degree_bound(&max_degrees) - zerofier_degree) - .collect() - } - } + ) -> Vec; } pub trait QuotientableExtensionTable: ExtensionTable + Quotientable {} diff --git a/triton-vm/src/table/hash_table.rs b/triton-vm/src/table/hash_table.rs index ac88e197b..ea889fc00 100644 --- a/triton-vm/src/table/hash_table.rs +++ b/triton-vm/src/table/hash_table.rs @@ -3,7 +3,7 @@ use num_traits::Zero; use strum::EnumCount; use strum_macros::{Display, EnumCount as EnumCountMacro, EnumIter}; use twenty_first::shared_math::b_field_element::BFieldElement; -use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; +use twenty_first::shared_math::mpolynomial::MPolynomial; use twenty_first::shared_math::rescue_prime_regular::DIGEST_LENGTH; use twenty_first::shared_math::rescue_prime_regular::{ ALPHA, MDS, MDS_INV, NUM_ROUNDS, ROUND_CONSTANTS, STATE_SIZE, @@ -528,11 +528,7 @@ impl HashTable { ) } - pub fn extend( - &self, - challenges: &HashTableChallenges, - interpolant_degree: Degree, - ) -> ExtHashTable { + pub fn extend(&self, challenges: &HashTableChallenges) -> ExtHashTable { let mut from_processor_running_evaluation = EvalArg::default_initial(); let mut to_processor_running_evaluation = EvalArg::default_initial(); @@ -618,40 +614,19 @@ impl HashTable { } assert_eq!(self.data().len(), extension_matrix.len()); - let padded_height = extension_matrix.len(); - let extension_table = self.extension( - extension_matrix, - interpolant_degree, - padded_height, - ExtHashTable::ext_initial_constraints(challenges), - ExtHashTable::ext_consistency_constraints(challenges), - ExtHashTable::ext_transition_constraints(challenges), - ExtHashTable::ext_terminal_constraints(challenges), - ); + let extension_table = self.new_from_lifted_matrix(extension_matrix); ExtHashTable { inherited_table: extension_table, } } - pub fn for_verifier( - interpolant_degree: Degree, - padded_height: usize, - all_challenges: &AllChallenges, - ) -> ExtHashTable { + pub fn for_verifier() -> ExtHashTable { let inherited_table = Table::new(BASE_WIDTH, FULL_WIDTH, vec![], "ExtHashTable".to_string()); let base_table = Self { inherited_table }; let empty_matrix: Vec> = vec![]; - let extension_table = base_table.extension( - empty_matrix, - interpolant_degree, - padded_height, - ExtHashTable::ext_initial_constraints(&all_challenges.hash_table_challenges), - ExtHashTable::ext_consistency_constraints(&all_challenges.hash_table_challenges), - ExtHashTable::ext_transition_constraints(&all_challenges.hash_table_challenges), - ExtHashTable::ext_terminal_constraints(&all_challenges.hash_table_challenges), - ); + let extension_table = base_table.new_from_lifted_matrix(empty_matrix); ExtHashTable { inherited_table: extension_table, @@ -800,10 +775,7 @@ impl ExtensionTable for ExtHashTable { #[cfg(test)] mod constraint_tests { - use twenty_first::shared_math::other::roundup_npo2; - use crate::table::extension_table::Evaluable; - use crate::table::table_collection::interpolant_degree; use crate::vm::Program; use super::*; @@ -818,14 +790,10 @@ mod constraint_tests { panic!("Program execution failed: {e}"); } - let padded_height = roundup_npo2(aet.hash_matrix.len() as u64) as usize; - let num_trace_randomizers = 0; - let interpolant_degree = interpolant_degree(padded_height, num_trace_randomizers); - let challenges = AllChallenges::placeholder(); let ext_hash_table = HashTable::new_prover(aet.hash_matrix.iter().map(|r| r.to_vec()).collect()) - .extend(&challenges.hash_table_challenges, interpolant_degree); + .extend(&challenges.hash_table_challenges); for v in ext_hash_table.evaluate_initial_constraints(&ext_hash_table.data()[0], &challenges) { diff --git a/triton-vm/src/table/instruction_table.rs b/triton-vm/src/table/instruction_table.rs index e13e044ca..ae2dd9265 100644 --- a/triton-vm/src/table/instruction_table.rs +++ b/triton-vm/src/table/instruction_table.rs @@ -3,7 +3,7 @@ use num_traits::{One, Zero}; use strum::EnumCount; use strum_macros::{Display, EnumCount as EnumCountMacro, EnumIter}; use twenty_first::shared_math::b_field_element::BFieldElement; -use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; +use twenty_first::shared_math::mpolynomial::MPolynomial; use twenty_first::shared_math::x_field_element::XFieldElement; use InstructionTableChallengeId::*; @@ -377,11 +377,7 @@ impl InstructionTable { ) } - pub fn extend( - &self, - challenges: &InstructionTableChallenges, - interpolant_degree: Degree, - ) -> ExtInstructionTable { + pub fn extend(&self, challenges: &InstructionTableChallenges) -> ExtInstructionTable { let mut extension_matrix: Vec> = Vec::with_capacity(self.data().len()); let mut processor_table_running_product = PermArg::default_initial(); let mut program_table_running_evaluation = EvalArg::default_initial(); @@ -442,24 +438,11 @@ impl InstructionTable { } assert_eq!(self.data().len(), extension_matrix.len()); - let padded_height = extension_matrix.len(); - let inherited_table = self.extension( - extension_matrix, - interpolant_degree, - padded_height, - ExtInstructionTable::ext_initial_constraints(challenges), - ExtInstructionTable::ext_consistency_constraints(challenges), - ExtInstructionTable::ext_transition_constraints(challenges), - ExtInstructionTable::ext_terminal_constraints(challenges), - ); + let inherited_table = self.new_from_lifted_matrix(extension_matrix); ExtInstructionTable { inherited_table } } - pub fn for_verifier( - interpolant_degree: Degree, - padded_height: usize, - all_challenges: &AllChallenges, - ) -> ExtInstructionTable { + pub fn for_verifier() -> ExtInstructionTable { let inherited_table = Table::new( BASE_WIDTH, FULL_WIDTH, @@ -468,23 +451,7 @@ impl InstructionTable { ); let base_table = Self { inherited_table }; let empty_matrix: Vec> = vec![]; - let extension_table = base_table.extension( - empty_matrix, - interpolant_degree, - padded_height, - ExtInstructionTable::ext_initial_constraints( - &all_challenges.instruction_table_challenges, - ), - ExtInstructionTable::ext_consistency_constraints( - &all_challenges.instruction_table_challenges, - ), - ExtInstructionTable::ext_transition_constraints( - &all_challenges.instruction_table_challenges, - ), - ExtInstructionTable::ext_terminal_constraints( - &all_challenges.instruction_table_challenges, - ), - ); + let extension_table = base_table.new_from_lifted_matrix(empty_matrix); ExtInstructionTable { inherited_table: extension_table, diff --git a/triton-vm/src/table/jump_stack_table.rs b/triton-vm/src/table/jump_stack_table.rs index 3bdd629ce..1e67cfd57 100644 --- a/triton-vm/src/table/jump_stack_table.rs +++ b/triton-vm/src/table/jump_stack_table.rs @@ -3,7 +3,7 @@ use num_traits::One; use strum::EnumCount; use strum_macros::{Display, EnumCount as EnumCountMacro, EnumIter}; use twenty_first::shared_math::b_field_element::BFieldElement; -use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; +use twenty_first::shared_math::mpolynomial::MPolynomial; use twenty_first::shared_math::traits::Inverse; use twenty_first::shared_math::x_field_element::XFieldElement; @@ -357,11 +357,7 @@ impl JumpStackTable { ) } - pub fn extend( - &self, - challenges: &JumpStackTableChallenges, - interpolant_degree: Degree, - ) -> ExtJumpStackTable { + pub fn extend(&self, challenges: &JumpStackTableChallenges) -> ExtJumpStackTable { let mut extension_matrix: Vec> = Vec::with_capacity(self.data().len()); let mut running_product = PermArg::default_initial(); let mut all_clock_jump_differences_running_product = PermArg::default_initial(); @@ -417,24 +413,11 @@ impl JumpStackTable { } assert_eq!(self.data().len(), extension_matrix.len()); - let padded_height = extension_matrix.len(); - let inherited_table = self.extension( - extension_matrix, - interpolant_degree, - padded_height, - ExtJumpStackTable::ext_initial_constraints(challenges), - ExtJumpStackTable::ext_consistency_constraints(challenges), - ExtJumpStackTable::ext_transition_constraints(challenges), - ExtJumpStackTable::ext_terminal_constraints(challenges), - ); + let inherited_table = self.new_from_lifted_matrix(extension_matrix); ExtJumpStackTable { inherited_table } } - pub fn for_verifier( - interpolant_degree: Degree, - padded_height: usize, - all_challenges: &AllChallenges, - ) -> ExtJumpStackTable { + pub fn for_verifier() -> ExtJumpStackTable { let inherited_table = Table::new( BASE_WIDTH, FULL_WIDTH, @@ -443,21 +426,7 @@ impl JumpStackTable { ); let base_table = Self { inherited_table }; let empty_matrix: Vec> = vec![]; - let extension_table = base_table.extension( - empty_matrix, - interpolant_degree, - padded_height, - ExtJumpStackTable::ext_initial_constraints(&all_challenges.jump_stack_table_challenges), - ExtJumpStackTable::ext_consistency_constraints( - &all_challenges.jump_stack_table_challenges, - ), - ExtJumpStackTable::ext_transition_constraints( - &all_challenges.jump_stack_table_challenges, - ), - ExtJumpStackTable::ext_terminal_constraints( - &all_challenges.jump_stack_table_challenges, - ), - ); + let extension_table = base_table.new_from_lifted_matrix(empty_matrix); ExtJumpStackTable { inherited_table: extension_table, diff --git a/triton-vm/src/table/op_stack_table.rs b/triton-vm/src/table/op_stack_table.rs index e4dd1c69e..5afc8fbd3 100644 --- a/triton-vm/src/table/op_stack_table.rs +++ b/triton-vm/src/table/op_stack_table.rs @@ -3,7 +3,7 @@ use num_traits::One; use strum::EnumCount; use strum_macros::{Display, EnumCount as EnumCountMacro, EnumIter}; use twenty_first::shared_math::b_field_element::BFieldElement; -use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; +use twenty_first::shared_math::mpolynomial::MPolynomial; use twenty_first::shared_math::traits::Inverse; use twenty_first::shared_math::x_field_element::XFieldElement; @@ -332,11 +332,7 @@ impl OpStackTable { ) } - pub fn extend( - &self, - challenges: &OpStackTableChallenges, - interpolant_degree: Degree, - ) -> ExtOpStackTable { + pub fn extend(&self, challenges: &OpStackTableChallenges) -> ExtOpStackTable { let mut extension_matrix: Vec> = Vec::with_capacity(self.data().len()); let mut running_product = PermArg::default_initial(); let mut all_clock_jump_differences_running_product = PermArg::default_initial(); @@ -386,24 +382,11 @@ impl OpStackTable { } assert_eq!(self.data().len(), extension_matrix.len()); - let padded_height = extension_matrix.len(); - let inherited_table = self.extension( - extension_matrix, - interpolant_degree, - padded_height, - ExtOpStackTable::ext_initial_constraints(challenges), - ExtOpStackTable::ext_consistency_constraints(challenges), - ExtOpStackTable::ext_transition_constraints(challenges), - ExtOpStackTable::ext_terminal_constraints(challenges), - ); + let inherited_table = self.new_from_lifted_matrix(extension_matrix); ExtOpStackTable { inherited_table } } - pub fn for_verifier( - interpolant_degree: Degree, - padded_height: usize, - all_challenges: &AllChallenges, - ) -> ExtOpStackTable { + pub fn for_verifier() -> ExtOpStackTable { let inherited_table = Table::new( BASE_WIDTH, FULL_WIDTH, @@ -412,15 +395,7 @@ impl OpStackTable { ); let base_table = Self { inherited_table }; let empty_matrix: Vec> = vec![]; - let extension_table = base_table.extension( - empty_matrix, - interpolant_degree, - padded_height, - ExtOpStackTable::ext_initial_constraints(&all_challenges.op_stack_table_challenges), - ExtOpStackTable::ext_consistency_constraints(&all_challenges.op_stack_table_challenges), - ExtOpStackTable::ext_transition_constraints(&all_challenges.op_stack_table_challenges), - ExtOpStackTable::ext_terminal_constraints(&all_challenges.op_stack_table_challenges), - ); + let extension_table = base_table.new_from_lifted_matrix(empty_matrix); ExtOpStackTable { inherited_table: extension_table, diff --git a/triton-vm/src/table/processor_table.rs b/triton-vm/src/table/processor_table.rs index 295f00048..823891c3e 100644 --- a/triton-vm/src/table/processor_table.rs +++ b/triton-vm/src/table/processor_table.rs @@ -8,7 +8,7 @@ use num_traits::{One, Zero}; use strum::EnumCount; use strum_macros::{Display, EnumCount as EnumCountMacro, EnumIter}; use twenty_first::shared_math::b_field_element::BFieldElement; -use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; +use twenty_first::shared_math::mpolynomial::MPolynomial; use twenty_first::shared_math::x_field_element::XFieldElement; use ProcessorTableChallengeId::*; @@ -84,11 +84,7 @@ impl ProcessorTable { ) } - pub fn extend( - &self, - challenges: &ProcessorTableChallenges, - interpolant_degree: Degree, - ) -> ExtProcessorTable { + pub fn extend(&self, challenges: &ProcessorTableChallenges) -> ExtProcessorTable { let mut unique_clock_jump_differences = vec![]; let mut extension_matrix: Vec> = Vec::with_capacity(self.data().len()); @@ -316,24 +312,11 @@ impl ProcessorTable { } assert_eq!(self.data().len(), extension_matrix.len()); - let padded_height = extension_matrix.len(); - let inherited_table = self.extension( - extension_matrix, - interpolant_degree, - padded_height, - ExtProcessorTable::ext_initial_constraints(challenges), - ExtProcessorTable::ext_consistency_constraints(challenges), - ExtProcessorTable::ext_transition_constraints(challenges), - ExtProcessorTable::ext_terminal_constraints(challenges), - ); + let inherited_table = self.new_from_lifted_matrix(extension_matrix); ExtProcessorTable { inherited_table } } - pub fn for_verifier( - interpolant_degree: Degree, - padded_height: usize, - all_challenges: &AllChallenges, - ) -> ExtProcessorTable { + pub fn for_verifier() -> ExtProcessorTable { let inherited_table = Table::new( BASE_WIDTH, FULL_WIDTH, @@ -342,19 +325,7 @@ impl ProcessorTable { ); let base_table = Self { inherited_table }; let empty_matrix: Vec> = vec![]; - let extension_table = base_table.extension( - empty_matrix, - interpolant_degree, - padded_height, - ExtProcessorTable::ext_initial_constraints(&all_challenges.processor_table_challenges), - ExtProcessorTable::ext_consistency_constraints( - &all_challenges.processor_table_challenges, - ), - ExtProcessorTable::ext_transition_constraints( - &all_challenges.processor_table_challenges, - ), - ExtProcessorTable::ext_terminal_constraints(&all_challenges.processor_table_challenges), - ); + let extension_table = base_table.new_from_lifted_matrix(empty_matrix); ExtProcessorTable { inherited_table: extension_table, diff --git a/triton-vm/src/table/program_table.rs b/triton-vm/src/table/program_table.rs index 3b92c5996..1c83ec7f2 100644 --- a/triton-vm/src/table/program_table.rs +++ b/triton-vm/src/table/program_table.rs @@ -3,7 +3,7 @@ use num_traits::{One, Zero}; use strum::EnumCount; use strum_macros::{Display, EnumCount as EnumCountMacro, EnumIter}; use twenty_first::shared_math::b_field_element::BFieldElement; -use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; +use twenty_first::shared_math::mpolynomial::MPolynomial; use twenty_first::shared_math::x_field_element::XFieldElement; use ProgramTableChallengeId::*; @@ -238,11 +238,7 @@ impl ProgramTable { ) } - pub fn extend( - &self, - challenges: &ProgramTableChallenges, - interpolant_degree: Degree, - ) -> ExtProgramTable { + pub fn extend(&self, challenges: &ProgramTableChallenges) -> ExtProgramTable { let mut extension_matrix: Vec> = Vec::with_capacity(self.data().len()); let mut instruction_table_running_evaluation = EvalArg::default_initial(); @@ -282,24 +278,11 @@ impl ProgramTable { } assert_eq!(self.data().len(), extension_matrix.len()); - let padded_height = extension_matrix.len(); - let inherited_table = self.extension( - extension_matrix, - interpolant_degree, - padded_height, - ExtProgramTable::ext_initial_constraints(challenges), - ExtProgramTable::ext_consistency_constraints(challenges), - ExtProgramTable::ext_transition_constraints(challenges), - ExtProgramTable::ext_terminal_constraints(challenges), - ); + let inherited_table = self.new_from_lifted_matrix(extension_matrix); ExtProgramTable { inherited_table } } - pub fn for_verifier( - interpolant_degree: Degree, - padded_height: usize, - all_challenges: &AllChallenges, - ) -> ExtProgramTable { + pub fn for_verifier() -> ExtProgramTable { let inherited_table = Table::new( BASE_WIDTH, FULL_WIDTH, @@ -308,15 +291,7 @@ impl ProgramTable { ); let base_table = Self { inherited_table }; let empty_matrix: Vec> = vec![]; - let extension_table = base_table.extension( - empty_matrix, - interpolant_degree, - padded_height, - ExtProgramTable::ext_initial_constraints(&all_challenges.program_table_challenges), - ExtProgramTable::ext_consistency_constraints(&all_challenges.program_table_challenges), - ExtProgramTable::ext_transition_constraints(&all_challenges.program_table_challenges), - ExtProgramTable::ext_terminal_constraints(&all_challenges.program_table_challenges), - ); + let extension_table = base_table.new_from_lifted_matrix(empty_matrix); ExtProgramTable { inherited_table: extension_table, diff --git a/triton-vm/src/table/ram_table.rs b/triton-vm/src/table/ram_table.rs index 868e1364c..80a05b6a9 100644 --- a/triton-vm/src/table/ram_table.rs +++ b/triton-vm/src/table/ram_table.rs @@ -3,7 +3,7 @@ use num_traits::{One, Zero}; use strum::EnumCount; use strum_macros::{Display, EnumCount as EnumCountMacro, EnumIter}; use twenty_first::shared_math::b_field_element::BFieldElement; -use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; +use twenty_first::shared_math::mpolynomial::MPolynomial; use twenty_first::shared_math::traits::Inverse; use twenty_first::shared_math::x_field_element::XFieldElement; @@ -109,11 +109,7 @@ impl RamTable { ) } - pub fn extend( - &self, - challenges: &RamTableChallenges, - interpolant_degree: Degree, - ) -> ExtRamTable { + pub fn extend(&self, challenges: &RamTableChallenges) -> ExtRamTable { let mut extension_matrix: Vec> = Vec::with_capacity(self.data().len()); let mut running_product_for_perm_arg = PermArg::default_initial(); let mut all_clock_jump_differences_running_product = PermArg::default_initial(); @@ -187,36 +183,15 @@ impl RamTable { } assert_eq!(self.data().len(), extension_matrix.len()); - let padded_height = extension_matrix.len(); - let inherited_table = self.extension( - extension_matrix, - interpolant_degree, - padded_height, - ExtRamTable::ext_initial_constraints(challenges), - ExtRamTable::ext_consistency_constraints(challenges), - ExtRamTable::ext_transition_constraints(challenges), - ExtRamTable::ext_terminal_constraints(challenges), - ); + let inherited_table = self.new_from_lifted_matrix(extension_matrix); ExtRamTable { inherited_table } } - pub fn for_verifier( - interpolant_degree: Degree, - padded_height: usize, - all_challenges: &AllChallenges, - ) -> ExtRamTable { + pub fn for_verifier() -> ExtRamTable { let inherited_table = Table::new(BASE_WIDTH, FULL_WIDTH, vec![], "ExtRamTable".to_string()); let base_table = Self { inherited_table }; let empty_matrix: Vec> = vec![]; - let extension_table = base_table.extension( - empty_matrix, - interpolant_degree, - padded_height, - ExtRamTable::ext_initial_constraints(&all_challenges.ram_table_challenges), - ExtRamTable::ext_consistency_constraints(&all_challenges.ram_table_challenges), - ExtRamTable::ext_transition_constraints(&all_challenges.ram_table_challenges), - ExtRamTable::ext_terminal_constraints(&all_challenges.ram_table_challenges), - ); + let extension_table = base_table.new_from_lifted_matrix(empty_matrix); ExtRamTable { inherited_table: extension_table, diff --git a/triton-vm/src/table/table_collection.rs b/triton-vm/src/table/table_collection.rs index dbc74682e..2c214a9d1 100644 --- a/triton-vm/src/table/table_collection.rs +++ b/triton-vm/src/table/table_collection.rs @@ -243,39 +243,27 @@ impl ExtTableCollection { } } - pub fn for_verifier( - num_trace_randomizers: usize, - padded_height: usize, - challenges: &AllChallenges, - maybe_profiler: &mut Option, - ) -> Self { - let interpolant_degree = interpolant_degree(padded_height, num_trace_randomizers); - + pub fn for_verifier(padded_height: usize, maybe_profiler: &mut Option) -> Self { prof_start!(maybe_profiler, "program table"); - let ext_program_table = - ProgramTable::for_verifier(interpolant_degree, padded_height, challenges); + let ext_program_table = ProgramTable::for_verifier(); prof_stop!(maybe_profiler, "program table"); prof_start!(maybe_profiler, "instruction table"); - let ext_instruction_table = - InstructionTable::for_verifier(interpolant_degree, padded_height, challenges); + let ext_instruction_table = InstructionTable::for_verifier(); prof_stop!(maybe_profiler, "instruction table"); prof_start!(maybe_profiler, "processor table"); - let ext_processor_table = - ProcessorTable::for_verifier(interpolant_degree, padded_height, challenges); + let ext_processor_table = ProcessorTable::for_verifier(); prof_stop!(maybe_profiler, "processor table"); prof_start!(maybe_profiler, "op stack table"); - let ext_op_stack_table = - OpStackTable::for_verifier(interpolant_degree, padded_height, challenges); + let ext_op_stack_table = OpStackTable::for_verifier(); prof_stop!(maybe_profiler, "op stack table"); prof_start!(maybe_profiler, "ram table"); - let ext_ram_table = RamTable::for_verifier(interpolant_degree, padded_height, challenges); + let ext_ram_table = RamTable::for_verifier(); prof_stop!(maybe_profiler, "ram table"); prof_start!(maybe_profiler, "jump stack table"); - let ext_jump_stack_table = - JumpStackTable::for_verifier(interpolant_degree, padded_height, challenges); + let ext_jump_stack_table = JumpStackTable::for_verifier(); prof_stop!(maybe_profiler, "jump stack table"); prof_start!(maybe_profiler, "hash table"); - let ext_hash_table = HashTable::for_verifier(interpolant_degree, padded_height, challenges); + let ext_hash_table = HashTable::for_verifier(); prof_stop!(maybe_profiler, "hash table"); ExtTableCollection { @@ -309,42 +297,29 @@ impl ExtTableCollection { pub fn extend_tables( base_tables: &BaseTableCollection, all_challenges: &AllChallenges, - num_trace_randomizers: usize, ) -> Self { let padded_height = base_tables.padded_height; - let interpolant_degree = interpolant_degree(padded_height, num_trace_randomizers); - let program_table = base_tables .program_table - .extend(&all_challenges.program_table_challenges, interpolant_degree); - - let instruction_table = base_tables.instruction_table.extend( - &all_challenges.instruction_table_challenges, - interpolant_degree, - ); - - let processor_table = base_tables.processor_table.extend( - &all_challenges.processor_table_challenges, - interpolant_degree, - ); - - let op_stack_table = base_tables.op_stack_table.extend( - &all_challenges.op_stack_table_challenges, - interpolant_degree, - ); - + .extend(&all_challenges.program_table_challenges); + let instruction_table = base_tables + .instruction_table + .extend(&all_challenges.instruction_table_challenges); + let processor_table = base_tables + .processor_table + .extend(&all_challenges.processor_table_challenges); + let op_stack_table = base_tables + .op_stack_table + .extend(&all_challenges.op_stack_table_challenges); let ram_table = base_tables .ram_table - .extend(&all_challenges.ram_table_challenges, interpolant_degree); - - let jump_stack_table = base_tables.jump_stack_table.extend( - &all_challenges.jump_stack_table_challenges, - interpolant_degree, - ); - + .extend(&all_challenges.ram_table_challenges); + let jump_stack_table = base_tables + .jump_stack_table + .extend(&all_challenges.jump_stack_table_challenges); let hash_table = base_tables .hash_table - .extend(&all_challenges.hash_table_challenges, interpolant_degree); + .extend(&all_challenges.hash_table_challenges); ExtTableCollection { padded_height, diff --git a/triton-vm/src/vm.rs b/triton-vm/src/vm.rs index 31c7c2a5d..6cae9a6ef 100644 --- a/triton-vm/src/vm.rs +++ b/triton-vm/src/vm.rs @@ -220,7 +220,6 @@ pub mod triton_vm_tests { use crate::table::challenges::AllChallenges; use crate::table::extension_table::Evaluable; use crate::table::processor_table::ProcessorTable; - use crate::table::table_collection::interpolant_degree; use crate::table::table_column::ProcessorBaseTableColumn; use super::*; @@ -855,11 +854,9 @@ pub mod triton_vm_tests { "Matrix length must be power of 2 after padding" ); - let num_trace_randomizers = 2; let challenges = AllChallenges::placeholder(); - let interpolant_degree = interpolant_degree(padded_height, num_trace_randomizers); let ext_processor_table = - processor_table.extend(&challenges.processor_table_challenges, interpolant_degree); + processor_table.extend(&challenges.processor_table_challenges); let program_idx_string = format!("Program number {code_idx:>2}"); profiler.start(&program_idx_string);