1#![warn(clippy::pedantic)]
4#![allow(clippy::similar_names)]
5#![allow(clippy::cast_possible_wrap)]
6#![allow(clippy::cast_possible_truncation)]
7#![allow(clippy::cast_sign_loss)]
8#![allow(clippy::module_name_repetitions)]
9#![allow(clippy::needless_range_loop)]
10#![allow(clippy::cast_lossless)]
11#![allow(clippy::bool_to_int_with_if)]
12#![allow(clippy::should_panic_without_expect)]
13#![allow(clippy::field_reassign_with_default)]
14#![allow(clippy::manual_assert)]
15#![allow(clippy::unreadable_literal)]
16#![allow(clippy::match_wildcard_for_single_variants)]
17#![allow(clippy::missing_panics_doc)]
18#![allow(clippy::missing_errors_doc)]
19#![allow(clippy::explicit_iter_loop)]
20#![allow(clippy::struct_excessive_bools)]
21#![warn(missing_docs)]
22
23mod air;
24mod context;
25mod cost;
26mod dependencies;
27mod disassembler;
28pub mod estimator;
29pub mod events;
30mod executor;
31mod hook;
32mod instruction;
33mod io;
34mod memory;
35mod opcode;
36#[cfg(feature = "profiling")]
37mod profiler;
38mod program;
39mod record;
40mod reduce;
41mod register;
42mod report;
43mod state;
44pub mod subproof;
45pub mod syscalls;
46mod utils;
47
48pub use air::*;
49pub use context::*;
50pub use cost::*;
51pub use executor::*;
52pub use hook::*;
53pub use instruction::*;
54pub use opcode::*;
55pub use program::*;
56pub use record::*;
57pub use reduce::*;
58pub use register::*;
59pub use report::*;
60pub use state::*;
61pub use utils::*;
62
63#[cfg(test)]
65pub mod programs {
66 #[allow(dead_code)]
67 #[allow(missing_docs)]
68 pub mod tests {
69 use crate::{Instruction, Opcode, Program};
70
71 pub use test_artifacts::{
72 FIBONACCI_ELF, PANIC_ELF, SECP256R1_ADD_ELF, SECP256R1_DOUBLE_ELF, SSZ_WITHDRAWALS_ELF,
73 U256XU2048_MUL_ELF,
74 };
75
76 #[must_use]
77 pub fn simple_program() -> Program {
78 let instructions = vec![
79 Instruction::new(Opcode::ADD, 29, 0, 5, false, true),
80 Instruction::new(Opcode::ADD, 30, 0, 37, false, true),
81 Instruction::new(Opcode::ADD, 31, 30, 29, false, false),
82 ];
83 Program::new(instructions, 0, 0)
84 }
85
86 #[must_use]
92 pub fn fibonacci_program() -> Program {
93 Program::from(FIBONACCI_ELF).unwrap()
94 }
95
96 #[must_use]
102 pub fn secp256r1_add_program() -> Program {
103 Program::from(SECP256R1_ADD_ELF).unwrap()
104 }
105
106 #[must_use]
112 pub fn secp256r1_double_program() -> Program {
113 Program::from(SECP256R1_DOUBLE_ELF).unwrap()
114 }
115
116 #[must_use]
122 pub fn u256xu2048_mul_program() -> Program {
123 Program::from(U256XU2048_MUL_ELF).unwrap()
124 }
125
126 #[must_use]
132 pub fn ssz_withdrawals_program() -> Program {
133 Program::from(SSZ_WITHDRAWALS_ELF).unwrap()
134 }
135
136 #[must_use]
142 pub fn panic_program() -> Program {
143 Program::from(PANIC_ELF).unwrap()
144 }
145
146 #[must_use]
147 #[allow(clippy::unreadable_literal)]
148 pub fn simple_memory_program() -> Program {
149 let instructions = vec![
150 Instruction::new(Opcode::ADD, 29, 0, 0x12348765, false, true),
151 Instruction::new(Opcode::SW, 29, 0, 0x27654320, false, true),
153 Instruction::new(Opcode::LW, 28, 0, 0x27654320, false, true),
154 Instruction::new(Opcode::LBU, 27, 0, 0x27654320, false, true),
156 Instruction::new(Opcode::LBU, 26, 0, 0x27654321, false, true),
157 Instruction::new(Opcode::LBU, 25, 0, 0x27654322, false, true),
158 Instruction::new(Opcode::LBU, 24, 0, 0x27654323, false, true),
159 Instruction::new(Opcode::LB, 23, 0, 0x27654320, false, true),
161 Instruction::new(Opcode::LB, 22, 0, 0x27654321, false, true),
162 Instruction::new(Opcode::LHU, 21, 0, 0x27654320, false, true),
164 Instruction::new(Opcode::LHU, 20, 0, 0x27654322, false, true),
165 Instruction::new(Opcode::LH, 19, 0, 0x27654320, false, true),
167 Instruction::new(Opcode::LH, 18, 0, 0x27654322, false, true),
168 Instruction::new(Opcode::ADD, 17, 0, 0x38276525, false, true),
170 Instruction::new(Opcode::SW, 29, 0, 0x43627530, false, true),
172 Instruction::new(Opcode::SB, 17, 0, 0x43627530, false, true),
173 Instruction::new(Opcode::LW, 16, 0, 0x43627530, false, true),
174 Instruction::new(Opcode::SB, 17, 0, 0x43627531, false, true),
175 Instruction::new(Opcode::LW, 15, 0, 0x43627530, false, true),
176 Instruction::new(Opcode::SB, 17, 0, 0x43627532, false, true),
177 Instruction::new(Opcode::LW, 14, 0, 0x43627530, false, true),
178 Instruction::new(Opcode::SB, 17, 0, 0x43627533, false, true),
179 Instruction::new(Opcode::LW, 13, 0, 0x43627530, false, true),
180 Instruction::new(Opcode::SW, 29, 0, 0x43627530, false, true),
183 Instruction::new(Opcode::SH, 17, 0, 0x43627530, false, true),
184 Instruction::new(Opcode::LW, 12, 0, 0x43627530, false, true),
185 Instruction::new(Opcode::SH, 17, 0, 0x43627532, false, true),
186 Instruction::new(Opcode::LW, 11, 0, 0x43627530, false, true),
187 ];
188 Program::new(instructions, 0, 0)
189 }
190 }
191}