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

Feature: DATA_TO_HASH_NEW_SEGMENT hint #159

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
3 changes: 2 additions & 1 deletion src/hints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub type HintImpl = fn(
) -> Result<(), HintError>;

#[rustfmt::skip]
static HINTS: [(&str, HintImpl); 162] = [
static HINTS: [(&str, HintImpl); 164] = [
(BREAKPOINT, breakpoint),
(INITIALIZE_CLASS_HASHES, initialize_class_hashes),
(INITIALIZE_STATE_CHANGES, initialize_state_changes),
Expand Down Expand Up @@ -214,6 +214,7 @@ static HINTS: [(&str, HintImpl); 162] = [
(syscalls::STORAGE_READ, syscalls::storage_read),
(syscalls::STORAGE_WRITE, syscalls::storage_write),
(transaction_hash::ADDITIONAL_DATA_NEW_SEGMENT, transaction_hash::additional_data_new_segment),
(transaction_hash::DATA_TO_HASH_NEW_SEGMENT, transaction_hash::data_to_hash_new_segment),
];

/// Hint Extensions extend the current map of hints used by the VM.
Expand Down
14 changes: 14 additions & 0 deletions src/hints/transaction_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,17 @@ pub fn additional_data_new_segment(
) -> Result<(), HintError> {
insert_value_from_var_name(vars::ids::ADDITIONAL_DATA, vm.add_memory_segment(), vm, ids_data, ap_tracking)
}

pub const DATA_TO_HASH_NEW_SEGMENT: &str = indoc! {r#"
ids.data_to_hash = segments.add()"#
};

pub fn data_to_hash_new_segment(
vm: &mut VirtualMachine,
_exec_scopes: &mut ExecutionScopes,
ids_data: &HashMap<String, HintReference>,
ap_tracking: &ApTracking,
_constants: &HashMap<String, Felt252>,
) -> Result<(), HintError> {
insert_value_from_var_name(vars::ids::DATA_TO_HASH, vm.segments.add(), vm, ids_data, ap_tracking)
}
5 changes: 0 additions & 5 deletions src/hints/unimplemented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ pub const COMPUTE_VALUE_DIV_MOD: &str = indoc! {r#"
value = div_mod(1, x, SECP256R1_P)"#
};

#[allow(unused)]
pub const DATA_TO_HASH_NEW_SEGMENT: &str = indoc! {r#"
ids.data_to_hash = segments.add()"#
};

#[allow(unused)]
pub const ASSERT_END_OF_BYTECODE_SEGMENTS: &str = indoc! {r#"
assert next(bytecode_segments, None) is None"#
Expand Down
1 change: 1 addition & 0 deletions src/hints/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub mod ids {
pub const CURRENT_BLOCK_NUMBER: &str = "current_block_number";
pub const CURRENT_HASH: &str = "current_hash";
pub const DA_START: &str = "da_start";
pub const DATA_TO_HASH: &str = "data_to_hash";
pub const DEPRECATED_TX_INFO: &str = "deprecated_tx_info";
pub const DESCEND: &str = "descend";
pub const DEST_PTR: &str = "dest_ptr";
Expand Down
Loading