-
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
38 changed files
with
1,357 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ version = "0.1.0" | |
edition = "2023_11" | ||
|
||
members = [ | ||
"cairo1" | ||
"hdp_cairo" | ||
] | ||
|
||
[workspace.dependencies] | ||
|
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,5 +1,28 @@ | ||
use crate::vars; | ||
use cairo_vm::{ | ||
hint_processor::builtin_hint_processor::{builtin_hint_processor_definition::HintProcessorData, hint_utils::insert_value_into_ap}, | ||
types::exec_scope::ExecutionScopes, | ||
vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}, | ||
Felt252, | ||
}; | ||
use std::collections::HashMap; | ||
use types::proofs::Proofs; | ||
|
||
pub mod account_verifier; | ||
pub mod header_verifier; | ||
pub mod receipt_verifier; | ||
pub mod storage_item_verifier; | ||
pub mod transaction_verifier; | ||
|
||
pub const HINT_HEADERS_WITH_MMR_LEN: &str = "memory[ap] = to_felt_or_relocatable(len(batch.headers_with_mmr))"; | ||
|
||
pub fn hint_headers_with_mmr_headers_len( | ||
vm: &mut VirtualMachine, | ||
exec_scopes: &mut ExecutionScopes, | ||
_hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
let proofs = exec_scopes.get::<Proofs>(vars::scopes::BATCH)?; | ||
|
||
insert_value_into_ap(vm, Felt252::from(proofs.headers_with_mmr.len())) | ||
} |
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,41 +1,64 @@ | ||
use crate::vars; | ||
use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::HintProcessorData; | ||
use cairo_vm::hint_processor::builtin_hint_processor::hint_utils::insert_value_into_ap; | ||
use cairo_vm::hint_processor::builtin_hint_processor::hint_utils::{get_integer_from_var_name, insert_value_into_ap}; | ||
use cairo_vm::{ | ||
types::exec_scope::ExecutionScopes, | ||
vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}, | ||
Felt252, | ||
}; | ||
use std::{any::Any, collections::HashMap}; | ||
use types::proofs::Proofs; | ||
use types::ChainProofs; | ||
|
||
pub const HINT_VM_ENTER_SCOPE: &str = "vm_enter_scope({'batch': proofs, '__dict_manager': __dict_manager})"; | ||
pub const HINT_CHAIN_PROOFS_LEN: &str = "memory[ap] = to_felt_or_relocatable(len(chain_proofs))"; | ||
|
||
pub fn hint_vm_enter_scope( | ||
_vm: &mut VirtualMachine, | ||
pub fn hint_chain_proofs_len( | ||
vm: &mut VirtualMachine, | ||
exec_scopes: &mut ExecutionScopes, | ||
_hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
let batch: Box<dyn Any> = Box::new(exec_scopes.get::<Proofs>(vars::scopes::PROOFS)?); | ||
let dict_manager: Box<dyn Any> = Box::new(exec_scopes.get_dict_manager()?); | ||
exec_scopes.enter_scope(HashMap::from([ | ||
(String::from(vars::scopes::BATCH), batch), | ||
(String::from(vars::scopes::DICT_MANAGER), dict_manager), | ||
])); | ||
let chain_proofs = exec_scopes.get::<Vec<ChainProofs>>(vars::scopes::CHAIN_PROOFS)?; | ||
insert_value_into_ap(vm, Felt252::from(chain_proofs.len())) | ||
} | ||
|
||
Ok(()) | ||
pub const HINT_CHAIN_PROOFS_CHAIN_ID: &str = "memory[ap] = to_felt_or_relocatable(chain_proofs[ids.idx - 1].chain_id)"; | ||
|
||
pub fn hint_chain_proofs_chain_id( | ||
vm: &mut VirtualMachine, | ||
exec_scopes: &mut ExecutionScopes, | ||
hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
let chain_proofs = exec_scopes.get::<Vec<ChainProofs>>(vars::scopes::CHAIN_PROOFS)?; | ||
let idx: usize = get_integer_from_var_name(vars::ids::IDX, vm, &hint_data.ids_data, &hint_data.ap_tracking)? | ||
.try_into() | ||
.unwrap(); | ||
insert_value_into_ap(vm, Felt252::from(chain_proofs[idx - 1].chain_id())) | ||
} | ||
|
||
pub const HINT_HEADERS_WITH_MMR_LEN: &str = "memory[ap] = to_felt_or_relocatable(len(batch.headers_with_mmr))"; | ||
pub const HINT_VM_ENTER_SCOPE: &str = "vm_enter_scope({'batch': chain_proofs[ids.idx - 1].value, '__dict_manager': __dict_manager})"; | ||
|
||
pub fn hint_headers_with_mmr_headers_len( | ||
pub fn hint_vm_enter_scope( | ||
vm: &mut VirtualMachine, | ||
exec_scopes: &mut ExecutionScopes, | ||
_hint_data: &HintProcessorData, | ||
hint_data: &HintProcessorData, | ||
_constants: &HashMap<String, Felt252>, | ||
) -> Result<(), HintError> { | ||
let proofs = exec_scopes.get::<Proofs>(vars::scopes::BATCH)?; | ||
let chain_proofs = exec_scopes.get::<Vec<ChainProofs>>(vars::scopes::CHAIN_PROOFS)?; | ||
let idx: usize = get_integer_from_var_name(vars::ids::IDX, vm, &hint_data.ids_data, &hint_data.ap_tracking)? | ||
.try_into() | ||
.unwrap(); | ||
|
||
let batch: Box<dyn Any> = match chain_proofs[idx - 1].clone() { | ||
ChainProofs::EthereumMainnet(proofs) => Box::new(proofs), | ||
ChainProofs::EthereumSepolia(proofs) => Box::new(proofs), | ||
}; | ||
let dict_manager: Box<dyn Any> = Box::new(exec_scopes.get_dict_manager()?); | ||
|
||
insert_value_into_ap(vm, Felt252::from(proofs.headers_with_mmr.len())) | ||
exec_scopes.enter_scope(HashMap::from([ | ||
(String::from(vars::scopes::BATCH), batch), | ||
(String::from(vars::scopes::DICT_MANAGER), dict_manager), | ||
])); | ||
|
||
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.