|
1 | 1 | use crate::{ |
2 | 2 | hint_processor::builtin_hint_processor::hint_utils::get_constant_from_var_name, |
3 | 3 | math_utils::signed_felt, |
4 | | - serde::deserialize_program::Identifier, |
5 | 4 | stdlib::{boxed::Box, collections::HashMap, prelude::*}, |
6 | | - types::{errors::math_errors::MathError, program::Program}, |
| 5 | + types::errors::math_errors::MathError, |
7 | 6 | }; |
8 | 7 | use lazy_static::lazy_static; |
9 | 8 | use num_traits::{Signed, Zero}; |
@@ -385,17 +384,16 @@ pub fn split_felt( |
385 | 384 | vm: &mut VirtualMachine, |
386 | 385 | ids_data: &HashMap<String, HintReference>, |
387 | 386 | ap_tracking: &ApTracking, |
388 | | - identifiers: &HashMap<String, Identifier>, |
| 387 | + constants: &HashMap<String, Felt252>, |
389 | 388 | ) -> Result<(), HintError> { |
390 | 389 | let assert = |b: bool, msg: &str| { |
391 | 390 | b.then_some(()) |
392 | 391 | .ok_or_else(|| HintError::AssertionFailed(msg.to_string().into_boxed_str())) |
393 | 392 | }; |
394 | 393 | let bound = pow2_const(128); |
395 | 394 |
|
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)?; |
| 395 | + let max_high = get_constant_from_var_name("MAX_HIGH", constants)?; |
| 396 | + let max_low = get_constant_from_var_name("MAX_LOW", constants)?; |
399 | 397 |
|
400 | 398 | assert( |
401 | 399 | max_high < &bound && max_low < &bound, |
@@ -756,6 +754,7 @@ pub fn split_xx( |
756 | 754 | #[cfg(test)] |
757 | 755 | mod tests { |
758 | 756 | use super::*; |
| 757 | + use crate::stdlib::rc::Rc; |
759 | 758 | use crate::{felt_hex, felt_str}; |
760 | 759 | use core::ops::Neg; |
761 | 760 |
|
@@ -2067,31 +2066,10 @@ mod tests { |
2067 | 2066 | ), |
2068 | 2067 | ]); |
2069 | 2068 | let identifiers = HashMap::from([ |
2070 | | - ( |
2071 | | - "MAX_LOW".to_string(), |
2072 | | - Identifier { |
2073 | | - pc: None, |
2074 | | - type_: Some("const".to_string()), |
2075 | | - value: Some(Felt252::ZERO), |
2076 | | - full_name: None, |
2077 | | - members: None, |
2078 | | - cairo_type: None, |
2079 | | - size: None, |
2080 | | - destination: None, |
2081 | | - }, |
2082 | | - ), |
| 2069 | + ("MAX_LOW".to_string(), Felt252::ZERO), |
2083 | 2070 | ( |
2084 | 2071 | "MAX_HIGH".to_string(), |
2085 | | - Identifier { |
2086 | | - pc: None, |
2087 | | - type_: Some("const".to_string()), |
2088 | | - value: Some(felt_str!("10633823966279327296825105735305134080")), |
2089 | | - full_name: None, |
2090 | | - members: None, |
2091 | | - cairo_type: None, |
2092 | | - size: None, |
2093 | | - destination: None, |
2094 | | - }, |
| 2072 | + felt_str!("10633823966279327296825105735305134080"), |
2095 | 2073 | ), |
2096 | 2074 | ]); |
2097 | 2075 | //Execute the hint |
@@ -2131,31 +2109,10 @@ mod tests { |
2131 | 2109 | let ids_data = ids_data!["low"]; |
2132 | 2110 |
|
2133 | 2111 | let identifiers = HashMap::from([ |
2134 | | - ( |
2135 | | - "MAX_LOW".to_string(), |
2136 | | - Identifier { |
2137 | | - pc: None, |
2138 | | - type_: Some("const".to_string()), |
2139 | | - value: Some(Felt252::ZERO), |
2140 | | - full_name: None, |
2141 | | - members: None, |
2142 | | - cairo_type: None, |
2143 | | - size: None, |
2144 | | - destination: None, |
2145 | | - }, |
2146 | | - ), |
| 2112 | + ("MAX_LOW".to_string(), Felt252::ZERO), |
2147 | 2113 | ( |
2148 | 2114 | "MAX_HIGH".to_string(), |
2149 | | - Identifier { |
2150 | | - pc: None, |
2151 | | - type_: Some("const".to_string()), |
2152 | | - value: Some(felt_str!("10633823966279327296825105735305134080")), |
2153 | | - full_name: None, |
2154 | | - members: None, |
2155 | | - cairo_type: None, |
2156 | | - size: None, |
2157 | | - destination: None, |
2158 | | - }, |
| 2115 | + felt_str!("10633823966279327296825105735305134080"), |
2159 | 2116 | ), |
2160 | 2117 | ]); |
2161 | 2118 |
|
@@ -2200,31 +2157,10 @@ mod tests { |
2200 | 2157 | ]); |
2201 | 2158 |
|
2202 | 2159 | let identifiers = HashMap::from([ |
2203 | | - ( |
2204 | | - "MAX_LOW".to_string(), |
2205 | | - Identifier { |
2206 | | - pc: None, |
2207 | | - type_: Some("const".to_string()), |
2208 | | - value: Some(Felt252::ZERO), |
2209 | | - full_name: None, |
2210 | | - members: None, |
2211 | | - cairo_type: None, |
2212 | | - size: None, |
2213 | | - destination: None, |
2214 | | - }, |
2215 | | - ), |
| 2160 | + ("MAX_LOW".to_string(), Felt252::ZERO), |
2216 | 2161 | ( |
2217 | 2162 | "MAX_HIGH".to_string(), |
2218 | | - Identifier { |
2219 | | - pc: None, |
2220 | | - type_: Some("const".to_string()), |
2221 | | - value: Some(felt_str!("10633823966279327296825105735305134080")), |
2222 | | - full_name: None, |
2223 | | - members: None, |
2224 | | - cairo_type: None, |
2225 | | - size: None, |
2226 | | - destination: None, |
2227 | | - }, |
| 2163 | + felt_str!("10633823966279327296825105735305134080"), |
2228 | 2164 | ), |
2229 | 2165 | ]); |
2230 | 2166 |
|
@@ -2274,31 +2210,10 @@ mod tests { |
2274 | 2210 | ]); |
2275 | 2211 |
|
2276 | 2212 | let identifiers = HashMap::from([ |
2277 | | - ( |
2278 | | - "MAX_LOW".to_string(), |
2279 | | - Identifier { |
2280 | | - pc: None, |
2281 | | - type_: Some("const".to_string()), |
2282 | | - value: Some(Felt252::ZERO), |
2283 | | - full_name: None, |
2284 | | - members: None, |
2285 | | - cairo_type: None, |
2286 | | - size: None, |
2287 | | - destination: None, |
2288 | | - }, |
2289 | | - ), |
| 2213 | + ("MAX_LOW".to_string(), Felt252::ZERO), |
2290 | 2214 | ( |
2291 | 2215 | "MAX_HIGH".to_string(), |
2292 | | - Identifier { |
2293 | | - pc: None, |
2294 | | - type_: Some("const".to_string()), |
2295 | | - value: Some(felt_str!("10633823966279327296825105735305134080")), |
2296 | | - full_name: None, |
2297 | | - members: None, |
2298 | | - cairo_type: None, |
2299 | | - size: None, |
2300 | | - destination: None, |
2301 | | - }, |
| 2216 | + felt_str!("10633823966279327296825105735305134080"), |
2302 | 2217 | ), |
2303 | 2218 | ]); |
2304 | 2219 |
|
@@ -2342,31 +2257,10 @@ mod tests { |
2342 | 2257 | ), |
2343 | 2258 | ]); |
2344 | 2259 | let identifiers = HashMap::from([ |
2345 | | - ( |
2346 | | - "MAX_LOW".to_string(), |
2347 | | - Identifier { |
2348 | | - pc: None, |
2349 | | - type_: Some("const".to_string()), |
2350 | | - value: Some(Felt252::ZERO), |
2351 | | - full_name: None, |
2352 | | - members: None, |
2353 | | - cairo_type: None, |
2354 | | - size: None, |
2355 | | - destination: None, |
2356 | | - }, |
2357 | | - ), |
| 2260 | + ("MAX_LOW".to_string(), Felt252::ZERO), |
2358 | 2261 | ( |
2359 | 2262 | "MAX_HIGH".to_string(), |
2360 | | - Identifier { |
2361 | | - pc: None, |
2362 | | - type_: Some("const".to_string()), |
2363 | | - value: Some(felt_str!("10633823966279327296825105735305134080")), |
2364 | | - full_name: None, |
2365 | | - members: None, |
2366 | | - cairo_type: None, |
2367 | | - size: None, |
2368 | | - destination: None, |
2369 | | - }, |
| 2263 | + felt_str!("10633823966279327296825105735305134080"), |
2370 | 2264 | ), |
2371 | 2265 | ]); |
2372 | 2266 | //Execute the hint |
@@ -2442,32 +2336,8 @@ mod tests { |
2442 | 2336 | ]); |
2443 | 2337 |
|
2444 | 2338 | let identifiers = HashMap::from([ |
2445 | | - ( |
2446 | | - "a.MAX_LOW".to_string(), |
2447 | | - Identifier { |
2448 | | - pc: None, |
2449 | | - type_: Some("const".to_string()), |
2450 | | - value: Some(Felt252::from(-1)), |
2451 | | - full_name: None, |
2452 | | - members: None, |
2453 | | - cairo_type: None, |
2454 | | - size: None, |
2455 | | - destination: None, |
2456 | | - }, |
2457 | | - ), |
2458 | | - ( |
2459 | | - "a.MAX_HIGH".to_string(), |
2460 | | - Identifier { |
2461 | | - pc: None, |
2462 | | - type_: Some("const".to_string()), |
2463 | | - value: Some(Felt252::from(-1)), |
2464 | | - full_name: None, |
2465 | | - members: None, |
2466 | | - cairo_type: None, |
2467 | | - size: None, |
2468 | | - destination: None, |
2469 | | - }, |
2470 | | - ), |
| 2339 | + ("a.MAX_LOW".to_string(), Felt252::from(-1)), |
| 2340 | + ("a.MAX_HIGH".to_string(), Felt252::from(-1)), |
2471 | 2341 | ]); |
2472 | 2342 |
|
2473 | 2343 | //Execute the hint |
@@ -2511,32 +2381,8 @@ mod tests { |
2511 | 2381 | ]); |
2512 | 2382 |
|
2513 | 2383 | let identifiers = HashMap::from([ |
2514 | | - ( |
2515 | | - "MAX_LOW".to_string(), |
2516 | | - Identifier { |
2517 | | - pc: None, |
2518 | | - type_: Some("const".to_string()), |
2519 | | - value: Some(Felt252::ZERO), |
2520 | | - full_name: None, |
2521 | | - members: None, |
2522 | | - cairo_type: None, |
2523 | | - size: None, |
2524 | | - destination: None, |
2525 | | - }, |
2526 | | - ), |
2527 | | - ( |
2528 | | - "MAX_HIGH".to_string(), |
2529 | | - Identifier { |
2530 | | - pc: None, |
2531 | | - type_: Some("const".to_string()), |
2532 | | - value: Some(Felt252::ZERO), |
2533 | | - full_name: None, |
2534 | | - members: None, |
2535 | | - cairo_type: None, |
2536 | | - size: None, |
2537 | | - destination: None, |
2538 | | - }, |
2539 | | - ), |
| 2384 | + ("MAX_LOW".to_string(), Felt252::ZERO), |
| 2385 | + ("MAX_HIGH".to_string(), Felt252::ZERO), |
2540 | 2386 | ]); |
2541 | 2387 |
|
2542 | 2388 | //Execute the hint |
|
0 commit comments