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): implement set decompressed dst hint #4666

Open
wants to merge 1 commit into
base: yoav/snos/hints/compression_hint/impl_compression_hint
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashMap;

use blockifier::state::state_api::StateReader;
use cairo_vm::hint_processor::builtin_hint_processor::hint_utils::{
get_integer_from_var_name,
get_maybe_relocatable_from_var_name,
get_ptr_from_var_name,
insert_value_from_var_name,
Expand Down Expand Up @@ -62,7 +63,18 @@ pub(crate) fn compression_hint<S: StateReader>(
}

pub(crate) fn set_decompressed_dst<S: StateReader>(
HintArgs { .. }: HintArgs<'_, S>,
HintArgs { vm, ids_data, ap_tracking, .. }: HintArgs<'_, S>,
) -> OsHintResult {
todo!()
let decompressed_dst =
get_ptr_from_var_name(Ids::DecompressedDst.into(), vm, ids_data, ap_tracking)?;

let packed_felt = get_integer_from_var_name(Ids::PackedFelt.into(), vm, ids_data, ap_tracking)?;
let elm_bound = get_integer_from_var_name(Ids::ElmBound.into(), vm, ids_data, ap_tracking)?;

vm.insert_value(
decompressed_dst,
packed_felt.div_rem(&elm_bound.try_into().expect("elm_bound is zero")).1,
)?;

Ok(())
}
6 changes: 6 additions & 0 deletions crates/starknet_os/src/hints/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ pub enum Ids {
ContractStateChanges,
DataEnd,
DataStart,
DecompressedDst,
DictPtr,
ElmBound,
FullOutput,
Hash,
NCompiledClassFacts,
NextAvailableAlias,
OldBlockHash,
OldBlockNumber,
OsStateUpdate,
PackedFelt,
PrevOffset,
Sha256Ptr,
StateEntry,
Expand All @@ -81,14 +84,17 @@ impl From<Ids> for &'static str {
Ids::ContractStateChanges => "contract_state_changes",
Ids::DataEnd => "data_end",
Ids::DataStart => "data_start",
Ids::DecompressedDst => "decompressed_dst",
Ids::DictPtr => "dict_ptr",
Ids::ElmBound => "elm_bound",
Ids::FullOutput => "full_output",
Ids::Hash => "hash",
Ids::NCompiledClassFacts => "n_compiled_class_facts",
Ids::NextAvailableAlias => "next_available_alias",
Ids::OldBlockHash => "old_block_hash",
Ids::OldBlockNumber => "old_block_number",
Ids::OsStateUpdate => "os_state_update",
Ids::PackedFelt => "packed_felt",
Ids::PrevOffset => "prev_offset",
Ids::Sha256Ptr => "sha256_ptr",
Ids::StateEntry => "state_entry",
Expand Down
Loading