Skip to content

Commit ca88b12

Browse files
Changes_for_using_hint_extention_feature
1 parent 0b30ba2 commit ca88b12

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#### Upcoming Changes
44

55
#### [2.0.0-rc1] - 2024-11-20
6+
* chore: [#1855](https://github.com/lambdaclass/cairo-vm/pull/1880):
7+
* Refactor vm crate to make it possible to use hint extension feature for nested programs with hints.
68

79
* feat: add `EvalCircuit` and `TestLessThanOrEqualAddress` hints [#1843](https://github.com/lambdaclass/cairo-vm/pull/1843)
810

vm/src/hint_processor/builtin_hint_processor/builtin_hint_processor_definition.rs

+3
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ impl BuiltinHintProcessor {
180180
}
181181

182182
impl HintProcessorLogic for BuiltinHintProcessor {
183+
fn as_any_mut(&mut self) -> &mut dyn Any {
184+
self
185+
}
183186
fn execute_hint(
184187
&mut self,
185188
vm: &mut VirtualMachine,

vm/src/hint_processor/hint_processor_definition.rs

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub trait HintProcessorLogic {
5151
}))
5252
}
5353

54+
fn as_any_mut(&mut self) -> &mut dyn Any;
5455
#[cfg(feature = "extensive_hints")]
5556
// Executes the hint which's data is provided by a dynamic structure previously created by compile_hint
5657
// Also returns a map of hints to be loaded after the current hint is executed

vm/src/types/program.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ use arbitrary::{Arbitrary, Unstructured};
6060
// failures.
6161
// Fields in `Program` (other than `SharedProgramData` itself) are used by the main logic.
6262
#[derive(Clone, Default, Debug, PartialEq, Eq)]
63-
pub(crate) struct SharedProgramData {
63+
pub struct SharedProgramData {
6464
pub(crate) data: Vec<MaybeRelocatable>,
65-
pub(crate) hints_collection: HintsCollection,
65+
pub hints_collection: HintsCollection,
6666
pub(crate) main: Option<usize>,
6767
//start and end labels will only be used in proof-mode
6868
pub(crate) start: Option<usize>,
6969
pub(crate) end: Option<usize>,
7070
pub(crate) error_message_attributes: Vec<Attribute>,
7171
pub(crate) instruction_locations: Option<HashMap<usize, InstructionLocation>>,
7272
pub(crate) identifiers: HashMap<String, Identifier>,
73-
pub(crate) reference_manager: Vec<HintReference>,
73+
pub reference_manager: Vec<HintReference>,
7474
}
7575

7676
#[cfg(feature = "test_utils")]
@@ -107,13 +107,13 @@ impl<'a> Arbitrary<'a> for SharedProgramData {
107107
}
108108

109109
#[derive(Clone, Default, Debug, PartialEq, Eq)]
110-
pub(crate) struct HintsCollection {
111-
hints: Vec<HintParams>,
110+
pub struct HintsCollection {
111+
pub hints: Vec<HintParams>,
112112
/// This maps a PC to the range of hints in `hints` that correspond to it.
113113
#[cfg(not(feature = "extensive_hints"))]
114114
pub(crate) hints_ranges: Vec<HintRange>,
115115
#[cfg(feature = "extensive_hints")]
116-
pub(crate) hints_ranges: HashMap<Relocatable, HintRange>,
116+
pub hints_ranges: HashMap<Relocatable, HintRange>,
117117
}
118118

119119
impl HintsCollection {
@@ -200,8 +200,8 @@ pub type HintRange = (usize, NonZeroUsize);
200200
#[cfg_attr(feature = "test_utils", derive(Arbitrary))]
201201
#[derive(Clone, Debug, PartialEq, Eq)]
202202
pub struct Program {
203-
pub(crate) shared_program_data: Arc<SharedProgramData>,
204-
pub(crate) constants: HashMap<String, Felt252>,
203+
pub shared_program_data: Arc<SharedProgramData>,
204+
pub constants: HashMap<String, Felt252>,
205205
pub(crate) builtins: Vec<BuiltinName>,
206206
}
207207

0 commit comments

Comments
 (0)