Skip to content

Commit

Permalink
Changes_for_using_hint_extention_feature
Browse files Browse the repository at this point in the history
  • Loading branch information
YairVaknin-starkware committed Nov 24, 2024
1 parent 0b30ba2 commit 50e1fa4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#### Upcoming Changes

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ impl BuiltinHintProcessor {
}

impl HintProcessorLogic for BuiltinHintProcessor {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn execute_hint(
&mut self,
vm: &mut VirtualMachine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,10 @@ impl HintProcessorLogic for Cairo1HintProcessor {
}
Ok(())
}

fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
}

impl ResourceTracker for Cairo1HintProcessor {
Expand Down
1 change: 1 addition & 0 deletions vm/src/hint_processor/hint_processor_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub trait HintProcessorLogic {
}))
}

fn as_any_mut(&mut self) -> &mut dyn Any;
#[cfg(feature = "extensive_hints")]
// Executes the hint which's data is provided by a dynamic structure previously created by compile_hint
// Also returns a map of hints to be loaded after the current hint is executed
Expand Down
16 changes: 8 additions & 8 deletions vm/src/types/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ use arbitrary::{Arbitrary, Unstructured};
// failures.
// Fields in `Program` (other than `SharedProgramData` itself) are used by the main logic.
#[derive(Clone, Default, Debug, PartialEq, Eq)]
pub(crate) struct SharedProgramData {
pub struct SharedProgramData {
pub(crate) data: Vec<MaybeRelocatable>,
pub(crate) hints_collection: HintsCollection,
pub hints_collection: HintsCollection,
pub(crate) main: Option<usize>,
//start and end labels will only be used in proof-mode
pub(crate) start: Option<usize>,
pub(crate) end: Option<usize>,
pub(crate) error_message_attributes: Vec<Attribute>,
pub(crate) instruction_locations: Option<HashMap<usize, InstructionLocation>>,
pub(crate) identifiers: HashMap<String, Identifier>,
pub(crate) reference_manager: Vec<HintReference>,
pub reference_manager: Vec<HintReference>,
}

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

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

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

Expand Down

0 comments on commit 50e1fa4

Please sign in to comment.