• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TritonVM / triton-vm / 9256027932

27 May 2024 01:54PM UTC coverage: 99.325% (+0.05%) from 99.276%
9256027932

Pull #294

github

web-flow
Merge 11a8e3e4a into 4e52b67ed
Pull Request #294: feat: Parallelize table extension

855 of 855 new or added lines in 8 files covered. (100.0%)

29 existing lines in 3 files now uncovered.

44744 of 45048 relevant lines covered (99.33%)

3728707.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.5
/constraint-evaluation-generator/src/main.rs
1
//! The constraint generator is a tool that generates efficient-to-evaluate code
2
//! for the constraints of Triton Virtual Machine, in particular, for the
3
//! Arithmetic Intermediate Representation (AIR) constraints of the
4
//! Zero-Knowledge Proof System underpinning the STARK proof system.
5
//!
6
//! The constraints are defined in the Triton VM crate. In order to leverage
7
//! compiler optimizations, rust code is generated using those constraints.
8
//!
9
//! Additionally, the constraints are also translated to Triton Assembly (TASM).
10
//! This allows Triton VM to evaluate its own constraints, which is essential
11
//! for recursive proof verification, or Incrementally Verifiable Computation.
12
//!
13
//! The constraint generator can be run by executing
14
//! `cargo run --bin constraint-evaluation-generator`
15
//! in the root of the repository.
16

17
#![warn(missing_debug_implementations)]
18
#![warn(missing_docs)]
19

20
use std::fs::write;
21

22
use proc_macro2::TokenStream;
23

24
use crate::codegen::Codegen;
25
use crate::codegen::RustBackend;
26
use crate::codegen::TasmBackend;
27
use crate::constraints::Constraints;
28

29
mod codegen;
30
mod constraints;
31
mod substitution;
32

33
fn main() {
×
34
    let mut constraints = Constraints::all();
×
35
    let substitutions = constraints.lower_to_target_degree_through_substitutions();
×
36
    let degree_lowering_table_code = substitutions.generate_degree_lowering_table_code();
×
37

×
38
    let constraints = constraints.combine_with_substitution_induced_constraints(substitutions);
×
39
    let rust = RustBackend::constraint_evaluation_code(&constraints);
×
40
    let tasm = TasmBackend::constraint_evaluation_code(&constraints);
×
41

×
42
    write_code_to_file(degree_lowering_table_code, "degree_lowering_table");
×
43
    write_code_to_file(rust, "constraints");
×
44
    write_code_to_file(tasm, "tasm_air_constraints");
×
45
}
×
46

47
fn write_code_to_file(code: TokenStream, file_name: &str) {
×
48
    let syntax_tree = syn::parse2(code).unwrap();
×
49
    let code = prettyplease::unparse(&syntax_tree);
×
50
    let path = format!("triton-vm/src/table/{file_name}.rs");
×
51
    write(path, code).unwrap();
×
52
}
×
53

54
#[cfg(test)]
55
mod tests {
56
    use super::*;
57

58
    #[test]
59
    fn test_constraints_can_be_fetched() {
1✔
60
        let _ = Constraints::test_constraints();
1✔
61
    }
1✔
62

63
    #[test]
64
    fn degree_lowering_tables_code_can_be_generated_for_test_constraints() {
1✔
65
        let mut constraints = Constraints::test_constraints();
1✔
66
        let substitutions = constraints.lower_to_target_degree_through_substitutions();
1✔
67
        let _ = substitutions.generate_degree_lowering_table_code();
1✔
68
    }
1✔
69

70
    #[test]
71
    fn all_constraints_can_be_fetched() {
1✔
72
        let _ = Constraints::all();
1✔
73
    }
1✔
74

75
    #[test]
76
    fn degree_lowering_tables_code_can_be_generated_from_all_constraints() {
1✔
77
        let mut constraints = Constraints::all();
1✔
78
        let substitutions = constraints.lower_to_target_degree_through_substitutions();
1✔
79
        let _ = substitutions.generate_degree_lowering_table_code();
1✔
80
    }
1✔
81

82
    #[test]
83
    fn constraints_and_substitutions_can_be_combined() {
1✔
84
        let mut constraints = Constraints::test_constraints();
1✔
85
        let substitutions = constraints.lower_to_target_degree_through_substitutions();
1✔
86
        let _ = constraints.combine_with_substitution_induced_constraints(substitutions);
1✔
87
    }
1✔
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc