-
Notifications
You must be signed in to change notification settings - Fork 4
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
14 changed files
with
139 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; | ||
use cairo_vm::Felt252; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct Param { | ||
pub visibility: Visibility, | ||
pub value: Felt252, | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum Visibility { | ||
Public, | ||
Private, | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct HDPDryRunInput { | ||
pub params: Vec<Param>, | ||
pub compiled_class: CasmContractClass, | ||
} |
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,6 +1,7 @@ | ||
pub mod builtins; | ||
pub mod contract_class; | ||
pub mod dict_manager; | ||
pub mod params; | ||
pub mod program; | ||
pub mod scopes; | ||
pub mod syscall_handler; |
52 changes: 52 additions & 0 deletions
52
cairo_vm_hints/src/hints/lib/contract_bootloader/params.rs
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::{hint_processor::models::Param, hints::vars}; | ||
use cairo_vm::{ | ||
hint_processor::builtin_hint_processor::{ | ||
builtin_hint_processor_definition::HintProcessorData, | ||
hint_utils::{get_ptr_from_var_name, insert_value_from_var_name}, | ||
}, | ||
types::{exec_scope::ExecutionScopes, relocatable::Relocatable}, | ||
vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}, | ||
Felt252, | ||
}; | ||
use std::collections::HashMap; | ||
|
||
pub const LOAD_PARMAS: &str = "ids.params_len = len(params)\nsegments.write_arg(ids.params, [param.value for param in params])"; | ||
|
||
pub fn load_parmas( | ||
vm: &mut VirtualMachine, | ||
exec_scopes: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
let params = exec_scopes.get::<Vec<Param>>(vars::scopes::PARAMS)?; | ||
insert_value_from_var_name( | ||
vars::ids::PARAMS_LEN, | ||
params.len(), | ||
vm, | ||
&hint_data.ids_data, | ||
&hint_data.ap_tracking, | ||
)?; | ||
|
||
let params_base = get_ptr_from_var_name( | ||
vars::ids::PARAMS, | ||
vm, | ||
&hint_data.ids_data, | ||
&hint_data.ap_tracking, | ||
)?; | ||
|
||
write_params(vm, params_base, params)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn write_params( | ||
vm: &mut VirtualMachine, | ||
ptr: Relocatable, | ||
params: Vec<Param>, | ||
) -> Result<(), HintError> { | ||
for (idx, param) in params.into_iter().enumerate() { | ||
vm.insert_value((ptr + idx)?, param.value)?; | ||
} | ||
|
||
Ok(()) | ||
} |
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