-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
303 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,29 @@ | ||
pub mod bit_length; | ||
pub mod left_child; | ||
use cairo_vm::{ | ||
hint_processor::builtin_hint_processor::builtin_hint_processor_definition::HintProcessorData, | ||
types::exec_scope::ExecutionScopes, | ||
vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}, | ||
Felt252, | ||
}; | ||
use std::collections::HashMap; | ||
|
||
mod bit_length; | ||
mod left_child; | ||
|
||
pub fn run_hint( | ||
vm: &mut VirtualMachine, | ||
exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
match hint_data.code.as_str() { | ||
bit_length::MMR_BIT_LENGTH => { | ||
bit_length::mmr_bit_length(vm, exec_scope, hint_data, constants) | ||
} | ||
left_child::MMR_LEFT_CHILD => { | ||
left_child::mmr_left_child(vm, exec_scope, hint_data, constants) | ||
} | ||
_ => Err(HintError::UnknownHint( | ||
hint_data.code.to_string().into_boxed_str(), | ||
)), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,40 @@ | ||
pub mod bit_length; | ||
use cairo_vm::{ | ||
hint_processor::builtin_hint_processor::builtin_hint_processor_definition::HintProcessorData, | ||
types::exec_scope::ExecutionScopes, | ||
vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}, | ||
Felt252, | ||
}; | ||
use std::collections::HashMap; | ||
|
||
pub mod block_header; | ||
pub mod mmr; | ||
pub mod mpt; | ||
pub mod rlp_little; | ||
pub mod utils; | ||
mod bit_length; | ||
mod block_header; | ||
mod mmr; | ||
mod mpt; | ||
mod rlp_little; | ||
mod utils; | ||
|
||
pub fn run_hint( | ||
vm: &mut VirtualMachine, | ||
exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
let hints = [ | ||
bit_length::run_hint, | ||
block_header::run_hint, | ||
mmr::run_hint, | ||
mpt::run_hint, | ||
rlp_little::run_hint, | ||
utils::run_hint, | ||
]; | ||
|
||
for hint in hints.iter() { | ||
let res = hint(vm, exec_scope, hint_data, constants); | ||
if !matches!(res, Err(HintError::UnknownHint(_))) { | ||
return res; | ||
} | ||
} | ||
Err(HintError::UnknownHint( | ||
hint_data.code.to_string().into_boxed_str(), | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,50 @@ | ||
pub mod assert; | ||
pub mod divmod; | ||
pub mod leading_zeros; | ||
pub mod nibbles; | ||
use std::collections::HashMap; | ||
|
||
use cairo_vm::{ | ||
hint_processor::builtin_hint_processor::builtin_hint_processor_definition::HintProcessorData, | ||
types::exec_scope::ExecutionScopes, | ||
vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}, | ||
Felt252, | ||
}; | ||
|
||
mod assert; | ||
mod divmod; | ||
mod leading_zeros; | ||
mod nibbles; | ||
|
||
pub fn run_hint( | ||
vm: &mut VirtualMachine, | ||
exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
match hint_data.code.as_str() { | ||
assert::HINT_EXPECTED_LEADING_ZEROES => { | ||
assert::hint_expected_leading_zeroes(vm, exec_scope, hint_data, constants) | ||
} | ||
assert::HINT_EXPECTED_NIBBLE => { | ||
assert::hint_expected_nibble(vm, exec_scope, hint_data, constants) | ||
} | ||
divmod::HINT_POW_CUT => divmod::hint_pow_cut(vm, exec_scope, hint_data, constants), | ||
leading_zeros::HINT_EXPECTED_LEADING_ZEROES => { | ||
leading_zeros::hint_expected_leading_zeroes(vm, exec_scope, hint_data, constants) | ||
} | ||
leading_zeros::HINT_EXPECTED_NIBBLE => { | ||
leading_zeros::hint_expected_nibble(vm, exec_scope, hint_data, constants) | ||
} | ||
nibbles::HINT_IS_ZERO => nibbles::hint_is_zero(vm, exec_scope, hint_data, constants), | ||
nibbles::HINT_NIBBLE_FROM_LOW => { | ||
nibbles::hint_nibble_from_low(vm, exec_scope, hint_data, constants) | ||
} | ||
nibbles::HINT_NEEDS_NEXT_WORD => { | ||
nibbles::hint_needs_next_word(vm, exec_scope, hint_data, constants) | ||
} | ||
nibbles::HINT_NEEDS_NEXT_WORD_ENDING => { | ||
nibbles::hint_needs_next_word_ending(vm, exec_scope, hint_data, constants) | ||
} | ||
nibbles::HINT_WORDS_LOOP => nibbles::hint_words_loop(vm, exec_scope, hint_data, constants), | ||
_ => Err(HintError::UnknownHint( | ||
hint_data.code.to_string().into_boxed_str(), | ||
)), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,46 @@ | ||
pub mod assert; | ||
pub mod carry; | ||
pub mod divmod; | ||
pub mod trailing_zeroes; | ||
pub mod write; | ||
use std::collections::HashMap; | ||
|
||
use cairo_vm::{ | ||
hint_processor::builtin_hint_processor::builtin_hint_processor_definition::HintProcessorData, | ||
types::exec_scope::ExecutionScopes, | ||
vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}, | ||
Felt252, | ||
}; | ||
|
||
mod assert; | ||
mod carry; | ||
mod divmod; | ||
mod trailing_zeroes; | ||
mod write; | ||
|
||
pub fn run_hint( | ||
vm: &mut VirtualMachine, | ||
exec_scope: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
match hint_data.code.as_str() { | ||
assert::HINT_ASSERT_INTEGER_DIV32 => { | ||
assert::hint_assert_integer_div32(vm, exec_scope, hint_data, constants) | ||
} | ||
assert::HINT_ASSERT_INTEGER_DIV => { | ||
assert::hint_assert_integer_div(vm, exec_scope, hint_data, constants) | ||
} | ||
carry::HINT_CARRY => carry::hint_carry(vm, exec_scope, hint_data, constants), | ||
divmod::HINT_VALUE_DIV32 => divmod::hint_value_div32(vm, exec_scope, hint_data, constants), | ||
divmod::HINT_VALUE_8 => divmod::hint_value_8(vm, exec_scope, hint_data, constants), | ||
divmod::HINT_VALUE_DIV => divmod::hint_value_div(vm, exec_scope, hint_data, constants), | ||
trailing_zeroes::HINT_TRAILING_ZEROES_BYTES => { | ||
trailing_zeroes::hint_trailing_zeroes_bytes(vm, exec_scope, hint_data, constants) | ||
} | ||
write::HINT_WRITE_2 => write::hint_write_2(vm, exec_scope, hint_data, constants), | ||
write::HINT_WRITE_3 => write::hint_write_3(vm, exec_scope, hint_data, constants), | ||
write::HINT_WRITE_4 => write::hint_write_4(vm, exec_scope, hint_data, constants), | ||
write::HINT_WRITE_5 => write::hint_write_5(vm, exec_scope, hint_data, constants), | ||
write::HINT_WRITE_6 => write::hint_write_6(vm, exec_scope, hint_data, constants), | ||
write::HINT_WRITE_7 => write::hint_write_7(vm, exec_scope, hint_data, constants), | ||
_ => Err(HintError::UnknownHint( | ||
hint_data.code.to_string().into_boxed_str(), | ||
)), | ||
} | ||
} |
Oops, something went wrong.