Skip to content

Commit 106787c

Browse files
Use identifiers in split_felt
1 parent df6cc35 commit 106787c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

vm/src/hint_processor/builtin_hint_processor/builtin_hint_processor_definition.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,12 @@ impl HintProcessorLogic for BuiltinHintProcessor {
266266
&hint_data.ap_tracking,
267267
"continue_loop",
268268
),
269-
hint_code::SPLIT_FELT => {
270-
split_felt(vm, &hint_data.ids_data, &hint_data.ap_tracking, constants)
271-
}
269+
hint_code::SPLIT_FELT => split_felt(
270+
vm,
271+
&hint_data.ids_data,
272+
&hint_data.ap_tracking,
273+
&hint_data.identifiers,
274+
),
272275
hint_code::UNSIGNED_DIV_REM => {
273276
unsigned_div_rem(vm, &hint_data.ids_data, &hint_data.ap_tracking)
274277
}

vm/src/hint_processor/builtin_hint_processor/math_utils.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use crate::{
22
hint_processor::builtin_hint_processor::hint_utils::get_constant_from_var_name,
33
math_utils::signed_felt,
4+
serde::deserialize_program::Identifier,
45
stdlib::{boxed::Box, collections::HashMap, prelude::*},
5-
types::errors::math_errors::MathError,
6+
types::{errors::math_errors::MathError, program::Program},
67
};
78
use lazy_static::lazy_static;
89
use num_traits::{Signed, Zero};
@@ -384,15 +385,18 @@ pub fn split_felt(
384385
vm: &mut VirtualMachine,
385386
ids_data: &HashMap<String, HintReference>,
386387
ap_tracking: &ApTracking,
387-
constants: &HashMap<String, Felt252>,
388+
identifiers: &HashMap<String, Identifier>,
388389
) -> Result<(), HintError> {
389390
let assert = |b: bool, msg: &str| {
390391
b.then_some(())
391392
.ok_or_else(|| HintError::AssertionFailed(msg.to_string().into_boxed_str()))
392393
};
393394
let bound = pow2_const(128);
394-
let max_high = get_constant_from_var_name("MAX_HIGH", constants)?;
395-
let max_low = get_constant_from_var_name("MAX_LOW", constants)?;
395+
396+
let constants = Program::extract_constants(identifiers).unwrap();
397+
let max_high = get_constant_from_var_name("MAX_HIGH", &constants)?;
398+
let max_low = get_constant_from_var_name("MAX_LOW", &constants)?;
399+
396400
assert(
397401
max_high < &bound && max_low < &bound,
398402
"assert ids.MAX_HIGH < 2**128 and ids.MAX_LOW < 2**128",

0 commit comments

Comments
 (0)