Skip to content

Commit df6cc35

Browse files
Add identifiers to hint_processor
1 parent 08edc6f commit df6cc35

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

hint_accountant/src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ fn run() {
6464
.map(|ahe| ahe.hint_lines.join("\n"))
6565
.filter(|h| {
6666
let hint_data = hint_executor
67-
.compile_hint(h, &ap_tracking_data, &reference_ids, &references)
67+
.compile_hint(
68+
h,
69+
&ap_tracking_data,
70+
&reference_ids,
71+
&references,
72+
&HashMap::default(),
73+
)
6874
.expect("this implementation is infallible");
6975
matches!(
7076
hint_executor.execute_hint(&mut vm, &mut exec_scopes, &hint_data, &constants,),

vm/src/hint_processor/builtin_hint_processor/builtin_hint_processor_definition.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use super::{
2323
pack::*,
2424
},
2525
};
26+
use crate::serde::deserialize_program::Identifier;
2627
use crate::Felt252;
2728
use crate::{
2829
hint_processor::builtin_hint_processor::secp::secp_utils::{SECP256R1_ALPHA, SECP256R1_P},
@@ -132,6 +133,7 @@ pub struct HintProcessorData {
132133
pub code: String,
133134
pub ap_tracking: ApTracking,
134135
pub ids_data: HashMap<String, HintReference>,
136+
pub identifiers: HashMap<String, Identifier>,
135137
}
136138

137139
impl HintProcessorData {
@@ -140,6 +142,7 @@ impl HintProcessorData {
140142
code,
141143
ap_tracking: ApTracking::default(),
142144
ids_data,
145+
identifiers: HashMap::new(),
143146
}
144147
}
145148
}

vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use super::hint_processor_utils::*;
99
use crate::any_box;
1010
use crate::hint_processor::cairo_1_hint_processor::dict_manager::DictSquashExecScope;
1111
use crate::hint_processor::hint_processor_definition::HintReference;
12+
use crate::serde::deserialize_program::Identifier;
1213
use crate::stdlib::{boxed::Box, collections::HashMap, prelude::*};
1314
use crate::types::relocatable::{MaybeRelocatable, Relocatable};
1415
use crate::vm::runners::cairo_runner::ResourceTracker;
@@ -1263,6 +1264,8 @@ impl HintProcessorLogic for Cairo1HintProcessor {
12631264
_reference_ids: &HashMap<String, usize>,
12641265
//List of all references (key corresponds to element of the previous dictionary)
12651266
_references: &[HintReference],
1267+
// Identifiers stored in the hint's program.
1268+
_identifiers: &HashMap<String, Identifier>,
12661269
) -> Result<Box<dyn Any>, VirtualMachineError> {
12671270
let data = hint_code.parse().ok().and_then(|x: usize| self.hints.get(&x).cloned())
12681271
.ok_or_else(|| VirtualMachineError::CompileHintFail(

vm/src/hint_processor/hint_processor_definition.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::stdlib::{any::Any, boxed::Box, collections::HashMap, prelude::*};
22

33
use crate::any_box;
4-
use crate::serde::deserialize_program::ApTracking;
54
use crate::serde::deserialize_program::OffsetValue;
65
use crate::serde::deserialize_program::Reference;
6+
use crate::serde::deserialize_program::{ApTracking, Identifier};
77
use crate::types::exec_scope::ExecutionScopes;
88
use crate::types::instruction::Register;
99
use crate::types::relocatable::Relocatable;
@@ -43,11 +43,14 @@ pub trait HintProcessorLogic {
4343
reference_ids: &HashMap<String, usize>,
4444
//List of all references (key corresponds to element of the previous dictionary)
4545
references: &[HintReference],
46+
// Identifiers stored in the hint's program.
47+
identifiers: &HashMap<String, Identifier>,
4648
) -> Result<Box<dyn Any>, VirtualMachineError> {
4749
Ok(any_box!(HintProcessorData {
4850
code: hint_code.to_string(),
4951
ap_tracking: ap_tracking_data.clone(),
5052
ids_data: get_ids_data(reference_ids, references)?,
53+
identifiers: identifiers.clone(),
5154
}))
5255
}
5356

vm/src/tests/run_deprecated_contract_class_simplified.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ pub fn vm_load_program(
302302
&hint_ap_tracking_data,
303303
&reference_ids,
304304
&references,
305+
&HashMap::default(),
305306
)?;
306307
// Create the hint extension
307308
// As the hint from the compiled constract has offset 0, the hint pc will be equal to the loaded contract's program base:

vm/src/vm/runners/cairo_runner.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ impl CairoRunner {
654654
&hint.flow_tracking_data.ap_tracking,
655655
&hint.flow_tracking_data.reference_ids,
656656
references,
657+
&self.program.shared_program_data.identifiers,
657658
)
658659
.map_err(|_| VirtualMachineError::CompileHintFail(hint.code.clone().into()))
659660
})

0 commit comments

Comments
 (0)