Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(starknet_os): integrate math hints #3692

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!()
}