Skip to content

Commit 9728017

Browse files
Add more comments
1 parent 85cccab commit 9728017

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

vm/src/vm/runners/cairo_runner.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,15 @@ pub struct CairoRunnerBuilder {
160160
memory: MemorySegmentManager,
161161
// Set after loading program.
162162
loaded_program: bool,
163-
// Set after loading instruction cache.
164-
// instructions: Vec<Option<Instruction>>,
165163
// Set after compiling hints.
166164
hints: Option<Vec<Rc<Box<dyn Any>>>>,
165+
// TODO: Set after loading instruction cache.
166+
// instructions: Vec<Option<Instruction>>,
167167
}
168168

169169
impl CairoRunnerBuilder {
170+
// TODO: Determine if these fields should be set with different functions,
171+
// instead of passing them to `new`.
170172
pub fn new(
171173
program: &Program,
172174
layout_name: LayoutName,
@@ -227,6 +229,8 @@ impl CairoRunnerBuilder {
227229
self.memory.add()
228230
}
229231

232+
// TODO: Cloning the builder after calling this function leads to bad
233+
// behaviour (transactions revert). Why?
230234
pub fn initialize_builtin_runners_for_layout(&mut self) -> Result<(), RunnerError> {
231235
let builtin_ordered_list = vec![
232236
BuiltinName::output,
@@ -377,6 +381,20 @@ impl CairoRunnerBuilder {
377381
Ok(())
378382
}
379383

384+
/// Precompiles the program's hints using the given executor.
385+
///
386+
/// # Safety
387+
///
388+
/// Use the v2 variants of the execution functions (run_until_pc_v2 or
389+
/// run_from_entrypoint_v2), as those function make use of the precompiled
390+
/// hints.
391+
///
392+
/// This function consumes the program's constants, so not doing so can
393+
/// lead to errors during execution (missing constants). This was done for
394+
/// performance reasons.
395+
///
396+
/// The user must make sure to use the same implementation of the
397+
/// HintProcessor for execution.
380398
pub fn compile_hints(
381399
&mut self,
382400
hint_processor: &mut dyn HintProcessor,

0 commit comments

Comments
 (0)