Skip to content

Commit

Permalink
feat(starknet_os): integrate math hints
Browse files Browse the repository at this point in the history
  • Loading branch information
dorimedini-starkware committed Jan 28, 2025
1 parent efb0878 commit d374505
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/starknet_os/src/hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ pub mod execute_transactions;
pub mod execution;
pub mod find_element;
pub mod kzg;
pub mod math;
pub mod stateless_compression;
pub mod types;
8 changes: 8 additions & 0 deletions crates/starknet_os/src/hints/enum_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ use crate::hints::execution::{
};
use crate::hints::find_element::search_sorted_optimistic;
use crate::hints::kzg::store_da_segment;
use crate::hints::math::log2_ceil;
use crate::hints::stateless_compression::{
compression_hint,
dictionary_from_bucket,
Expand Down Expand Up @@ -979,6 +980,13 @@ segments.write_arg(ids.sha256_ptr_end, padding)"#}
ids.evals = segments.add_temp_segment()
segments.write_arg(ids.kzg_commitments.address_, list(itertools.chain(*kzg_commitments)))"#}
),
(
Log2Ceil,
log2_ceil,
indoc! {r#"from starkware.python.math_utils import log2_ceil
ids.res = log2_ceil(ids.value)"#
}
)
);

Expand Down
19 changes: 19 additions & 0 deletions crates/starknet_os/src/hints/math.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::collections::HashMap;

use cairo_vm::hint_processor::hint_processor_definition::HintReference;
use cairo_vm::serde::deserialize_program::ApTracking;
use cairo_vm::types::exec_scope::ExecutionScopes;
use cairo_vm::vm::vm_core::VirtualMachine;
use starknet_types_core::felt::Felt;

use crate::hints::error::HintResult;

pub fn log2_ceil(
_vm: &mut VirtualMachine,
_exec_scopes: &mut ExecutionScopes,
_ids_data: &HashMap<String, HintReference>,
_ap_tracking: &ApTracking,
_constants: &HashMap<String, Felt>,
) -> HintResult {
todo!()
}

0 comments on commit d374505

Please sign in to comment.